函数内的函数没有定义?

时间:2018-05-30 20:35:23

标签: jupyter-notebook

您好我的代码编写如下。它是用ipython编写的,所以每个函数都写在一个单元格中。

**Cell 1:**
def linear_activation_forward(A_prev, W, b, activation):
    *some code*
    return A, cache

**Cell 2:**
def L_model_forward(X, parameters):
    *some code*
    AL, cache = linear_activation_forward(A, 
                                             parameters["W" + str(L)], 
                                             parameters["b" + str(L)], 
                                             activation='sigmoid')
    *some code*
    return AL, caches

**Cell 3:**
def L_layer_model(X, Y, layers_dims, learning_rate = 0.0075, num_iterations = 3000, print_cost=False):
    *some code*
     AL, caches = L_model_forward(X, parameters)
    *some code*
    return parameters

**cell4**
parameters = L_layer_model(train_x, train_set_y_orig, layer_dims, learning_rate = 0.0075, num_iterations = 3000, print_cost = True)

如果我运行Cell 1,我没有错误 如果我运行Cell 2,我没有错误 如果我运行Cell 3,我没有错误 如果我运行Cell 4,那么我的单元格1的功能没有定义

NameError:name' linear_activation_forward'未定义

有人有任何线索吗? Tnx

0 个答案:

没有答案