def batch_log_pdf(self, x):
"""
Ref: :py:meth:`pyro.distributions.distribution.Distribution.batch_log_pdf`
"""
a = self.a.expand(self.shape(x))
b = self.b.expand(self.shape(x))
lb = x.ge(a).type_as(a)
ub = x.le(b).type_as(b)
batch_log_pdf_shape = self.batch_shape(x) + (1,)
return torch.sum(torch.log(lb.mul(ub)) - torch.log(b - a), -1).contiguous().view(batch_log_pdf_shape)
评论列表
文章目录