# Week 3 - Exercise 8 - nn_model - help

Hi,
In the programming assignments, all my previous functions pass the tests, but when I go about combining them in the nn_model function, while it does not seem like there is an obvious error, the result is not what is expected. Any suggestion about how to investigate it (without pasting my code directly) ? My test output is below:

## Cost after iteration 0: 0.693159 Cost after iteration 1000: 0.693159 Cost after iteration 2000: 0.693159 Cost after iteration 3000: 0.693159 Cost after iteration 4000: 0.693159 Cost after iteration 5000: 0.693159 Cost after iteration 6000: 0.693159 Cost after iteration 7000: 0.693159 Cost after iteration 8000: 0.693159 Cost after iteration 9000: 0.693159 W1 = [[-0.00278734 0.01525596] [-0.00484164 -0.0114673 ] [ 0.01110381 0.01841291] [-0.00604522 0.03017888]] b1 = [[0.] [0.] [0.] [0.]] W2 = [[-0.01036626 -0.00577783 -0.00922438 0.0098561 ]] b2 = [[0.]]

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.71392202 1.31281102]
[-0.76411243 -1.41967065]
[-0.75040545 -1.38857337]
[ 0.56495575 1.04857776]]
b1 = [[-0.0073536 ]
[ 0.01534663]
[ 0.01262938]
[ 0.00218135]]
W2 = [[ 2.82545815 -3.3063945 -3.16116615 1.8549574 ]]
b2 = [[0.00393452]]
All tests passed!

Notice that your cost values don’t change and that your b1 and b2 values are still zero. So the thing to check is whether your “update parameters” logic is getting invoked correctly. Note that you wrote that function earlier and if it passed the test cases, then it is probably correct. But there could be a problem in nn_model where you are either not calling that function or somehow not using the return values that you are getting from it correctly.

Thanks, it was a typo, I was updating parmeters

Thanks.

Glad to hear that you were able to find the issue based on just that hint. Nice work!

Programming is a game of details: a single character wrong or out of place can ruin everything.