I have been trying to fix this for hours and I don’t know what went wrong. It seems like the code run into a dimensional problem in layer 2, where it tries to multiply W2 with X instead of with A1. Does that mean the for loop stop iterating? What should I do?
Hi @Rongqing_Yuan
Welcome to the community!
When you call function linear_activation_forward() you should update the A_prev with the new A at every iteration to make a correct connection of forward path
Happy Ramadan!
Best Regards,
Abdelrahman
There was actually a line (A_prev=A) in the code provided that suppose to do this job. I copied and pasted it again, run the code, delete it, and rerun the code a few times and it eventually went through. I still don’t know what causes the problem but could be because of the Jupyter itself (I guess?)
Hello Rongqing,
Try restarting the kernel by clearing all the outputs, run the cells from the beginning through shift +enter key and then work on your code. Hope it will resolve the issue.
Yes! My guess is just that you confused yourself by not actually executing the code after you modified it. Just typing new code in a function cell and then calling the function again does nothing: it just runs the old version of the code. You have to actually click “Shift-Enter” on the function cell itself in order to get the new code “compiled” (well, interpreted really, but the point is the same).
Now that you are aware of this, you can easily demonstrate how it works. Take a function that works and purposely change the code to break it. E.g. multiply the correct answer by 2. Now run the test cell again. It still works, right? Now click “Shift-Enter” on the function cell and then run the test again. Kaboom!