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

Return an AbstractChains object from appliying pointwise_logdensities to Abstractchains? #688

Open
bgctw opened this issue Oct 14, 2024 · 0 comments

Comments

@bgctw
Copy link
Contributor

bgctw commented Oct 14, 2024

Currently, pointwise_logdensities(chains::AbstractChains) returns an OrderedDict of Matrices all of the shape (sample x chain).

I find it more convenient to work with the results of the pointwise functions applied to AbstractChains as an AbstractChains again, rather than the OrderedDict{String, Matrix}.
What is a good place to support this conversion? A function in the MCMCChains extension such as:

function as_chains(lds_pointwise)
     Chains(stack(values(lds_pointwise); dims=2), collect(keys(lds_pointwise)))
end
chn = as_chains(logjoints_pointwise); # from @testset "pointwise_logdensities chain"
names(chn)
get(chn, :x)[1] == logjoints_pointwise["x"]

One could even think of letting the pointwise_logdensities(..., ::AbstractChains) routinely return a Chains object.
This could be achieved by

  • renaming the pointwise_logdensities(..., ::AbstractChains) to pointwise_logdensities_dict,
  • implementing it in the DynamicPPLMCMCChains extension by converting the result of pointwise_logdensities_dict.

What are opinions about this suggestion?

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

1 participant