Last active
October 17, 2019 14:52
-
-
Save aymericdelab/4f08e728a92f19cb0371533db6fb0229 to your computer and use it in GitHub Desktop.
export your saved model from azure to local computer and evaluate its accuracy on the test set
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#imports | |
import json | |
import numpy as np | |
from tensorflow.contrib import predictor | |
## transfer the saved model from azure blob storage to your local computer | |
ds = ws.get_default_datastore() | |
ds.download(target_path='outputs', | |
prefix='founder-classifier/outputs/model', | |
show_progress=True) | |
## restore your tf.estimator model | |
saved_model_location='outputs/founder-classifier/outputs/model/1570442423' | |
loaded_model = predictor.from_saved_model(saved_model_location) | |
## load your test set | |
with open('./data/test.json', 'rb') as f: | |
test_data=json.load(f) | |
features=np.reshape(test_data['images'], (-1,28,28,1)) | |
## make predictions | |
predictions = loaded_model({'x': features})['classes'] | |
true_labels=test_data['labels'] | |
## compute the accuracy | |
count=0 | |
for i in range(len(predictions)): | |
if predictions[i]==true_labels[i]: | |
count+=1 | |
accuracy=count/len(predictions) | |
print('The accuracy on the test set is: ', accuracy) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment