Hello, I’m new to pymc3 and am struggling with an error while trying out an example. I’ve read the other people’s posts who have had the same error but I’m still struggling to make sense of mine. Any help would be amazing. I’m using Jupyter -
X = np.array([10, 14, 12, 1200, 25, 120, 54, 32, 18, 23])
with pm.Model() as model:
mu = pm.Uniform(‘mu’, 0, 1000)
sigma = pm.Uniform(‘sigma’, 0, 1000)
likelihood = pm.Normal(‘likelihood’, mu, sigma**-2, observed=True, testval=X)
trace = pm.sample(1000)
Auto-assigning NUTS sampler…
Initializing NUTS using jitter+adapt_diag…
Sequential sampling (2 chains in 1 job)
NUTS: [sigma, mu]
Sampling chain 0, 0 divergences: 13%|█▎ | 202/1500 [00:05<00:34, 37.42it/s]
Thats where it gets stuck and I get the following error -
ValueError Traceback (most recent call last)
in
1 with model:
----> 2 trace = pm.sample(1000)
~/ml/my_env/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, **kwargs)
487 _log.info(“Sequential sampling ({} chains in 1 job)”.format(chains))
488 _print_step_hierarchy(step)
–> 489 trace = _sample_many(**sample_args)
490
491 discard = tune if discard_tuned_samples else 0
~/ml/my_env/lib/python3.7/site-packages/pymc3/sampling.py in _sample_many(draws, chain, chains, start, random_seed, step, **kwargs)
537 step=step,
538 random_seed=random_seed[i],
–> 539 **kwargs
540 )
541 if trace is None:
~/ml/my_env/lib/python3.7/site-packages/pymc3/sampling.py in _sample(chain, progressbar, random_seed, start, draws, step, trace, tune, model, **kwargs)
603 try:
604 strace = None
–> 605 for it, (strace, diverging) in enumerate(sampling):
606 if it >= skip_first:
607 trace = MultiTrace([strace])
~/ml/my_env/lib/python3.7/site-packages/tqdm/std.py in iter(self)
1106 fp_write=getattr(self.fp, ‘write’, sys.stderr.write))
1107
-> 1108 for obj in iterable:
1109 yield obj
1110 # Update and possibly print the progressbar.
~/ml/my_env/lib/python3.7/site-packages/pymc3/sampling.py in _iter_sample(draws, step, start, trace, chain, tune, model, random_seed)
698 step = stop_tuning(step)
699 if step.generates_stats:
–> 700 point, stats = step.step(point)
701 if strace.supports_sampler_stats:
702 strace.record(point, stats)
~/ml/my_env/lib/python3.7/site-packages/pymc3/step_methods/arraystep.py in step(self, point)
245
246 if self.generates_stats:
–> 247 apoint, stats = self.astep(array)
248 point = self._logp_dlogp_func.array_to_full_dict(apoint)
249 return point, stats
~/ml/my_env/lib/python3.7/site-packages/pymc3/step_methods/hmc/base_hmc.py in astep(self, q0)
128 (np.abs(check_test_point) >= 1e20) | np.isnan(check_test_point)
129 ]
–> 130 self.potential.raise_ok(self._logp_dlogp_func._ordering.vmap)
131 message_energy = (
132 "Bad initial energy, check any log probabilities that "
~/ml/my_env/lib/python3.7/site-packages/pymc3/step_methods/hmc/quadpotential.py in raise_ok(self, vmap)
229 errmsg.append(‘The derivative of RV {}
.ravel()[{}]’
230 ’ is zero.’.format(*name_slc[ii]))
–> 231 raise ValueError(’\n’.join(errmsg))
232
233 if np.any(~np.isfinite(self._stds)):
ValueError: Mass matrix contains zeros on the diagonal.
The derivative of RV sigma_interval__
.ravel()[0] is zero.
The derivative of RV mu_interval__
.ravel()[0] is zero.