Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to find the predicted class for a specific testing sample? #5910

Closed
mdshopon opened this issue Mar 21, 2017 · 5 comments
Closed

How to find the predicted class for a specific testing sample? #5910

mdshopon opened this issue Mar 21, 2017 · 5 comments

Comments

@mdshopon
Copy link

I have created a model in keras for classifying MNIST digits. Now I want to see the predicted classes for first 10 testing samples. How do I do that ?

@bstriner
Copy link
Contributor

I assume your outputs are a softmax over classes. If your input is (n, 1, 28, 28) or whatever, run model.predict(x), and you will get a numpy array shaped (n, 10). If you just want to see the most likely class for each sample, use np.argmax(y, axis=1) to convert the softmax outputs into an array of integers representing the most likely class for each sample.

Cheers

@mdshopon
Copy link
Author

I resolved the issue. Actually model.prect_classes() function does that for me. I didn't know that. Thanks anyway.

@DNXie
Copy link

DNXie commented Dec 11, 2017

@codeheadshopon There is no function named prect_classes
I got the error when I tried: AttributeError: 'Model' object has no attribute 'prect_classes'
Are you sure you typed it right?

@henriqueluzz
Copy link

@DNXie The function name is actually predict_classes()

@pcuevas-ch
Copy link

python throws me an error when I put model.predict_classes(). It says that it needs an argument for the function :(

TypeError: predict_classes() missing 1 required positional argument: 'x'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants