예제 #1
0
 def test_lower_cholesky_affine(self):
     for input_dim in [2, 3]:
         loc = torch.randn(input_dim)
         scale_tril = torch.randn(input_dim).exp().diag() + 0.03 * torch.randn(input_dim, input_dim)
         scale_tril = scale_tril.tril(0)
         transform = T.LowerCholeskyAffine(loc, scale_tril)
         self._test_inverse(input_dim, transform)
         self._test_jacobian(input_dim, transform)
         for shape in [(3,), (3, 4)]:
             self._test_shape(shape + (input_dim,), transform)
예제 #2
0
 def transform_factory(input_dim):
     loc = torch.randn(input_dim)
     scale_tril = torch.randn(input_dim).exp().diag(
     ) + 0.03 * torch.randn(input_dim, input_dim)
     scale_tril = scale_tril.tril(0)
     return T.LowerCholeskyAffine(loc, scale_tril)