C2_W3_Ex- Train the model


Although I passed all exercises, when trying to Train the Model I get this error:

Could you help me, since I would like to try the model out?


Have you restarted the kernel and run all cells?

Hi @jonaslalin

Yes I did but the error remains the same.
My version of compute_cost has 7 lines instead of one. I wonder if this makes any difference although the “All tests passed”. In fact I am puzzled on how all this can be done in only one line.

Thanks for your attention

Send me you notebook as a private message and I will have a look

You are using numpy methods which is why you have this problem. You see in the comments how it is supposed to be done:

cost = tf.keras.lossses.categorical_crossentropy(labels.T, logits.T)

1 Like

Interesting! Thanks, Jonas, for figuring this out. Now that you mention it, I also saw a very similar case where someone had used the numpy version of transpose here. Inserting a non-TF node in the compute graph has the side effect that the automatic gradient computations that TF does cannot propagate across that point in the graph, so you end up not getting any gradients.

1 Like