Menu
Apache MXNet on AWS
Developer Guide

Step 5: Test the Model

The testing code uses the validation data from the model that you trained to perform predictions.

Copy and paste the following code into the notebook and run it.

Copy
''' Perform predictions on validation data with 10000 images. ''' predictions = model.predict(eval_data=val_iter) # Let us print an example prediction. # Let us see what is the 8th image in our validation data is. # And check if our model predicts it correctly. plt.imshow(val_img[7], cmap='Greys_r') plt.axis('off') plt.show() prob = predictions[7].asnumpy() print("Classified as %d with probability %f" %(prob.argmax(), max(prob)))

The code prints the input image and the digit that the model predicts.

Next Step

Step 6: Clean Up