0
votes

I have build a CNN model for image classification. I want to pick five images that are correctly classified by the network and have the maximum softmax scores(for each class).

I have tried to check the model.evaluate(X_test,y_test) but it gives the overall softmax score of model.

model = Sequential()
model.add(Conv2D(96, (7, 7),  kernel_initializer='he_uniform', padding='same',strides=2, input_shape=(32, 32, 3)))
model.add(Activation("relu"))
model.add(Conv2D(64, (5, 5), kernel_initializer='he_uniform', padding='same',strides=2))
model.add(Activation("relu"))

model.add(Conv2D(128, (3, 3), kernel_initializer='he_uniform', padding='same',strides=2))
model.add(Activation("relu"))

model.add(MaxPooling2D(pool_size=(3, 3),padding='same',strides=3))

model.add(Flatten())

model.add(Dense(128))
model.add(Activation("relu"))

model.add(Dense(10, activation='softmax'))

compile model

opt = SGD(lr=0.0001, momentum=0.9)
model.compile(optimizer=opt, loss='categorical_crossentropy', metrics['accuracy'])

I want to see the softmax scores of correctly classified images.

1
If you have the overall softmax score and ground truth label, you can manually select the softmax scores of correctly classified ones. Does it make sense to you? - zihaozhihao
@zihaozhihao I have the overall sore of model, how can I get a score for single image - johntommond
You can get the output of last layer. Check this one github.com/keras-team/keras/issues/2495 - zihaozhihao

1 Answers

0
votes

For this you have to use model.predict, not model.evaluate:

model.predict(X_test)