Week3 - got an error in compute_cost function

I got an error in the compute_cost_test function but I don’t know how to fix the error in compute cost code.

I got the latest version of the notebook and these is the instructions:

So I write the code following the instruction, and I try to use transpose to fix the shape error.

{Moderator’s Edit: Solution Code Removed}

But still I have this error and I don’t know what is the problem…

Anyone know how to solve this problem?

Hey @zainabmel,
Since you are using linear activation function in the last layer of the neural network and you want the output to be computed using a softmax layer, you are supposed to set from_logits = True while using the tf.keras.losses.categorical_crossentropy. Let me know if this helps.

P.S. - Posting code publicly is strictly against the community guidelines. Please refrain from doing so in the future.

Cheers,
Elemento

It helps! thank you so much :smile: