Hello - first time poster. I did search the forum for a related issue but did not find any. I received an error message " ValueError: Shapes (10, 40) and (10, 10) are incompatible" after trying to train a CNN model (to predict images of faces). Here is how I got to this point:
# One Hot Encode
y_train = to_categorical(y_train)
y_test = to_categorical(y_test)
print(y_train.shape) -->(200,40)
print(y_test.shape) ---> (200,40)
-----------------------------------------------
#Reshape the image arrays so that they have 4 dimensions: (number of images, width of image, height
of image, number of channels
X_train = X_train.reshape(200, 64, 64, 1)
X_test = X_test.reshape(200, 64, 64, 1)
-----------------------------------------------
#Fit a convolutional neural network
model1=Sequential()
model1.add(Conv2D(16,kernel_size=(3,3),strides=1,activation='relu',
padding='same',input_shape=(64,64,1)))
model1.add(MaxPooling2D(pool_size=(2,2),strides=2))
model1.add(Flatten())
model1.add(Dense(10,activation='softmax'))
model1.summary()
-----------------------------------------------
# Train the model
model1.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model1.fit(X_train, y_train, epochs=20, batch_size=10,
validation_data=(X_test, y_test))
model1.evaluate(X_test, y_test, verbose=0)
-----------------------------------------------
OUTPUT: ValueError: Shapes (10, 40, 2) and (10, 10) are incompatibleThanks in advance,
Larz60+ write Oct-12-2021, 04:24 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
