Skip to content

Commit

Permalink
implement reset_tuning on Metropolis
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelosthege committed Feb 5, 2020
1 parent 8a808f1 commit fbc4951
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pymc3/step_methods/metropolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,25 @@ def __init__(self, vars=None, S=None, proposal_dist=None, scaling=1.,
self.any_discrete = self.discrete.any()
self.all_discrete = self.discrete.all()

# remember initial settings before tuning so they can be reset
self._untuned_settings = dict(
scaling=self.scaling,
steps_until_tune=tune_interval,
accepted=self.accepted
)

self.mode = mode

shared = pm.make_shared_replacements(vars, model)
self.delta_logp = delta_logp(model.logpt, vars, shared)
super().__init__(vars, shared)

def reset_tuning(self):
"""Resets the tuned sampler parameters to their initial values."""
for attr, initial_value in self._untuned_settings.items():
setattr(self, attr, initial_value)
return

def astep(self, q0):
if not self.steps_until_tune and self.tune:
# Tune scaling parameter
Expand Down

0 comments on commit fbc4951

Please sign in to comment.