Пример #1
0
 def test_outer_prod(self):
     vector = torch.tensor([[1, 2], [3, 4]], dtype=torch.double)
     expect = torch.tensor([[[10, 14], [14, 20]], [[0, 2], [-2, 0]]],
                           dtype=torch.double)
     self.assertTensorsEqual(cplx.outer_prod(vector, vector),
                             expect,
                             msg="Outer product failed!")
Пример #2
0
 def test_outer_prod_error_large(self):
     # take outer prod of 2 rank 3 tensors, instead of rank 2
     tensor = torch.tensor([[[1, 2], [3, 4]], [[5, 6], [7, 8]]], dtype=torch.double)
     with self.assertRaises(ValueError):
         cplx.outer_prod(tensor, tensor)
Пример #3
0
 def test_outer_prod_error_small(self):
     # take outer prod of 2 rank 1 tensors, instead of rank 2
     tensor = torch.tensor([1, 2], dtype=torch.double)
     with self.assertRaises(ValueError):
         cplx.outer_prod(tensor, tensor)