Turing v0.45#697
Conversation
|
Preview the changes: https://turinglang.org/docs/pr-previews/697 |
| # was rejected -- that is why we seed the sampling in this section). | ||
| chn1[:x][end], chn2[:x][1] | ||
|
|
||
| chn1[@varname(x)][end], chn1[@varname(y)][end] |
There was a problem hiding this comment.
I'm a little confused, should this be comparing chn1[y] with chn2[x]?
There was a problem hiding this comment.
Oh, yeah, somehow I got confused myself.
| # Extract the number of clusters for each sample of the Markov chain. | ||
| k = map( | ||
| t -> length(unique(vec(chain[t, MCMCChains.namesingroup(chain, :z), :].value))), | ||
| t -> length(unique(chain[@varname(z), iter=t])), |
There was a problem hiding this comment.
(courtesy of Claude)
chain[@varname(z), iter=t] keeps the chain dimension, so for a single-chain run with N-element z it returns a 1×N DimMatrix. unique on a 2-D array returns unique rows, not unique elements:
unique([1 2 3]) # → [[1 2 3]] — length 1So k will end up 1 for nearly every iteration and the cluster-count plot won't match the prose right below it about converging to ~3 clusters.
| t -> length(unique(chain[@varname(z), iter=t])), | |
| t -> length(unique(chain[@varname(z), iter=t, chain=1])), |
sunxd:
https://turinglang.org/docs/pr-previews/697/tutorials/infinite-mixture-models/ near the bottom the plot does look wrong
There was a problem hiding this comment.
I had no idea that unique did that and must have missed this one, thanks
There was a problem hiding this comment.
So Claude's not right:
julia> unique([1 2 3])
3-element Vector{Int64}:
1
2
3But I realised what the issue was, it's that chain[@varname(z)] is an array of vectors, not a 3D matrix. So just passing stack=true makes that right.
There was a problem hiding this comment.
nice! Sorry I should have verified
| ::: {.callout-warning} | ||
| ## `resume_from` | ||
|
|
||
| The `resume_from` argument has been removed in Turing v0.41; please use `initial_state=loadstate(chn)` instead, as described here. |
There was a problem hiding this comment.
sometimes it's only(loadstate(chn))?
There was a problem hiding this comment.
I guess it depends on the exact invocation of sample so it's a bit finicky, but I rephrased to clarify.
|
Thank you! :) |
These are all just interface changes for MCMCChains -> FlexiChains, there aren't any other content changes. I also took the liberty to remove the minituring pages as they're several versions outdated (we don't have
SamplingContextorassumeanymore).Closes #677
Inadvertently closes #483 since FlexiChains has better docs