An error of exercise 6 week 3 course 2

Improving Deep Neural Networks: Hyperparameter Tuning, Regularization and Optimization

week 3
exercise 6

I used "
loss=tf.keras.losses.categorical_crossentropy(tf.transpose(labels), tf.transpose(logits),from_logits=True)
cost = tf.reduce_mean(loss) "

I got an error. Shapes (2, 4) and (2, 6) are incompatible

How to fix the problem?

Thank you.

The number of classes here should be 6 in that test case. So the way you fix that problem is to figure out where the 4 came from, right? Are you sure you didn’t hard-wire 4 as the output shape in the one_hot routine?