# Predicting from a pickled model

**URL:** https://discourse.pymc.io/t/predicting-from-a-pickled-model/3053
**Category:** Questions
**Created:** [April 3, 2019, 1:23pm UTC](https://discourse.pymc.io/t/predicting-from-a-pickled-model/3053 "2019-04-03T13:23:23Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![adamh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/adamh/32/1684_2.png) [@adamh](https://discourse.pymc.io/u/adamh)
#### Post date: [April 3, 2019, 1:23pm UTC](https://discourse.pymc.io/t/predicting-from-a-pickled-model/3053/1 "2019-04-03T13:23:23Z")

</div>

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](https://docs.pymc.io/notebooks/posterior_predictive.html) 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?

---

<div class="post-metadata">

### Author: ![aayushy](https://avatars.discourse-cdn.com/v4/letter/a/ecccb3/32.png) [@aayushy](https://discourse.pymc.io/u/aayushy)
#### Post date: [April 4, 2019, 1:47pm UTC](https://discourse.pymc.io/t/predicting-from-a-pickled-model/3053/2 "2019-04-04T13:47:19Z")

</div>

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

---

<div class="post-metadata">

### Author: ![adamh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/adamh/32/1684_2.png) [@adamh](https://discourse.pymc.io/u/adamh)
#### Post date: [April 7, 2019, 9:06am UTC](https://discourse.pymc.io/t/predicting-from-a-pickled-model/3053/3 "2019-04-07T09:06:55Z")

</div>

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