exoplanet-dev / exoplanet

Fast & scalable MCMC for all your exoplanet needs!
https://docs.exoplanet.codes
MIT License
206 stars 52 forks source link

Sampling problems #107

Closed kevinkhu closed 4 years ago

kevinkhu commented 4 years ago

I've been adapting the "putting it all together" case study to work without RV data, and I ran into an issue at the sampling step, so I re-ran the tutorial without any modifications and ran into the same issue:

np.random.seed(203771098)
with model:
    trace = xo.sample(
        tune=3500,
        draws=3000,
        start=map_soln,
        chains=4,
        initial_accept=0.8,
        target_accept=0.95,
    )

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-16-ec9eb79dc12c> in <module>
      7         chains=4,
      8         initial_accept=0.8,
----> 9         target_accept=0.95,
     10     )

~/anaconda3/lib/python3.7/site-packages/exoplanet/quadpotential.py in sample(draws, tune, model, warmup_window, adapt_window, cooldown_window, target_accept, gamma, k, t0, step_kwargs, **kwargs)
    327 
    328     kwargs["step"] = step
--> 329     return pm.sample(draws=draws, tune=tune, model=model, **kwargs)
    330 
    331 

~/anaconda3/lib/python3.7/site-packages/pymc3/sampling.py in sample(draws, step, init, n_init, start, trace, chain_idx, chains, cores, tune, progressbar, model, random_seed, discard_tuned_samples, compute_convergence_checks, callback, return_inferencedata, idata_kwargs, **kwargs)
    481             step = assign_step_methods(model, step, step_kwargs=kwargs)
    482     else:
--> 483         step = assign_step_methods(model, step, step_kwargs=kwargs)
    484 
    485     if isinstance(step, list):

~/anaconda3/lib/python3.7/site-packages/pymc3/sampling.py in assign_step_methods(model, step, methods, step_kwargs)
    208             selected_steps[selected].append(var)
    209 
--> 210     return instantiate_steppers(model, steps, selected_steps, step_kwargs)
    211 
    212 

~/anaconda3/lib/python3.7/site-packages/pymc3/sampling.py in instantiate_steppers(model, steps, selected_steps, step_kwargs)
    134     unused_args = set(step_kwargs).difference(used_keys)
    135     if unused_args:
--> 136         raise ValueError("Unused step method arguments: %s" % unused_args)
    137 
    138     if len(steps) == 1:

ValueError: Unused step method arguments: {'initial_accept'}

pip, exoplanet 0.3.2, PyMC3 3.9.2, Python 3.7.7, Ubuntu 20.04

dfm commented 4 years ago

Thanks for reporting! I didn't do much testing with PyMC3 v3.9 and it seems to have introduced some regressions in the sample function (I rely on undocumented features 😈). I'll take a look at this early next week. Can you try to remember to ping me if you don't hear anything by Wednesday morning?

In the meantime you should be able to use the old version (note xo -> pm):

np.random.seed(203771098)
with model:
    trace = pm.sample(
        tune=3500,
        draws=3000,
        start=map_soln,
        chains=4,
        step=xo.get_dense_nuts_step(target_accept=0.95),
    )
dfm commented 4 years ago

Alas I didn't get to this yet. I'm going on holiday for the next few days, but I'll have a go early next week!

kevinkhu commented 4 years ago

No worries, the old version hack works for now!

dfm commented 4 years ago

I finally (only a month late) released a new version of exoplanet that is compatible with PyMC > 3.9. I'm working on pulling out (and improving) some of this functionality here: https://github.com/exoplanet-dev/pymc3-ext