Hi @Mubsi@paulinpaloalto
I am getting an assertion error in Week 3 exercise 8 (nn_model)
I would appreciate it if you could help me to find out what is wrong
I checked every single code multiple times but still wonder why the result of every iteration is nan
my id is ebylrvbd
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)
<ipython-input-53-1243cded3c7d> in <module>
----> 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
The first place I would check is your âupdate parametersâ logic. Are you sure that function passed its tests? E.g. make sure you are subtracting the update term, not adding it. Your W and b values are crazy large.
Hmmm, ok, then it looks like we need a new theory. So the bug must be in the nn_model routine. Are you sure that the variable names are consistent for the parameters and gradient dictionaries from when you call forward and back prop versus the names you pass to âupdate parametersâ?
Everything seems to be right
I really donât know what the problem is
Is it possible for you to check my code directly using my lab id? or I can send them to you in a direct message if Iâm allowed
It turns out that itâs a variant of the problem that I theorized about there. Look carefully at how you store the return values from forward propagation. You misspelled one of the variable names which results in the wrong data being used.
Hello! my id is ânzwpnnsnâ.
I couldnât solve the problem even though there are similar problems in this thread.
Other tests are passed except nn_model_test(nn_model) . Iâve attached the screenshot.
Only the course staff can actually look at anyoneâs notebook by using the notebook ID. The mentors are just fellow student volunteers and we do not have that âsuperpowerâ. But check your DMs for some alternate ways to approach this type of problem.
It looks like your output is the ones when you set the seed for a random number generator to 2.
This test sets ânp.random.seed(3)â and compares results. If you (or any of functions that you use) override this seed, then, the output will be different from expected.
Possible cases are
inside "initialize_parameters()
in ânn_model()â before calling âinitialize_parameters()â.
Thank you Nobu_Asai, It resolved the problem but I had to copy the initialize function which I think affected the grading system and now got stuck with 5.2 - Test the Model on the Planar Dataset It shows the following error:
Initialize_parameters() is already in this note book. Iâm afraid that you copy/paste some functions, and also modified functions itself to pass additional parameters. That should cause additional problems.
Please revert back all functions to original forms.
Hi! Nobu_Asai,
If I changed the initialize_parameters functionâs np.random.seed(2) to 3 then it causes problem in test case right after that cell but works fine for nn_model function which had an issue before.
Thatâs why I had to clone the function.