Closed jiweiqi closed 2 years ago
@ChrisRackauckas I am not sure how to submit bugfix solutions. This is not a big deal but annoying to spend a while to figure out the problem.
It seems that disabling sorting is implemented at the MCMCChains.jl
side, but not yet in Turing.jl
. See https://github.com/TuringLang/MCMCChains.jl/pull/160 for details.
The variables are not sorted in recent Turing versions by default: https://github.com/TuringLang/Turing.jl/pull/1627
Which Turing version did you use?
The variables are not sorted in recent Turing versions by default: #1627
Which Turing version did you use?
Mine is v0.18.0
.
Any my full st
:
Status `~/.julia/environments/v1.5/Project.toml`
[d1b5debe] Arrhenius v0.1.1 `https://github.com/DENG-MIT/Arrhenius.jl#main`
[c52e3926] Atom v0.12.30
[fbb218c0] BSON v0.3.3
[aae01518] BandedMatrices v0.16.10
[052768ef] CUDA v2.4.3
[39dd38d3] Dierckx v0.5.1
[aae7a2af] DiffEqFlux v1.39.0
[41bf760c] DiffEqSensitivity v6.49.1
[0c46a032] DifferentialEquations v6.18.0
[31c24e10] Distributions v0.25.14
[587475ba] Flux v0.12.1
[f6369f11] ForwardDiff v0.10.18
[f67ccb44] HDF5 v0.15.6
[a98d9a8b] Interpolations v0.13.2
[42fd0dbc] IterativeSolvers v0.9.1
[e5e0dc1b] Juno v0.8.4
[a5e1c1ea] LatinHypercubeSampling v1.8.0
[c7f686f2] MCMCChains v5.0.1
[cc2ba9b6] MLDataUtils v0.5.4
[429524aa] Optim v1.4.0
[1dea7af3] OrdinaryDiffEq v5.60.1
[91a5bcdd] Plots v1.19.4
[49802e3a] ProgressBars v1.3.0
[d330b81b] PyPlot v2.9.0
[47a9eef4] SparseDiffTools v1.13.2
[684fba80] SparsityDetection v0.3.4
[f3b207a7] StatsPlots v0.14.28
[c3572dad] Sundials v4.5.3
[fce5fe82] Turing v0.18.0
[fdbf4ff8] XLSX v0.7.6
[ddb6d928] YAML v0.4.7
[e88e6eb3] Zygote v0.6.12
[8bb1440f] DelimitedFiles
[37e2e46d] LinearAlgebra
[de0858da] Printf
[9a3f8284] Random
[10745b16] Statistics
Yeah but in the original comment above you just copied the output from the webpage (https://turing.ml/dev/tutorials/10-bayesian-differential-equations/), didn't you? And there a quite old version of Turing was used (0.15.18 apparently) that still sorted the variables. With recent versions of Turing the variables are not sorted anymore so you will get the order of variables in the chain that you expected.
I'm still not quite sure if and what the actual problem is here. Prior to the PR that I linked above (i.e. Turing < 0.16) the variables were sorted with natural sorting. So the order of the variables in the chain was expected and the desired behaviour. And hence also the indexing when plotting the trajectories seems to be correct.
Yeah, everything I posted was from the document webpage. The problem is that I am using the new version of Turing.jl which will face the error of no-sorting. So the solution is we shall update the document according to the new version of Turing.jl.
As explained in https://github.com/TuringLang/Turing.jl/pull/1627, you can recover the old behaviour (sorting with natural sort order) by specifying sort_chain=true
(i.e., use sample(....; sort_chain=true)
). Alternatively, you can just use 2:5
instead of 1:4
in the plotting code.
We should update the tutorial at some point but it is not completely urgent - in the tutorials the Turing version is stated on purpose so that you can see which version you have to use to get the same results. If you use a newer version, and in particular one with a breaking change, it is not guaranteed that the code still works.
Seems answered by https://github.com/TuringLang/Turing.jl/issues/1712#issuecomment-931624117. Please reopen if you have more questions.
Question on: https://github.com/TuringLang/Turing.jl/edit/master/docs/_tutorials/10_bayesian-differential-equations.md
The order of variables in the model is different from the chain statistics. This will induce inconsistency for final plot of estimated trajectories.
and
and