I am trying to save the model obtained while training the Perceptron multilayer network built using Theano at http://deeplearning.net/tutorial/code/mlp.py using the code shown in the Logistic regression at http://deeplearning.net/tutorial /code/logistic_sgd.py in particular
with open('best_model.pkl', 'w') as f:
cPickle.dump(classifier, f)
but i get
... loading data ... building a model ... school age 1, minibus 74/74, verification error 38.333333% epoch 1, minibatch 74/74, test error on the best model 41.666667% Traceback (last last call): File "mlp .py ", line 423, in test_mlp () File" mlp.py ", line 406, in test_mlp cPickle.dump (classifier, f, protocol = cPickle.HIGHEST_PROTOCOL) cPickle.PicklingError: Unable to pickle: the search attribute is built-in . Failed method
Since I also encountered this problem with the convolution network, my question is: is there a general way to store the model in Theano so that it can be reused for forecasting?
EDIT
As suggested in the comments I'm using now
cPickle.dump((classifier.hiddenLayer.params,classifier.logRegressionLayer.params), f)
to save and
classifier.hiddenLayer.W = cPickle.load(open('best_model_mlp.pkl'))[0][0]
() ,
x = T.matrix('x')
classifier = MLP(
rng=rng,
input=x,
n_in = 28*28,
n_hidden= 500,
n_out=10
)
predict_model = theano.function(
inputs=[classifier.input],
outputs=classifier.logRegressionLayer.y_pred,
)
[0] , .
?