I trained a model on Keras in CNN, it supposes to get the input of image with shape (-1,32,32,1)
after training, I tested the model by inputting new images to the model and get the prediction using model.predict_class and check if the prediction matches the desired label, but the model returns an array of 3 elements for example ([3 12 22]) why it doesn't return one class '
this is the preprocessing code of the image before the prediction
read_img = cv2.imread('test-images/' + file + '/' + img)
read_img = read_img.reshape( -1,32, 32, 1)
read_img = read_img.astype('float32')/255
maxind = model.predict_classes(read_img)
and this is the output of the prediction
[22 12 4]
the code used to build the model :
model = Sequential()
model.add(Conv2D(filters=32, kernel_size=2,padding='same',activation='relu',input_shape=(32,32,1)))
model.add(MaxPooling2D(pool_size=2))
model.add(Conv2D(filters=64, kernel_size=2, padding='same', activation='relu'))
model.add(MaxPooling2D(pool_size=2))
model.add(Flatten())
model.add(Dense(1024, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(24, activation='softmax'))
model.summary()
model inputs, outputs and image shape
model.inputs = [tf.Tensor 'conv2d_1_input:0' shape=(?, 32, 32, 1) dtype=float32]
model.outputs = [tf.Tensor 'dense_2/Softmax:0' shape=(?, 24) dtype=float32]
read_img.shape = (3, 32, 32, 1)
read_img? - Vivek Mehta