pyro: Value sampled is not in distribution's support for baseball example

The partially_pooled model in baseball.py seems to sporadically fail with the exception that the value argument is not within the support for the Pareto distribution. cc. @fehiepsi

Taking a look at this, but I am temporarily removing this from test_examples.py to unblock the build.

Traceback (most recent call last):
  File "/home/travis/build/uber/pyro/pyro/poutine/trace_struct.py", line 128, in log_prob_sum
    log_p = site["log_prob_sum"]
KeyError: 'log_prob_sum'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/home/travis/build/uber/pyro/examples/baseball.py", line 309, in <module>
    main(args)
  File "/home/travis/build/uber/pyro/examples/baseball.py", line 272, in main
    .run(partially_pooled, at_bats, hits)
  File "/home/travis/build/uber/pyro/pyro/infer/abstract_infer.py", line 84, in run
    for tr, logit in self._traces(*args, **kwargs):
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/mcmc.py", line 51, in _traces
    for trace in self._gen_samples(self.num_samples, trace):
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/mcmc.py", line 35, in _gen_samples
    trace = self.kernel.sample(trace)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 276, in sample
    direction, tree_depth, energy_current)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 159, in _build_tree
    direction, tree_depth-1, energy_current)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 178, in _build_tree
    direction, tree_depth-1, energy_current)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 178, in _build_tree
    direction, tree_depth-1, energy_current)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 155, in _build_tree
    return self._build_basetree(z, r, z_grads, log_slice, direction, energy_current)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/nuts.py", line 130, in _build_basetree
    z, r, self._potential_energy, self._inverse_mass_matrix, step_size, z_grads=z_grads)
  File "/home/travis/build/uber/pyro/pyro/ops/integrator.py", line 68, in single_step_velocity_verlet
    z_grads, potential_energy = _potential_grad(potential_fn, z_next)
  File "/home/travis/build/uber/pyro/pyro/ops/integrator.py", line 79, in _potential_grad
    potential_energy = potential_fn(z)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/hmc.py", line 170, in _potential_energy
    potential_energy = -self._compute_trace_log_prob(trace)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/hmc.py", line 154, in _compute_trace_log_prob
    return self._trace_prob_evaluator.log_prob(model_trace)
  File "/home/travis/build/uber/pyro/pyro/infer/mcmc/util.py", line 132, in log_prob
    return model_trace.log_prob_sum()
  File "/home/travis/build/uber/pyro/pyro/poutine/trace_struct.py", line 130, in log_prob_sum
    log_p = site["fn"].log_prob(site["value"], *site["args"], **site["kwargs"])
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/torch/distributions/transformed_distribution.py", line 86, in log_prob
    log_prob += _sum_rightmost(self.base_dist.log_prob(y),
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/torch/distributions/exponential.py", line 51, in log_prob
    self._validate_sample(value)
  File "/home/travis/virtualenv/python3.5.6/lib/python3.5/site-packages/torch/distributions/distribution.py", line 221, in _validate_sample
    raise ValueError('The value argument must be within the support')

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

When adapting, I think that with small step_size, we will get better mass_matrix. When mass_matrix is ready, step_size will automatically increase I guess (at least during the end_buffer).

Yeah, that’s a good observation! I think I was only seeing these issues without mass matrix adaptation, but you are right that the mass matrix will likely help alleviate many of these issues by adapting the step size per parameter, so we will probably not have to run many steps before getting a u turn.

Yes, I think we somehow should let users change hidden parameters. About small step_size, from what I learned from Stan reference and pymc3 notebook: smaller step_size the better. They even encourage increasing acceptance probability to a value ~1. When adapting, I think that with small step_size, we will get better mass_matrix. When mass_matrix is ready, step_size will automatically increase I guess (at least during the end_buffer).

To me, mass_matrix plays the role of setting different step_size for each parameter (with small variance params, we don’t want to move far from a position; with large variance params, we don’t want to stay around one position). So if we are able to learn it during warmup phase, the sampling will be good.

we should modify _is_turning method too

Oh good catch! We would need to multiply by the inverse of the mass matrix, I guess.

I am trying to debug why we are getting non deterministic output when we run HMC / NUTS with a fixed seed. I think that needs to be fixed first, even before we go on to debug why the model fails on certain initializations.