C2W3 - TF Programming Assignment

I get an error saying that my output doesn’t match the expected output for the compute_total_loss function. I am pretty sure I am doing everything correctly, I took the reduced sum and set from_logits to True. Can someone explain why I am getting the wrong output?

total_loss = tf.reduce_sum(tf.keras.losses.categorical_crossentropy(labels, logits, from_logits=True))

The instructions include this statement:

That’s a broad hint that a transposition or two may be needed.

1 Like

As tf.keras.metrics.categorical_crossentropy() accept true_y then pred_y.
make sure you pass first true_label (only have 0 or 1 value) then predicted values, other wise it will do wrong calculations.

and

both true_y and pred_y should have dimension (# of examples, # of classes )
in next cell both arguments of target ‘target(pred, tf.transpose(minibatch))’ have shape (# of classes, # of example) ,
hear # of classes is 6 and # of example is 2
and ‘target’ is ‘compute_total_loss’