I'm trying out a simple model in pymc3, but it is throwing the following error when I try to use the find_MAP
method.:
ValueError: Optimization error: max, logp or dlogp at max have non-finite values. Some values may be outside of distribution support. max: {'theta_stickbreaking': array([ 1.90465421e-09, 0.00000000e+00])} logp: array(-inf) dlogp: array([ -1.14279242e-09, 0.00000000e+00])Check that 1) you don't have hierarchical parameters, these will lead to points with infinite density. 2) your distribution logp's are properly specified. Specific issues:
Very similar code works using the Beta and Binomial distributions instead of the Dirichlet and Multinomial distributions, but the following code fails:
from pymc3 import Model
from pymc3 import Metropolis
from pymc3 import Multinomial, Dirichlet
from pymc3 import sample, find_MAP
from pymc3 import traceplot
from scipy import optimize
import numpy as np
y_obs = [200, 400, 500]
k = 3
a= np.array([1, 1, 1])
with Model() as multinomial_inference:
n = 1000
theta = Dirichlet('theta', a, shape=k)
y = Multinomial('y', n, theta, observed=y_obs)
with multinomial_inference:
start = find_MAP()
step = Metropolis([theta])
trace = sample(10000, step, start)
How can I tune the model inference settings so that it doesn't blow up?
I think the issue is with your chosen values of y_obs
and n
. The sum of the observed values of y
should sum to n
.