Programming Assignment Deep Neural Network - two_layer_model test

I am having the following error:
Cost after first iteration: 0.6950464961800915
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.
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-44-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.

It appears there are some errors in your two_layer_model() function.

Thanks for reaching out. Yes I am aware there are some errors in my two_layer_model() function. It is just difficult to figure them out, the message is very cryptic.

To see which test conditions are failing, you can to go the File menu and Open the “public_tests.py” file. This contains the two_layer_model_test() function, so you an inspect the tests that your code does not pass.

This assignment applies the “helper” functions that we created in the previous assignment. It should be relatively straightforward. If you get the incorrect results, then it means you are somehow calling those functions incorrectly.

A couple of general things to check:

Did you manually copy over your functions from the previous “Step by Step” exercise? If so, that is a mistake. They provided in “import” file that gives you those functions and at least one of them is different than what we actually built previously, although that difference doesn’t manifest until you get to the “L layer” case.

Make sure you are not “hard-coding” any parameters, e.g. the learning rate, then you call the helper functions like update_parameters from two_layer_model. There should be no equal signs in any of the parameters that you passed to update_parameters.

Make sure you are using the activation functions correctly. It is relu for the hidden layer and sigmoid for the output layer, right? But remember that on back prop, the layers happen in the reverse order.

If none of those suggestions shed any further light, then let us know and we’ll proceed from there.

1 Like

Here’s my result from that test cell:

Cost after first iteration: 0.693049735659989
 All tests passed.

Notice that my cost value is different. So you are passing some different parameters somewhere in two_layer_model.

thanks to everybody. I did figure it out. I was passing the wrong params to “initialize_params”

2 Likes

That’s great news that you were able to solve it just based on those general suggestions. Thanks for confirming!