I was stuck in the “Update Parameters” function step in the Neural Networks and Deep Learning C1W3 Assignment, where I received the following error. Also, b2 was also different from the expected output. I passed tests on both b1 (initialisation function) and db1 (backward propagation function). I used the following to update b1 : b1 = b1 - learning rate * db1. Not sure what went wrong and my b1 output is a number instead of a 4X1 vector. Need some guidance. Thanks.
The parameters and gradients are given by the test case. You can use a print statement to print out the shape of W1,b1 and W2,b2 to help find where the problem might be.
Did you modify any other code in the update_parameters() function, or in its test cell?
The test for update_parameters() does not call any of your other functions. So the issue would only be in that function, or maybe due to some other changes you made by accident.
The only other likely place for an error is in the code for db1 = ...
Thanks a lot. I might have accidentally changed some codes in the update_parameters() function as I passed all tests before this issue happened. Mind guiding me:
(a) the way to reset the function to the original so that I can start afresh of my work on the function again or
(b) if this doesn’t work, the way to wipe everything clean to start the whole assignment again. I don’t mind that as I have already saved a copy of my work in a notebook so that I can copy and paste my work prior to the function.
I already tried Lab Help to update the notebook to the latest version. It did not help (probably not the right way). Sorry for so many questions as I am new to this course/Specialisation. Thx again.
To get a new copy of the notebook, you need to rename your current copy (using “File → Rename”), then use “Help → Get latest version” to get a new copy.
Then use the File menu to Open the new copy. It will be the one with the original file name.
I managed to get a new copy and start afresh on the assignment again. Yet, the same issue happened when I reached the “update_parameter” function. I added a new line and used the print statement on all the parameters just before the said function. All of them showed the message of “undefined” except for A2, a 1x3 vector. I suspect this might have caused the issue. Need some help/guidance.
You need to refresh the kernel and rerun all the code cells.
From the menu bar on the top of your notebook, please try the following:
kernel ->restart and clear all output
and then rerun all the code cell from start
Thanks for your prompt response. I followed the suggestion to clear all output and rerun all the code from the start. The same issue happened reaching the update_parameter(). I printed all the parameters before the function step - all are undefined except A2. Need help on this.
Pls see the attached screenshot of what I meant on A2. I added one cell before the update_parameters fn, and printed the parameters one by one (I included 2 parameters, A1 and A2, for illustration sake). The print statement was outside of any specific function and I suppose all parameters should read “undefined”. The exception is on A2. I suspect this might have caused the issue (but I might be wrong). Appreciate guidance.
You can not just add a cell above the update_parameters() function to access the values passed into the function. As the values passed to the function are specified when the function is called, therefore, it has nothing to do with variables declared from other code cell.
Please follow the my suggestion from earlier reply and put the print statement within the function.
In order for you to get the most out of the course, you might like to enrol to a python programming course.
Here is a link to a list of python programming courses from Coursera
In addition to @Kic’s excellent comments, the update_parameters() function doesn’t even use the variables A1 or A2. So it isn’t clear to me why you would want to print them at that point in the notebook.
And W1 is used in that function, but it a key in the “parameters” dictionary. You have to read it from the dictionary and assign it to a local ‘W1’ variable before you can use it.
The only way that A1, A2, and W1 would be defined at that point in the code where you added cell In[23], would be if they were global variables.
Global variables are generally not a good idea.
I agree that maybe a tutorial on Python programming would be useful for you.
Thanks for the info and guidance. If A2 is not the issue, I would rework my coding on that function once again. Regarding W1, I already used copy.deepcopy(…“W1”) and assigned it to local W1 variable within the function. It seemed to work fine. Rgds.