I just finished the Neural Networks course, and in the final assignment, I seem not be able to get a correct result for one code block. I still submitted the assignment for grading, but the grader output does not go past that incorrect result. I feel I should get above 90% or so, but I got 50% and hence the result “Failed”. The grader output does not show past the failed block. Any help?
Do you mean that the L layer model code fails the tests in the notebook? If so, then it should not be surprising you get 50%: there are only two graded functions in that assignment.
I hope that you did not “hand import” your code from the previous assignment. The initialization routine for the L layer case is different then the version they give you in the “imports” and that will cause the tests to fail.
Hi @paulinpaloalto Thank you for your message. I tried both initializations, directly using layers_dims and using ((n_x, n_h, n_y))
parameters = initialize_parameters_deep((n_x, n_h, n_y)).
Still my tests are failing: Cost after iteration 1: 0.6564026188409187
Cost after first iteration: 0.6950464961800915
Cost after iteration 1: 0.7239781229671559
Cost after iteration 1: 0.7239781229671559
Cost after iteration 1: 0.7239781229671559
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: 0.6372332154479152
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
and it says:
AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.
I followed everything in the assignment as I was supposed to. Any help is appreciated. Thanks!
Are you using the “deep” initialization for the two_layer_model
? If so, that will fail. They use a different and more sophisticated initialization algorithm in the “deep” case.
There is a separate initialization routine that you need to use for the 2 layer case, right?
If that’s not the mistake, then it’s time to look at your code. We can’t see it directly and we aren’t supposed to share code in a public way. I will send you a DM (private personal message) about how to do that.
Thank you, my apologies for the oversight. Yes, I am now able to get the tests passed (and thanks for reviewing the code in DM).
To close the loop on the public thread, the problem was using the “deep” version of the initialization for the 2 layer case. They give you two separate functions and you have to use the one that they specified in the instructions in order to pass the tests.
It’s a bit ironic, because the “deep” initialization provided here uses a more sophisticated algorithm that we will learn about in DLS Course 2 and it actually gives better results on the two layer case. But “better” doesn’t match the results the test case is expecting, so it fails.
They used the more sophisticated algorithm for the “deep” case because the dataset and the 4 layer architecture they chose does not converge well with the simplistic initialization they had us build in the “Step by Step” assignment. Stay tuned for DLS Course 2 and we’ll learn about several additional initialization algorithms that are frequently used. There’s just too much to cover in DLS C1 to get to that yet.