Week 4, Ass. 2, Ex. 1: two_layer_model

Hello, I 'm getting this error and I can’t figure out what’s is wrong, it seems to me that all functions are written properly.
Any suggestions ?
Thanks in advance.

Cost after iteration 1: nan
Cost after first iteration: nan
Cost after iteration 1: nan
Cost after iteration 1: nan
Cost after iteration 1: nan
Error: Wrong output for variable W1.
Error: Wrong output for variable b1.
Error: Wrong output for variable W2.
Error: Wrong output for variable b2.
Error: Wrong output for variable 0.
Cost after iteration 2: nan
Error: Wrong output for variable W1.
Error: Wrong output for variable b1.
Error: Wrong output for variable W2.
Error: Wrong output for variable b2.
Error: Wrong output for variable 0.
 2  Tests passed
 2  Tests failed
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-26-f9ec5304d38d> in <module>
      3 print("Cost after first iteration: " + str(costs[0]))
      4 
----> 5 two_layer_model_test(two_layer_model)

~/work/release/W4A2/public_tests.py in two_layer_model_test(target)
     75     ]
     76 
---> 77     multiple_test(test_cases, target)
     78 
     79 

~/work/release/W4A2/test_utils.py in multiple_test(test_cases, target)
    140         print('\033[92m', success," Tests passed")
    141         print('\033[91m', len(test_cases) - success, " Tests failed")
--> 142         raise AssertionError("Not all tests were passed for {}. Check your equations and avoid using global variables inside the function.".format(target.__name__))
    143 

AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.

You can follow the same debugging steps as other learners have been recommended:

1 Like

I know that the error might be in a typo, I 've revised the spelling more than one time and I couldn’t find any, Thanks for your suggestion but I 'm asking if anything might be wrong in the logic or functions.

I supplied the link so you can read about how to debug this type of problem, not to read about this specific student’s exact solution to a NaN problem. You likely have a different mistake. I advice you to debug your loop using similar steps in order to find out where you might have a bug :slight_smile:

1 Like

@jonaslalin Thanks so much for your help, problem solved, it was error in activations types in some functions :sweat_smile:

1 Like

Good job! It is always good not to get the answer directly, but to find it yourself. You learn so much more that way :smiley:

1 Like

Yeah, of course :smiley:
There are times I 'm stuck in a certain part for days because of a small typo, knowing how to deal with problems is a core skill of a programmer :slightly_smiling_face:

1 Like