i wrote

cost = tf.reduce_mean(tf.keras.losses.categorical_crossentropy(labels,logits,from_logits=True))

and got error

how can i solve it ?

i wrote

cost = tf.reduce_mean(tf.keras.losses.categorical_crossentropy(labels,logits,from_logits=True))

and got error

how can i solve it ?

Please pay attention to the parameter shapes when invoking categorical_crossentropy.

The expected shape of parameters is `[batch_size, num_classes]`

how can i specify size of labels?

The first step is to understand what they are as the variable is given to you. Then figure out what operation you need to do in order to get from the given form to the desired form. Hint: transpose is what you need.

i did transpose both and didn’t work as well

What error do you get with the latest version of the code? Just saying “it doesn’t work as well” does not really give us much to go on …