Week -3 NN_Model error , All the block level codes passed

Cost after iteration 0: 0.692739
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 = [[ -16186.13630757 40180.82996963]
[-360723.53188029 896731.32715588]
[ 17257.96007911 -42822.70465944]
[ 209480.75357122 -519895.20920142]]
b1 = [[ -9474.41783091]
[-211140.18602741]
[ 10090.92043859]
[ 122539.91698547]]
W2 = [[ -9.47145191 -211.86057992 10.10540846 122.72616583]]
b2 = [[1998.68544]]
Error: Wrong output for variable W1.
Error: Wrong output for variable b1.
Error: Wrong output for variable W2.
Error: Wrong output for variable b2.
2 Tests passed
1 Tests failed

AssertionError Traceback (most recent call last)
in
7 print("b2 = " + str(parameters[“b2”]))
8
----> 9 nn_model_test(nn_model)

~/work/release/W3A1/public_tests.py in nn_model_test(target)
306 ]
307
→ 308 multiple_test(test_cases, target)
309
310 def predict_test(target):

~/work/release/W3A1/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 nn_model. Check your equations and avoid using global variables inside the function.

Once go through all the equations and check whether any parameters are missing.

Also check to make sure you used sigmoid and not tanh as the activation function at the output layer.

Hi Paulinpaloalto ,
Update_parameters function have learning_rate = 1.2 in block level code
but in nn_model function there is no learning_rate ,If we include learning rate value also cost value is increasing

What value did you specify for learning rate at the nn_model level to get an increasing cost? The point of the test cases in the notebook is that they don’t specify the LR, so you end up using the default value declared in the function definition of update_parameters, which is (as you mention) 1.2.

Thanks for your reply ,
if its default 1.2 means
Cost value is nan after 1000 iterations
if i put 0.01 as learning rate then its increasing trend

I used the default 1.2 and I did not have the problem with NaN for cost after 1000 iterations. So all this says is that there is a problem somewhere else in your code.

But maybe you can use that as a clue: maybe the problem is in how you implemented the parameter update logic. Notice that all your W values are huge. Maybe you used addition instead of subtraction:

W = W + <... update formula ...>

instead of

W = W - <... update formula ...>

Are you sure that you checked all the test results on your previous functions like update_parameters?

I had a similar problem.

There are some global variables that we (students) are not aware of, and some times this variables have a similar names to the ones used to return in function.
In my case, the problem was a misspelled word that mach the name of a global variable.