MCPcopy Index your code
hub / github.com/lisa-lab/DeepLearningTutorials / predict

Function predict

code/logistic_sgd.py:449–471  ·  view source on GitHub ↗

An example of how to load a trained model and use it to predict labels.

()

Source from the content-addressed store, hash-verified

447
448
449def predict():
450 """
451 An example of how to load a trained model and use it
452 to predict labels.
453 """
454
455 # load the saved model
456 classifier = pickle.load(open('best_model.pkl'))
457
458 # compile a predictor function
459 predict_model = theano.function(
460 inputs=[classifier.input],
461 outputs=classifier.y_pred)
462
463 # We can test it on some examples from test test
464 dataset='mnist.pkl.gz'
465 datasets = load_data(dataset)
466 test_set_x, test_set_y = datasets[2]
467 test_set_x = test_set_x.get_value()
468
469 predicted_values = predict_model(test_set_x[:10])
470 print("Predicted values for the first 10 examples in test set:")
471 print(predicted_values)
472
473
474if __name__ == '__main__':

Callers

nothing calls this directly

Calls 2

loadMethod · 0.80
load_dataFunction · 0.70

Tested by

no test coverage detected