Eine Vorhersage in Keras erhalten

Ich habe erfolgreich ein einfaches Modell in Keras trainiert, um Bilder zu klassifizieren:

model = Sequential()

model.add(Convolution2D(32, 3, 3, border_mode='valid', input_shape=(img_channels, img_rows, img_cols),
                        activation='relu', name='conv1_1'))
model.add(Convolution2D(32, 3, 3, activation='relu', name='conv1_2'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

model.add(Convolution2D(64, 3, 3, border_mode='valid', activation='relu', name='conv2_1'))
model.add(Convolution2D(64, 3, 3, activation='relu', name='conv2_2'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))

model.add(Flatten())
model.add(Dense(512, activation='relu'))
model.add(Dropout(0.5))

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

model.compile(loss='categorical_crossentropy', optimizer=sgd, metrics=['accuracy'])

Ich kann die Bildklassen auch mit @ vorhersag

y_pred = model.predict_classes(img, 1, verbose=0)

Aber die Ausgabe vony_pred ist immer binär. Dies scheint auch bei der Verwendung von @ der Fall zu seipredict_proba undpredict. Meine Ausgaben sind in dieser Form

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

Dies funktioniert in Ordnung, aber ich hätte gerne eine prozentuale Wahrscheinlichkeit für jede Klassifizierung, zum Beispiel

[[ 0.8  0.1  0.1  0.4]]

Wie bekomme ich das in Keras?

Antworten auf die Frage(2)

Ihre Antwort auf die Frage