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

Chain 0 failed. #13

Open
vidigen opened this issue Sep 8, 2020 · 2 comments
Open

Chain 0 failed. #13

vidigen opened this issue Sep 8, 2020 · 2 comments

Comments

@vidigen
Copy link

vidigen commented Sep 8, 2020

Dear Eric,

thanks a lot for a great post HMM in pymc3 (https://ericmjl.github.io/essays-on-data-science/machine-learning/markov-models/). I am writing a thesis in associative learning and I would like to integrate part of your model into my simulations. The problem is that when I run the sampler for

n_states = 3
with pm.Model() as model:
p_transition = pm.Dirichlet(
"p_transition",
a=tt.ones((n_states, n_states)) * 4, # weakly informative prior
shape=(n_states, n_states))

# Solve for the equilibrium state
p_equilibrium = solve_equilibrium(n_states, p_transition)

obs_states = HMMStates(
    "states",
    p_transition=p_transition,
    p_equilibrium=p_equilibrium,
    n_states=n_states,
    observed=np.array(states).astype("float")
)

it gets stack saying "Chain 0 failed."

If I run prior checks I manage to get samples for the "p_transition" but for "states", I get the following error:
'HMMStates' object has no attribute 'p'
I guess the problems are related.

Those are the versions:
numpy == 1.19.1
theano == 1.0.4
pymc3 == 3.9.3

Thanks a lot in advance for your help.

Vincenzo

@ericmjl
Copy link
Owner

ericmjl commented Sep 8, 2020

Hi @vidigen! Thanks for chiming in. I should update the essay in there with a link to my Bayesian analysis recipes: https://github.com/ericmjl/bayesian-analysis-recipes/blob/master/docs/notebooks/markov-models.ipynb

That one should execute from top to bottom with no Python class definition issues.

There's some things that need improvement, btw, such as the log-likelihood calculation being marginalized over every possible state (something that isn't done in the code). I've been working on that with an intern at work, and we'll be releasing it sometime near the end of the year once he's done with his internship.

@vidigen
Copy link
Author

vidigen commented Sep 11, 2020

Thanks a lot, I will be looking forward to the updates!

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

No branches or pull requests

2 participants