ValueError: You are passing a target array of shape (32, 1) while using as loss categorical_crossentropy. categorical_crossentropy expects targets to be binary matrices (1s and 0s) of shape (samples, classes). If your targets are integer classes, you can convert them to the expected format via:
from keras.utils import to_categorical
y_binary = to_categorical(y_int)
Alternatively, you can use the loss function sparse_categorical_crossentropy instead, which does expect integer targets.
That error indicates you have just 1 type of objects in your dataset. You must have 2 or more different object classes in your image dataset.
@OlafenwaMoses why is that the case? Why can't there be only one object class?
Or, to put it better: Is there any workaround on how to make it work with only one object class?
same question, lolz
@TranDinhKhang , for my usecase I ended up creating two classes. Say, if I wanted to detect apple, I also created a no-apple class. Hope this helps
Hello after adding another object, it still returns the error listed above. Any news on this error?
I have two objects and same error
@OlafenwaMoses why is that the case? Why can't there be only one object class?
Or, to put it better: Is there any workaround on how to make it work with only one object class?
It is a classification model, which requires at least 2 unique objects. However, for detecting and recognizing 1 object, you can use the latest feature detailed in the tutorial linked below.
https://medium.com/deepquestai/train-object-detection-ai-with-6-lines-of-code-6d087063f6ff
Most helpful comment
That error indicates you have just 1 type of objects in your dataset. You must have 2 or more different object classes in your image dataset.