Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG integrator keyword #3581

Closed
lorentzenchr opened this issue Aug 7, 2019 · 3 comments · Fixed by #3589
Closed

BUG integrator keyword #3581

lorentzenchr opened this issue Aug 7, 2019 · 3 comments · Fixed by #3589

Comments

@lorentzenchr
Copy link

Description of your problem

Since version 3.7, 'integrator' is not anymore accepted as a kwarg to sample. This might have to do with the deprication of nuts_kwargs and step_kwargs in v3.7.

Please provide a minimal, self-contained, and reproducible example.

with pm.Model() as model:
    mu = pm.Normal('mu', mu=0, sigma=1)
    obs = pm.Normal('obs', mu=mu, sigma=1, observed=np.random.randn(100))
    kwargs = {'integrator':'two-stage'}
    trace = pm.sample(1000, tune=500, **kwargs)

Please provide the full traceback.

Auto-assigning NUTS sampler...
Initializing NUTS using jitter+adapt_diag...
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-3-48064cbbd5a7> in <module>
      3     obs = pm.Normal('obs', mu=mu, sigma=1, observed=np.random.randn(100))
      4     kwargs = {'integrator':'two-stage'}
----> 5     trace = pm.sample(1000, tune=500, **kwargs) 

/python3.6/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, **kwargs)
    394                 start_, step = init_nuts(init=init, chains=chains, n_init=n_init,
    395                                          model=model, random_seed=random_seed,
--> 396                                          progressbar=progressbar, **kwargs)
    397                 if start is None:
    398                     start = start_

/python3.6/site-packages/pymc3/sampling.py in init_nuts(init, chains, n_init, model, random_seed, progressbar, **kwargs)
   1513             'Unknown initializer: {}.'.format(init))
   1514
-> 1515     step = pm.NUTS(potential=potential, model=model, **kwargs)
   1516
   1517     return start, step

/python3.6/site-packages/pymc3/step_methods/hmc/nuts.py in __init__(self, vars, max_treedepth, early_max_treedepth, **kwargs)
    150         `pm.sample` to the desired number of tuning steps.
    151         
--> 152         super().__init__(vars, **kwargs)
    153
    154         self.max_treedepth = max_treedepth
 
/python3.6/site-packages/pymc3/step_methods/hmc/base_hmc.py in __init__(self, vars, scaling, step_scale, is_cov, model, blocked, potential, dtype, Emax, target_accept, gamma, k, t0, adapt_step_size, step_rand, **theano_kwargs)
     70         vars = inputvars(vars)
     71
---> 72         super().__init__(vars, blocked=blocked, model=model, dtype=dtype, **theano_kwargs)
     73
     74         self.adapt_step_size = adapt_step_size
 
/python3.6/site-packages/pymc3/step_methods/arraystep.py in __init__(self, vars, model, blocked, dtype, **theano_kwargs)
    226
    227         func = model.logp_dlogp_function(
--> 228             vars, dtype=dtype, **theano_kwargs)
    229
    230         # handle edge case discovered in #2948

/python3.6/site-packages/pymc3/model.py in logp_dlogp_function(self, grad_vars, **kwargs)
    721         varnames = [var.name for var in grad_vars]
    722         extra_vars = [var for var in self.free_RVs if var.name not in varnames]
--> 723         return ValueGradFunction(self.logpt, grad_vars, extra_vars, **kwargs)
    724
    725     @property
 
/python3.6/site-packages/pymc3/model.py in __init__(self, cost, grad_vars, extra_vars, dtype, casting, **kwargs)
    460
    461         self._theano_function = theano.function(
--> 462             inputs, [self._cost_joined, grad], givens=givens, **kwargs)
    463
    464     def set_extra_values(self, extra_vars):
 
TypeError: function() got an unexpected keyword argument 'integrator'

Versions and main components

  • PyMC3 Version: 3.7
  • Theano Version: 1.0.4
  • Python Version: 3.6.8
  • Operating system: RHEL 7.6
  • How did you install PyMC3: pip
@fonnesbeck
Copy link
Member

Yes, this also fails when passing a nuts_kwargs that is deprecated, but should still work.

@ColCarroll
Copy link
Member

@lorentzenchr I think I just pushed a fix -- is it right that it was just the leftover documentation, or was there something else that could help others avoid this problem?

@lorentzenchr
Copy link
Author

@ColCarroll Thanks for addressing this issue.
Some time ago, I had a computational challenging analysis and I think I had found some hint on using integrator at https://discourse.pymc.io/, but I don't find that post anymore.
On the other hand, I can't find any note on dropping integrator in https://github.com/pymc-devs/pymc3/blob/master/RELEASE-NOTES.md neither 😏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants