Assuming the labels are integers, they have the wrong shape for SparseCategoricalCrossentropy
. Check the docs.
Try converting your y
to one-hot encoded labels:
y = tf.keras.utils.to_categorical(y, num_classes=20)
and change your loss function to CategoricalCrossentropy
:
model.compile(optimizer=Nadam(lr=0.09), loss=tf.keras.losses.CategoricalCrossentropy(),
metrics=['accuracy', mean_squared_error, mean_absolute_error, mean_absolute_percentage_error])
and it should work.
CLICK HERE to find out more related problems solutions.