Yahya Uddin
Yahya Uddin

Reputation: 28951

Using Keras/ Neural Networks for categorical data

In the CNN example for the minst dataset for Keras they tell you how to make a good CNN network to recognise hand written digits. The issue is that it doesn't tell you how to predict new digits.

For example give an image, if I do this:

model.predict(image)

instead of telling me what digits it think it is, it instead gives me a list of 10 numbers (presumably probabilities)

Upvotes: 2

Views: 1073

Answers (1)

Serj Zaharchenko
Serj Zaharchenko

Reputation: 2721

You can use numpy's argmax to find out class that has maximum probability

import numpy as np
probabilities = model.predict(image)
classes = np.argmax(probabilities, axis=-1)

Upvotes: 2

Related Questions