Hello,
I’m a little stuck on Compute Cost part of the programming assignment. Here’s my one of code that I wrote:
cost = tf.reduce_mean(tf.keras.losses.categorical_crossentropy(tf.transpose(labels),tf.transpose(logits)))

I’m getting the error that says “AssertionError: Test does not match. Did you get the mean of your cost functions?”

My output is tf.Tensor(0.8071431, shape=(), dtype=float32)
The expected output is tf.Tensor(0.4051435, shape=(), dtype=float32).

What am I doing wrong with the code here? Any help/insight would be greatly appreciated. I’ve looked at similar posts and I’m still not understanding why I’m wrong.

That is the value that you get if you forget to tell the loss function that you are passing it “logits” instead of the outputs of the activation function. There is a from_logits parameter and the default value is False. That is not appropriate in our case here. They don’t really mention this in the instructions, so you have to read the documentation for the loss function and then think about it. They do give you that link. Also remember that when we wrote the forward propagation logic, they told us not to apply the activation function at the output layer.