Course2, Week3, Exercise 6

As per the instructions and the documentation, the equation for computing costs becomes,
tf.reduce_mean(tf.keras.losses.categorical_crossentropy(labels, logits))
labels being y_true and logits being y_pred. But I am getting an error for the mean calculation


With this error - AssertionError: Test does not match. Did you get the mean of your cost functions?

Hi @ashwinkashyap,

Read the instructions of the exercise 6 about the shape of the arguments passed to the categorical_crossentropy function, and how they differ from the arguments received by the compute_cost function as stated in the docstring.

Also you need to include an argument in the categorical_crossentropy function to indicate that you are sending the logits, check the documentation for how to do that.

Check this: DLS 2 week 3 exercise 6 compute_cost

Thank you very much for the suggestions and the reference to the other topic.
I was using reshape function which was causing the issue, but now I have used the right function required to change the shape of the arguments.

Thank you for your time and guidance.