def batch_log_pdf(self, x):
"""
Ref: :py:meth:`pyro.distributions.distribution.Distribution.batch_log_pdf`
"""
mu = self.mu.expand(self.shape(x))
sigma = self.sigma.expand(self.shape(x))
ll_1 = Variable(torch.Tensor([-0.5 * np.log(2.0 * np.pi)]).type_as(mu.data).expand_as(x))
ll_2 = -torch.log(sigma * x)
ll_3 = -0.5 * torch.pow((torch.log(x) - mu) / sigma, 2.0)
batch_log_pdf = torch.sum(ll_1 + ll_2 + ll_3, -1)
batch_log_pdf_shape = self.batch_shape(x) + (1,)
return batch_log_pdf.contiguous().view(batch_log_pdf_shape)
评论列表
文章目录