I am new to Keras and I am trying to make a model for classification, this is my model:
model = Sequential()
model.add(Dense(86, activation='sigmoid', input_dim=21))
model.add(Dense(50, activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='categorical_crossentropy', optimizer='nadam', metrics=['accuracy'])
but it keeps giving me this error:
ValueError: Error when checking target: expected dense_3 to have shape (None, 1) but got array with shape (17268, 2)
Now I know that I need to encode my labels using one hot encoding and flatten them, so I've done that too.
oht_y_train = np_utils.to_categorical(y_train, num_classes=3)
oht_y_train = np.ndarray.flatten(oht_y_train)
But I still get the same error.
NOTE: Before I flattened the labels I got the same error, just the shape was (5765, 3)
I have also printed the shape of the labels array, it gives me (17268,)