sbi icon indicating copy to clipboard operation
sbi copied to clipboard

Allow sampling the posterior given different `x` (batched)

Open michaeldeistler opened this issue 1 year ago • 2 comments

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 avatar Feb 15 '24 09:02 michaeldeistler

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 avatar Feb 29 '24 12:02 janfb

will be fixed with #1153

janfb avatar Jun 18 '24 07:06 janfb