1
print(model.predict(image))
print(model.predict_proba(image))
print(model.predict_classes(image))

Using the above different predict methods I always get predictions like

[[ 1. 0. 0. 0.]]

but I want the probabilities of each classes something like this

[[ 0.8 0.05 0.05 0.1]]

This is the model

model = Sequential([
    Conv2D(32, (3, 3), input_shape=input_shape, padding='same',activation='relu'),
    Conv2D(32, (3, 3), activation='relu', padding='same'),
    MaxPooling2D(pool_size=(2, 2), strides=(2, 2)),
    Conv2D(64, (3, 3), activation='relu', padding='same', ),
    Conv2D(64, (3, 3), activation='relu', padding='same', ),
    MaxPooling2D(pool_size=(2, 2), strides=(2, 2)),
    Conv2D(128, (3, 3), activation='relu', padding='same', ),
    Conv2D(128, (3, 3), activation='relu', padding='same', ),
    MaxPooling2D(pool_size=(2, 2), strides=(2, 2)),
    Conv2D(256, (3, 3), activation='relu', padding='same', ),
    Conv2D(256, (3, 3), activation='relu', padding='same', ),
    MaxPooling2D(pool_size=(2, 2), strides=(2, 2)),
    Conv2D(512, (3, 3), activation='relu', padding='same', ),
    Conv2D(512, (3, 3), activation='relu', padding='same', ),
    MaxPooling2D(pool_size=(2, 2), strides=(2, 2)),
    Flatten(),
    Dense(512, activation='relu'),
    Dense(num_classes, activation='softmax')
])

Compiled as

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

Not sure if this has any effects, but this is how I loaded the data

train_datagen = ImageDataGenerator( rescale=1./255, )

train_generator = train_datagen.flow_from_directory(folder+'apex/train', target_size=(200, 400), batch_size=batch_size, class_mode='categorical')

Pokkang
  • 11
  • 2
  • 1
    How many instances do you have in training set? How many output classes are there? – JahKnows May 18 '18 at 09:28
  • @JahKnows there are 8 output classes, as for training instances : 'acuminate' 1382, 'apiculate' 238, 'obtuse' 260, 'acute' 1216, 'mucronate' 240, 'round' 248, 'bilobed' 124, 'emarginate' 106 – Pokkang May 18 '18 at 11:21

0 Answers0