The cost value is going up from first iterations and than it turns in to nan after a few hundreds of iterations . I would appreciate any help. Restarting of the kernel did not help.
Cost after iteration 0: 0.693198
Cost after iteration 1000: nan
Cost after iteration 2000: nan
Cost after iteration 3000: nan
Cost after iteration 4000: nan
Cost after iteration 5000: nan
Cost after iteration 6000: nan
Cost after iteration 7000: nan
Cost after iteration 8000: nan
Cost after iteration 9000: nan
W1 = [[ -16151.48761099 40094.87691492]
[-360708.80502007 896694.73776285]
[ 17194.29194027 -42664.68066471]
[ 209432.69985165 -519775.95648378]]
b1 = [[ -9454.14941358]
[-211131.57910882]
[ 10053.6841467 ]
[ 122511.81043522]]
W2 = [[ -9.46131057 -211.85626202 10.08675527 122.71208997]]
b2 = [[1998.68544]]
AssertionError Traceback (most recent call last)
in
----> 1 nn_model_test(nn_model)
~/work/release/W3A1/public_tests.py in nn_model_test(target)
292 assert output[“b2”].shape == expected_output[“b2”].shape, f"Wrong shape for b2."
293
→ 294 assert np.allclose(output[“W1”], expected_output[“W1”]), “Wrong values for W1”
295 assert np.allclose(output[“b1”], expected_output[“b1”]), “Wrong values for b1”
296 assert np.allclose(output[“W2”], expected_output[“W2”]), “Wrong values for W2”
AssertionError: Wrong values for W1
Expected output
Cost after iteration 0: 0.693198
Cost after iteration 1000: 0.000219
Cost after iteration 2000: 0.000108
…
Cost after iteration 8000: 0.000027
Cost after iteration 9000: 0.000024
W1 = [[ 0.56305445 -1.03925886]
[ 0.7345426 -1.36286875]
[-0.72533346 1.33753027]
[ 0.74757629 -1.38274074]]
b1 = [[-0.22240654]
[-0.34662093]
[ 0.33663708]
[-0.35296113]]
W2 = [[ 1.82196893 3.09657075 -2.98193564 3.19946508]]
b2 = [[0.21344644]]
All tests passed!
All tests passed.
Restarting the kernel won’t help if your code is wrong. I’m guessing that your “update parameters” logic is incorrect. Are you perhaps adding instead of subtracting?
Thank you for your reply. Generally I have got all right values and all test passed signs on all previous exercises. I tried to play with other parts of the code including update parameters part but with no clear outcome. I am not sure how to hunt the error in most efficient way. I can think only about going through each step manually, which might take some time.
You are very true. Finding mistakes is not that easy
I suggest you to create a cell below the cell and try working on each of the codes, you have modified step-by-step. This will lead you to your goal.
Its a friendly suggestion though, not a professional one. You need to have that eye of a programmer that hunts out for every code in a specific manner.
Hey @Sergiy_Tokar,
Welcome to the community. I agree with what @Rashmi says. Still, if you find difficulty in finding the issue, feel free to share your code with any of the mentors, since the issue is something that the test cases are unable to catch. Make sure to DM your code to one of the mentors, and not post it here publicly, since it is against the community guidelines.
Please check the earlier cell carrying the Graded function on “nn_model”. You might have used any global variables or would have missed any important component within the equations, which is throwing an error in the test model.
Also, after making the changes, try saving it and run all the cells from the beginning to get the right outcome. Let us see if that works for you!