Course 1:Week 4 Programming Assignment 2 Error in two_layer_model

I am not able to pass two test cases. I am using the provided initialize_parameters(n_x,n_h,n_y) function for parameter init. Cannot figure out what is wrong. Any suggestions will be appreciated. Thank you.

This is slightly interesting output.
Observations are;

  • Looks like the first iteration seems to be OK.
  • Shapes and types for all weights seem to be OK.
  • A problem is 2nd iteration or later. In that case, parameters are not properly updated.
  • On the other hand, in the 2nd test, W2 and b2 are correct. But, W1 and b1 are not. In the last test, still b2 are correct.

From the above observations, of course, you may want to check the process to update.
Since there are some correct weights even in the 2nd iteration, one doubt is, do you set an appropriate activation function for back-propagation to update dA0, dW1, and db1 ? It is not “sigmoid”.

Thank you for your response!

I am using relu for dA0, dW1, db1
And then simply using update_parameters() function

Still confused what might go wrong…

Now, I understood whole reason… I was very close actually.
To get dA0, dW1 and db1, we need to pass dA1 and cache with “relu” activation.
It is not A1.

By the way, pasting code in here is not recommended. Please remove them, thank you.

Good luck !

Nobu.

That was so silly of me! Thank you for pointing that out. I will delete the code now. Thanks again :slight_smile: