From 427a4b3ca994b417d7eed0acf1e92f2ac8543267 Mon Sep 17 00:00:00 2001 From: Mehdi Mirza Date: Thu, 25 Jun 2015 20:13:19 -0400 Subject: [PATCH] add inputs the classifer --- code/logistic_sgd.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/code/logistic_sgd.py b/code/logistic_sgd.py index 85236ecb..33e9b39d 100644 --- a/code/logistic_sgd.py +++ b/code/logistic_sgd.py @@ -44,7 +44,6 @@ import theano import theano.tensor as T -from theano.gof import graph class LogisticRegression(object): @@ -110,6 +109,9 @@ def __init__(self, input, n_in, n_out): # parameters of the model self.params = [self.W, self.b] + # keep track of model input + self.input = input + def negative_log_likelihood(self, y): """Return the mean of the negative log-likelihood of the prediction of this model under a given target distribution. @@ -447,17 +449,11 @@ def predict(): # load the saved model classifier = cPickle.load(open('best_model.pkl')) - y_pred = classifier.y_pred - - # find the input to theano graph - inputs = graph.inputs([y_pred]) - # select only x - inputs = [item for item in inputs if item.name == 'x'] # compile a predictor function predict_model = theano.function( - inputs=inputs, - outputs=y_pred) + inputs=[classifier.input], + outputs=classifier.y_pred) # We can test it on some examples from test test dataset='mnist.pkl.gz'