#!/usr/bin/env python3 from keras.models import load_model import numpy as np from train import load_data if __name__ == '__main__': # Load trained keras model model = load_model('model.hd5') # Load test data images, labels = load_data('test_images.bin', 'test_labels.bin') # Predict written numbers in images labels_predicted = model.predict(images) # Decode the one-hot vectors to labels labels_decoded = np.argmax(labels_predicted, axis=1) # Calculate accuracy of prediction num_correct = np.sum(labels_decoded == labels) print('Accuracy on test dataset: {}'.format(float(num_correct)/len(labels)))