Course 2, Week 3, compute_total_loss(logits, labels):

It looks like you must have modified the shape of either the labels or the logits to be a 3D Tensor. Try adding these statements before the statement that “throws”

    print(f"logits.shape {logits.shape}")
    print(f"labels.shape {labels.shape}")

Note that I wrote the code to do the transposes first and then put the print statements after the transposes and before the loss call and here’s what I see when I run the test cell for compute_total_loss:

logits.shape (2, 6)
labels.shape (2, 6)
tf.Tensor(0.810287, shape=(), dtype=float32)
All test passed

A couple of other things to note:

  1. You’re not following the instructions correctly for the last step: they tell you to compute the sum, not the mean. Here’s a thread explaining why it is done that way.
  2. Note that the labels input that they use in the test case is new_y_train which was created earlier in the notebook by using your one_hot_matrix function. Maybe there is a problem with that function.