in L_layer_model(X, Y, layers_dims, learning_rate, num_iterations, print_cost)
43 # cost = …
44 # YOUR CODE STARTS HERE
—> 45 cost = compute_cost(AL,Y)
46
47 # YOUR CODE ENDS HERE
~/work/release/W4A2/dnn_app_utils_v3.py in compute_cost(AL, Y)
265
266 cost = np.squeeze(cost) # To make sure your cost’s shape is what we expect (e.g. this turns [[17]] into 17).
→ 267 assert(cost.shape == ())
268
269 return cost
Hi, Kimberly. Check out my [“sermon”] I just delivered as the last post in this thread. I’d hate to do it twice!
The exception is being thrown at the compute_cost function which you have loaded from the dnn_app_utils_v3 module in the very first cell. All of the functions have been supplied so I hope that you are not invoking your own. So just climb up the “call-stack” to check if the problem is upstream. Where are the parameters to the cost function, AL and Y, produced? We know compute_cost is correct, right?
I realized I called linear_activation_forward instead of L_model_forward, but after correction, the error message looks worse…everything is just WRONG
Cost after iteration 0: 0.693049735659989
Cost after first iteration: 0.693049735659989
Error: Wrong output
Error: Datatype mismatch.
Error: Wrong shape
Error: Wrong output
0 Tests passed
4 Tests failed
AssertionError Traceback (most recent call last)
in
3 print("Cost after first iteration: " + str(costs[0]))
4
----> 5 L_layer_model_test(L_layer_model)
~/work/release/W4A2/public_tests.py in L_layer_model_test(target)
181 ]
182
→ 183 multiple_test(test_cases, target)
~/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 L_layer_model. Check your equations and avoid using global variables inside the function.
Ohhh. This looks like another came I came across recently. Have you called the function initilize_parameters rather than initialize_parameter_deep? You have to do something with that global variable defined in the the previous cell, right? Take another look at the instructions and the signatures of the functions called. Maybe sermons aren’t so bad after all.
with reference to the above context (“Not all tests were passed for L_layer_model. Check your equations and avoid using global variables inside the function.”
I have called initialize_parameter_deep as follows
parameters = initialize_parameters_deep(layers_dims)
though, you gave big hint to overcome issue, somehow, I am unable to figure it out, request you to help.
Cost after iteration 0: 0.7717493284237686
Cost after first iteration: 0.7717493284237686
Error: Wrong output
Error: Datatype mismatch.
Error: Wrong shape
Error: Wrong output
0 Tests passed
4 Tests failed
AssertionError Traceback (most recent call last)
in
3 print("Cost after first iteration: " + str(costs[0]))
4
----> 5 L_layer_model_test(L_layer_model)
~/work/release/W4A2/public_tests.py in L_layer_model_test(target)
181 ]
182
→ 183 multiple_test(test_cases, target)
~/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 L_layer_model. Check your equations and avoid using global variables inside the function.
Note that this is a more than 2 year old thread, so a lot of the participants may no longer be listening. I just happened to notice because it showed up on my “latest activity” list.
Well there are lots of possible errors besides the initialization. We are testing the complete model here. Notice that the error you get from the test case is that some output variable does not even have the correct shape.
One important point is that you are not supposed to “hand copy” over any of your code from the Step by Step exercise: just call the functions. They are imported for you.