Predicting from a pickled model

I’ve trained a model and I’m interested in using it for prediction on held-out data, on a different machine (without re-training). During training I made sure the training data is in a shared tensor. I’ve pickled the model, the trace and the shared tensor (necessary for pm.sample_posterior_predictive).

In a different session, I’ve pickle-loaded them, and changed the values of the shared tensor (following this tutorial). However, running pm.sample_posterior_predictive returns predictions for the original training data, as if the values of the shared tensor did not change.

When I’m doing shared_tensor.set_value(...) in the training session (on the same machine, with the same running python kernel), it does work; maybe the theano graph isn’t propely pickled with the model? Any way around this?

Have you tried pickling the theano shared variable with your model and trace?

Yes, I’ve pickled the model, the trace and the shared tensor…