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 ?
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
I resolved the issue. Actually model.prect_classes() function does that for me. I didn't know that. Thanks anyway.
@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?
@DNXie The function name is actually predict_classes()
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'
Most helpful comment
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, usenp.argmax(y, axis=1)to convert the softmax outputs into an array of integers representing the most likely class for each sample.Cheers