# Get nan or inf from model.logp (model.test point) is an attestation of incorrectly configured model?

**URL:** <https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111>\
**Category:** Questions\
**Created:** [June 22, 2017, 9:17pm UTC](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111 "2017-06-22T21:17:53Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![marcio](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@marcio](https://discourse.pymc.io/u/marcio)\
**Post date:** [June 24, 2017, 12:22pm UTC](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111/21 "2017-06-24T12:22:53Z")

</div>

Oh, good! I’m almost jumping through the window, the sample took a day to finish. HAHAHAHAHA (desperate laugh). Thank you very much @junpenglao, I will wait for the @colcarroll’s teachings!

---

<div class="post-metadata">

**Author:** ![colcarroll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.pymc.io/colcarroll/32/9_2.png) [@colcarroll](https://discourse.pymc.io/u/colcarroll)\
**Post date:** [June 24, 2017, 12:46pm UTC](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111/22 "2017-06-24T12:46:09Z")

</div>

Haven’t tried this, but it should work (give it a shot with very few samples first!):

```auto
import cPickle as pickle # if python2
import pickle # if python3

...

trace = pm.sample(5e4, njobs=4, step=[pm.Metropolis(vars=[Y, Yp]), pm.NUTS()], tune=1000)

with open('trace.pkl', 'wb') as buff:
    pickle.dump(trace, buff)

```

You can then recover the trace with

```auto
with open('trace.pkl', 'rb') as buff:
    trace = pickle.load(buff)

```

This is great for local development on your computer. A few “gotchas” that probably won’t matter:

1. You cannot pickle in python2 and unpickle in python3
2. Do not unpickle a file from an untrusted source, as it can run arbitrary code

---

<div class="post-metadata">

**Author:** ![marcio](https://avatars.discourse-cdn.com/v4/letter/m/f19dbf/32.png) [@marcio](https://discourse.pymc.io/u/marcio)\
**Post date:** [June 24, 2017, 12:49pm UTC](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111/23 "2017-06-24T12:49:51Z")

</div>

Thank you very much @colcarroll !

[Previous page](https://discourse.pymc.io/t/get-nan-or-inf-from-model-logp-model-test-point-is-an-attestation-of-incorrectly-configured-model/111.md?page=1)
