Skip iteration pymc3

If I run the pymc3 code such as:

modell = pm.Model()
func = IntegrateOpFUN(z_l,z_s) 
with modell:
    Omega_m = pm.Uniform('OMM',lower=0.1, upper=0.45)
    a = pm.Uniform('a', lower=1.1, upper=2.2)
    thetaMu = func(OMM,a)
    obs = pm.Normal('obs', mu=thetaMu, sd=D_tobserr, observed=D_tobs)
    start = pm.find_MAP()
    step = pm.Metropolis()
    db = pm.backends.Text('drive/My Drive/stronglensing_tsalli GPU')
    trace = pm.sample(25000, step, start=start, chains=1, trace=db)

and while it is running it will abort(for example when iteration= 6000 ) for some reason such as power outage .
Is it possible when I will run the program again
it will skip iteration from where it stop not from beginning? (in my case continue from iteration=6000).

I have never used the Text backend. in fact; it is flagged for deprecation, because did not see anybody using it.

To your questoin: you can take the last iteration (or the media of the last few hundred!!) as the start for the next try.
With ArviZ you can certainly make an InferenceData object from the concatenation of your two traces.

If you don’t have gradients on your model, you might still want to try out other samples, because Metropolis is literally the least efficient sampler we have.
One option could be DEMetropolisZ which can work really well if you start it from the typical set (e.g. the median of your first 6k samples, assuming they already converged).

2 Likes