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

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

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

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
1 Like