Skip to content

Sampling from posterior with 3-D tensor #1288

Answered by michaeldeistler
Jimmyc776 asked this question in Q&A
Discussion options

You must be logged in to vote

Hi there,

thanks for reporting this! I tried reproducing the issue but all seems fine to me. Could you test whether the following works for you:

import torch
from torch import ones, zeros, eye, float32, tensor, as_tensor, randn, rand, randn_like
from torch.nn import Module
from torch import nn

from sbi.inference import NPE
from sbi.utils import BoxUniform
from sbi.neural_nets import posterior_nn


prior = BoxUniform(-ones(3), ones(3))
theta = prior.sample((100,))
x = torch.stack([theta, theta, theta], axis=1)
x = torch.stack([x, x, x], axis=1)
x += randn_like(x) * 0.1
print(f"theta.shape {theta.shape}")  # torch.Size([100, 3])
print(f"x.shape {x.shape}")  # torch.Size([100, 3, 3, 3])

x_o =

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@Jimmyc776
Comment options

@michaeldeistler
Comment options

Answer selected by michaeldeistler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants