Lazaros Polymenakos
2015-09-09 00:52:38 UTC
Hello,
I am fairly new to THEANO. I am trying out the examples and adapting them
to run new experiments.
In the documentation, there is a piece of code for the Logistic Regression
example that is called predict()
and it is used to load a trained model and test on a set of data.
I append the modified code. The actual data loads and the sizes are correct.
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "logistic_reg.py", line 180, in predict
inputs=[classifier2.input],
AttributeError: 'LogisticRegression' object has no attribute 'input'
I would appreciate some insight on what could be wrong and how I could fix
it.
def predict():
"""
An example of how to load a trained model and use it
to predict labels.
"""
# load the saved model
classifier = cPickle.load(open('best_model.pkl'))
print classifier.b.get_value().shape
# compile a predictor function
predict_model = theano.function(
inputs=[classifier.input],
outputs=classifier.y_pred)
# We can test it on some examples from test test
# dataset='mnist.pkl.gz'
# datasets = load_data(dataset)
# test_set_x, test_set_y = datasets[2]
# test_set_x = test_set_x.get_value()
train_set_x = numpy.load('m_trainA.npy')
train_set_y = numpy.load('m_labels1.npy')
test_set_x = numpy.load('m_testA.npy')
test_set_y = numpy.load('m_labels2.npy')
predicted_values = predict_model(test_set_x[:10])
print ("Predicted values for the first 10 examples in test set:")
print predicted_values
Many thanks in advance
I am fairly new to THEANO. I am trying out the examples and adapting them
to run new experiments.
In the documentation, there is a piece of code for the Logistic Regression
example that is called predict()
and it is used to load a trained model and test on a set of data.
I append the modified code. The actual data loads and the sizes are correct.
I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "logistic_reg.py", line 180, in predict
inputs=[classifier2.input],
AttributeError: 'LogisticRegression' object has no attribute 'input'
I would appreciate some insight on what could be wrong and how I could fix
it.
def predict():
"""
An example of how to load a trained model and use it
to predict labels.
"""
# load the saved model
classifier = cPickle.load(open('best_model.pkl'))
print classifier.b.get_value().shape
# compile a predictor function
predict_model = theano.function(
inputs=[classifier.input],
outputs=classifier.y_pred)
# We can test it on some examples from test test
# dataset='mnist.pkl.gz'
# datasets = load_data(dataset)
# test_set_x, test_set_y = datasets[2]
# test_set_x = test_set_x.get_value()
train_set_x = numpy.load('m_trainA.npy')
train_set_y = numpy.load('m_labels1.npy')
test_set_x = numpy.load('m_testA.npy')
test_set_y = numpy.load('m_labels2.npy')
predicted_values = predict_model(test_set_x[:10])
print ("Predicted values for the first 10 examples in test set:")
print predicted_values
Many thanks in advance
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.