Hi - I’m on the last exercise of Wk3 of the Deep Learning assignment and I get a “Tests Failed” error even though the output of my cell matches exactly the ‘Expected Output’. i’ve been trying to figure out what is the issue but no luck. Any pointers will be appreciated. Thank you!
The problem is that there is more than one test there. You can see the output of the first test, but the others are contained in the file
public_tests.py. The problem is the way you have copied the input
params variable. That is a dictionary, but you did a simple copy. That does not actually copy the entries in the dictionary, which in this case are numpy arrays which are python objects. So you are actually updating the global variables that are being passed in. That’s why the second set of tests failed: you’ve modifed the input values.
Here’s a thread which discusses this point in more detail. The “TL;DR” is that you need to use “deepcopy” not simple copy. That’s the cleanest solution or you can individually copy the entries in the
params dictionary. Or you can rewrite the code not to use the “in place” operator += to do the individual updates. That is explained on that other thread.
That definitely helped! Read the linked thread as well - Great info. Thank you @paulinpaloalto !
That’s good to hear! Did you also read the later example on that same thread?
I did indeed. Good stuff!