Skip to content

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

Closed

Description

@michaeldeistler

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()

Activity

  1. added
    enhancement
    on Feb 15, 2024
  2. janfb commented on Feb 29, 2024

    @janfb
    Contributor

    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).

  3. janfb commented on Jun 18, 2024

    @janfb
    Contributor

    will be fixed with #1153

  4. linked a pull request that will close this issuefeat: batched sampling for MCMC #1176on Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions