Enrollments closing soon for Post Graduate Certificate Program in Applied Data Science & AI By IIT Roorkee | 3 Seats Left

  Apply Now

Project - How to Build a Neural Network for Image Classification with TensorFlow

8 / 8

Evaluating the Model Performance

Let us see how well our model has learnt from the train data, by testing it on the test data.

INSTRUCTIONS
  • Use model.evaluate on X_test, y_test to see the test data prediction accuracy:

    model.evaluate(X_test, y_test)
    
  • Let us predict and visualize the first 3 samples from the test data.

    y_pred = np.argmax(model.predict(X_test[:3]), 1)
    print(y_pred)
    print([class_names[index] for index in y_pred])
    
  • Visualize the predictions for the first 3 samples from the test data:

    plt.figure(figsize=(7, 3))
    
    for index, image in enumerate(X_test[:3]):
        plt.subplot(1, 3, index + 1)
        plt.imshow(image, cmap="binary")
        plt.axis('off')
        plt.title(class_names[y_pred[index]], fontsize=12)
    plt.subplots_adjust(wspace=0.2, hspace=0.5)
    
    plt.show()
    
Get Hint See Answer


Note - Having trouble with the assessment engine? Follow the steps listed here

Loading comments...