Exercise 8 - nn_model wrong values for W1

hi
i have complete code below:

{moderator edit - solution code removed}

but i got error: Wrong values for W1

may i ask where the output W1 b1 W2 b2 comes from? As i only see print ("Cost after iteration %i: f" (i, cost)) in the function.

if i know where the W1 b1 W2 b2 print comes from, then i can think why it is error…

Hi, Lucy,

I think you are very close.
There is a python test program to check your implementation. (I suppose you see nn_model_test(nn_model) in a cell.) It checks dimensions and values of your outputs in different layers, and shows some messages if any of those are not expected ones.
In your case, please double-check your “for loop”. It will be iterations of “forward_propagation → compute_cost → back_propagation → update_parameters” after initialization of parameters.

sorry .
i didn’t see any " print" in “forward_propagation → compute_cost → back_propagation → update_parameters”

Hi, Lucy,

Let me clear a few things.

  • For your question about “print”, those are in a test program which is hidden from your notebook. Error messages, which you say “print”, came from those. If you correct the point in the 2nd bullet below, those will be disappeared.
  • The reason why you get messages about “W1,…” is, you did not update those correctly in your Python program (in “for loop”). Again, steps inside a “for loop” is;
  1. forward propagation (you implemented correctly)
  2. computing cost (to see differences between your output and expected output) (you implemented correctly)
  3. back propagation with calculating “gradient” by partial differentiations. (you implemented correctly)
  4. update parameters (weights, bias) → This includes updating W1, W2, b1, b2, …and so on. (you need to revisit your implementation)

You are very close. Hope this helps.

thanks so much i fix that now. wrongly use initial parameter than update parameter.
thanks again!