The linear_activation_forward still works fine (at least, it passes the test).
Now, when I use it in my code for Exercise 5, I get the following error message:
#############################################################
UnboundLocalError Traceback (most recent call last)
in
1 t_X, t_parameters = L_model_forward_test_case_2hidden()
----> 2 t_AL, t_caches = L_model_forward(t_X, t_parameters)
3
4 print("AL = " + str(t_AL))
5
in L_model_forward(X, parameters)
30 #W=parameters[“W”+str(l)]
31 #b=parameters[“b”+str(l)]
—> 32 A,cache=linear_activation_forward(A_prev,parameters[“W”+str(l)],parameters[“b”+str(l)],relu)
33 caches.append(cache)
34 # YOUR CODE ENDS HERE
in linear_activation_forward(A_prev, W, b, activation)
40 A,activation_cache=relu(Z)
41 # YOUR CODE ENDS HERE
—> 42 cache = (linear_cache, activation_cache)
43 #print("A_neu: ",A)
44 return A, cache
UnboundLocalError: local variable ‘linear_cache’ referenced before assignment
################################################################
I tried to fix this by inserting the following into the code for linear_activation_forward:
linear_cache=
activation_cache=
A=A_prev
With these ingredients, the code runs, but now, the loop in model_forward with the lines
Moderator edit: code removed.
does no longer change A. (I had it print A, and it just remains the same in every iteration.)
I suppose the first error should not have happened in the first place, and my attempt to fix it does not work as it should. Any help would be appreciated…