I’m stuck on Exercise 6 of the TensorFlow Introduction assignment, where I need to calculate the total cost given the model’s predictions and the true labels.

I am using the pescribed functions, tf.reduce_sum() and tf.keras.losses.categorical_crossentropy(from_logits=True), but it still gives the wrong answer.

I even asked ChatGPT (which is known for it’s ability to solve simple coding problems), and they said my code was correct, so this is beyond me.

The error message is this:
tf.Tensor(0.17102128, shape=(), dtype=float32) –snip–
AssertionError: Test does not match. Did you get the reduce sum of your loss functions?

That worked! The exercise criteria don’t really get across that you need to transpose the inputs well, so I’m not surprised I missed it. That also explains why ChatGPT couldn’t solve it.

Glad to hear that you solved it. They did mention the expected dimensions of the labels and logits in the instructions, although they did not actually use the word “transpose” anywhere. I explained the background on the other thread that I linked above.