docs icon indicating copy to clipboard operation
docs copied to clipboard

Usability of Bayesian HMM Tutorial

Open TimKo90 opened this issue 4 years ago • 5 comments

Hi! First of all, thank you very much for this package and the detailed tutorial! I just started working with Turing.jl and noticed a few issues when going through the Bayesian HMM Tutorial. Some of them are addressed in #86 and will likely be solved anyway, but there is one thing not mentioned there.

When I copy & paste the code given from the tutorial and run it on my machine, the simulated trajectory doesn't converge to the "experimental" one as it does in the animation in the tutorial:

HMM-Tutorial

I'm aware of the stochasticity of the process and ran the code a couple of times, but never got close to the result given in the tutorial. Is there any additional code that I need to run to get a similarly performing fit? As a side note: I also noticed that in the tutorial, the model is run with only 100 samples, while 500 are shown in the animation...not sure if this might be related...

(Edit: just fixed a typo...)

TimKo90 avatar Mar 29 '21 20:03 TimKo90

Hi! Your questions remind me of https://github.com/TuringLang/Turing.jl/issues/1302 :slightly_smiling_face: Do the suggestions in https://github.com/TuringLang/Turing.jl/issues/1302#issuecomment-645390404 fix your issues?

devmotion avatar Mar 29 '21 20:03 devmotion

Thanks for the fast reply! The issue is basically the same as the one you mention, however, setting different seeds doesn't improve the result for me (the following is obtained with Random.seed!(12345678):

HMM-Tutorial

Do I just need to try more different seeds until one gives a good result? Compared to the code shown in the other issue, I only modified the following due to an error:

# Extract our m and s parameters from the chain.
m_set = c[:m].value.data
s_set = c[:s].value.data

to 

# Extract our m and s parameters from the chain.
m_set = Array(group(c, :m))
s_set = Array(group(c, :s))

TimKo90 avatar Mar 29 '21 21:03 TimKo90

Yes, one should use Array(group(...)) instead of .value.data. I assume the tutorial was written and executed with an old version of MCMCChains and never updated.

Which version of Julia and Turing did you use?

devmotion avatar Mar 29 '21 21:03 devmotion

I'm using Julia 1.5.3 and Turing v0.15.12.

TimKo90 avatar Mar 29 '21 21:03 TimKo90

@TimKo90 It should be fixed now: https://turinglang.org/docs/tutorials/04-hidden-markov-model/

shravanngoswamii avatar May 25 '24 04:05 shravanngoswamii