Week4 Ex5:local variable referenced before assignment

Hi I have the following problem:
I get:


The error occurs in a function that has already passed the test, i.e. my 'linear_activation_forward# and the part where the error shows is not even one that I wrote is that correct?
Where is my mistake then?
Thanks for the help!

It is a general principle of debugging that just because the error is thrown in a particular function, that does not mean that is where the actual bug is. It could be, as in this case, that the problem is you passed incorrect parameters to that routine. Take a look at the logic in linear_activation_forward. Look at the boolean conditions that select the various logic paths based on the activation argument. You’ll notice that those conditions are expecting a string name of a function. That is not what you are passing: you are passing a python object reference to the function.

So even though you did not write the logic that throws the error, it is actually caused by a mistake in your code.

BTW once you have solved this problem, please edit your original post to remove the source code. It helps to see it for debugging, although just the error message would have been enough in this particular case, but we don’t want to leave solution code sitting around in the forums for people to see. Thanks!


Thank you so much. It’s these little things that are the hardest to find :slight_smile:

1 Like

Exactly. You can stare right at it and not “see” it. :scream_cat:

Thanks a lot for editing your post to remove the source code! :+1:

{moderator edit: no original content in this post, just a quote of an earlier post on this thread}