Evaluate log_prob of univariate Gaussian with multiple means

I would like to calculate the log probability of a vector with respect to n different Gaussians, shown below.

from torch import tensor
from pyro import distributions as dist

data = tensor([0., 1., 10., 11., 12.])

dist.Normal(tensor([0., 10.]), tensor(1.)).log_prob(data)

ValueError: Value is not broadcastable with batch_shape+event_shape: torch.Size([5])
 vs torch.Size([2]).

Ideally, this would return a 5x2 vector of log probabilities. Is there a way to accomplish this?

data => data.unsqueeze(-1)

pyro distributions have the same shape semantics as in torch

1 Like