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]
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]
As you are not applying the softmax function on the logits, you need to put “from_logits = True” in your categorical crossentropy function.
y_true = labels, y_pred = logits
apply this
This has been solved on a different thread.