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

Allow sampling the posterior given different x (batched) #944

Closed
michaeldeistler opened this issue Feb 15, 2024 · 2 comments · Fixed by #1176
Closed

Allow sampling the posterior given different x (batched) #944

michaeldeistler opened this issue Feb 15, 2024 · 2 comments · Fixed by #1176
Labels
enhancement New feature or request

Comments

@michaeldeistler
Copy link
Contributor

michaeldeistler commented Feb 15, 2024

Is your feature request related to a problem?
I would like to sample the posterior distribution given many x_o (amortization). This is also done in SBC. Currently, this requires a for-loop over x. I think it would be nice to have an option to sample batches of x. This should be possible for any kind of sampler we have (including VI, MCMC, Direct,...)

Describe the solution you'd like
To avoid the hassle of having to decide whether the x are supposed to be i.i.d. or multi-d or just a batch over which to amortize, I would suggest to have a separate sampling method for this, e.g. def sample_amortized()

@michaeldeistler michaeldeistler added the enhancement New feature or request label Feb 15, 2024
@janfb
Copy link
Contributor

janfb commented Feb 29, 2024

Note that nflows (and sbi posteriors) enable passing a batch of conditions to sample. The return shape is

(num_conditions, num_samples, x_shape) = flow.sample(num_samples, condition)

with condition.shape=(num_conditions, x_shape).

@janfb
Copy link
Contributor

janfb commented Jun 18, 2024

will be fixed with #1153

@janfb janfb linked a pull request Jul 30, 2024 that will close this issue
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants