ValueError: Shape Mismatch: The Shape Of Labels (received (15,)) Should Equal The Shape Of Logits Except For The Last Dimension (received (5, 3))
I am getting this error when trying to fit a model: ValueError: Shape mismatch: The shape of labels (received (15,)) should equal the shape of logits except for the last dimensi
Solution 1:
The difference between sparse_categorical_crossentropy
and categorical_crossentropy
is whether your targets are one-hot encoded.
The shape of label batch is (5,3)
, which means it has been one-hot encoded. So you should use categorical_crossentropy
loss function.
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
Solution 2:
I think it is related to your loss function just try to use "categorical_crossentropy" instead of "sparse..."
Post a Comment for "ValueError: Shape Mismatch: The Shape Of Labels (received (15,)) Should Equal The Shape Of Logits Except For The Last Dimension (received (5, 3))"