I am facing an error in compute_cost

logits = tf.transpose(logits)
labels = tf.transpose(labels)

cost = tf.reduce_mean(tf.keras.losses.categorical_crossentropy(y_true = labels,y_pred = logits))

Error Message: Shapes (2, 4) and (2, 6) are incompatible

[Removed solution code]

1 Like

As you are not applying the softmax function on the logits, you need to put “from_logits = True” in your categorical crossentropy function.

Hi
Thanks for the reply.
I have even tried that but it doesn’t work out.

[Removed solution code]


y_true = labels, y_pred = logits

apply this

1 Like

This has been solved on a different thread.

1 Like