W4_A2 _Ex-1_local variable ‘A’ referenced before assignment

I run my code, and this message comes out.
I have no idea - what part is wrong in my code.
Could you give me a hand?

UnboundLocalError Traceback (most recent call last)
----> 1 parameters, costs = two_layer_model(train_x, train_y, layers_dims = (n_x, n_h, n_y), num_iterations = 2, print_cost=False)
3 print("Cost after first iteration: " + str(costs[0]))
5 two_layer_model_test(two_layer_model)

in two_layer_model(X, Y, layers_dims, learning_rate, num_iterations, print_cost)
46 # A2, cache2 = …
—> 48 A1, cache1 = linear_activation_forward(X, W1, b1, relu)
49 A2, cache2 = linear_activation_forward(A1, W2, b2, sigmoid)

~/work/release/W4A2/dnn_app_utils_v3.py in linear_activation_forward(A_prev, W, b, activation)
209 A, activation_cache = relu(Z)
→ 211 assert (A.shape == (W.shape[0], A_prev.shape[1]))
212 cache = (linear_cache, activation_cache)

UnboundLocalError: local variable ‘A’ referenced before assignment

You are passing an incorrect value for the “activation” parameter to linear_activation_forward. Take a look at the source for linear_activation_forward (we wrote it in the previous exercise and we’re just using it here): how could you fall through that code and not set the value of A? It means the value of activation did not match either of the choices in the conditional logic there.

So how could that happen? Note that in python relu and "relu" are not the same thing: the former is an object reference to the function and the latter is a python string that happens to be the name of the function. And if you try this expression:

relu == "relu"

you will find that it evaluates to False. :nerd_face: