Repository navigation
feat: batched sampling for MCMC - #1176
Conversation
…rs' into amortizedsample
…from-different-posteriors' into amortizedsample
… reshapes in rejection
This reverts commit 17c5343.
|
I've made some progress now towards this PR, and would like some feedback before I continue.
Given
|
|
Great, it looks good. I like that the choice on iid or not can now be made at the I would also opt for your suggested option. The question arises because we squeeze the batch_shape into a single dimension, right? For "PyTorch" broadcasting, one would expect something like (1,batch_x_dim, x_dim) and (batch_theta_dim, betach_x_dim, theta_dim) -> (batch_x_dim, batch_theta_dim), so by squeezing the xs, thetas into 2d one would always get a dimension that is a multiple of batch_x_dim (otherwise it cannot be represented by a fixed size tensor). For (1,batch_x_dim,x_dim) and (batch_theta_dim, 1, theta_dim), PyTorch broadcasting semantics would compute all combinations. Unfortunately, after squeezing, these distinctions between cases can no longer be fully preserved. |
janfb
left a comment
There was a problem hiding this comment.
Great effort, thanks a lot for tacking this 👏
I do have a couple of comments and questions. Happy to discuss in person if needed.
Thanks for the review! I implemented your suggestions. An additional point - For |
janfb
left a comment
There was a problem hiding this comment.
Looks great! I added just a couple of last questions..
janfb
left a comment
There was a problem hiding this comment.
Looks good! Thanks a lot, great effort!
What does this implement/fix? Explain your changes
This pull request aims to implement the
sample_batchedmethod for MCMC.Current problem
BasePotentialcan either "allow_iid" or not. Hence, each batch dimension will be interpreted as IID samples.allow_iidwith a mutable attribute (or optional input argument)interpret_as_iid.The current implementation will let you sample the correct shape, BUT will output the wrong solution. This is because the potential function will broadcast, repeat and finally sum up the first dimension which is incorrect.