I am trying to learn and understand how to implement multiclass classification using ANN. In my case, I have 16 classes(0-15), and my label dataset contains one column with the label values. So I know that the output layer should have the same number of neurons as the classes. When I created the output layer with 16 neurons, I got the following error message:
Shapes (32, 1) and (32, 16) are incompatible
I followed the solutions from similar questions:
y_train= tf.one_hot(y_train, 16)
and I got the following error:
ValueError: Shapes (32, 1, 16) and (32, 16) are incompatible
I understand that the problem is with the shape of my labels, but I have no idea how to fix it.
I appreciate any help you can provide.
CodePudding user response:
The solution was to use the following:
from tensorflow.keras.utils import to_categorical
y_cat_test = to_categorical(y_test,16)