W4_A2_ Expected output is different but no errors found

I have got different results than the expected ones. Everything previous to this seems to be okay, how can I check what have I done wrong. Or why are the results different than expected. I got 74% accuracy rather than 80%. You can see that the expected costs output are also different

I think you don’t need an exact match as they said:

  • The cost should decrease on every iteration.

Have you passed the grader? If so, ignore this different result.

Are you sure you used the matching initialization function and that you didn’t hand import your own initialization function? The code they gave us for initialize_parameters_deep is more sophisticated than what they had us build in the W4 A1 Step by Step exercise.

Yes I used the correct code. I mean, I actually passed the grader with 100. But I would like to understand why I got a different result than the expected.

Are you sure you ran the cell that redefines layers_dims to be the 4 layer network? I’ll bet you just trained the 2 layer network again with the L layer logic. Try “Kernel → Restart and Clear Output” and then “Cell → Run All” and see if you then get the correct expected values. You get slightly better performance with the L layer logic and the same 2 layer network, because the “deep” init routine is more sophisticated than the two layer one.

Or just put a print statement in your code to actually print the value of layers_dims and see what it is when you run the training.

FWIW I just tried the experiment of running the L layer training with the layers_dims of the 2 layer network and I get exactly the results you show, including the cost values on the last few iterations.

So your code is correct (as the grader confirms), but the runtime state of your notebook was inconsistent.

You were right. I re-run all and it worked perfectly. Thank you so much