I'm using tensorflow/keras to build an image classification model. The labels are provided as integers, & so I'm using tf.keras.losses.SparseCategoricalCrossEntropy
as documented at https://www.tensorflow.org/api_docs/python/tf/keras/losses/SparseCategoricalCrossentropy
The model has output shape (batch_size,1,1,n_classes)
.
What shape do the labels need to have?
It seems like the labels should have the shape (batch_size,1,1,n_classes)
.
However, from a few tests, it seems like (batch_size,)
works too.
Often models have output shape (batch_size,n_classes)
and when using SparseCategoricalCrossEntropy
the label shape is (batch_size,).