In my tests I need to assertEqual
2 tensor values. Sometimes both of them are tensors of zero actually any values, for example:
def test_preprocess_text_single_line(self):
self.assertEqual(torch.tensor([0, 2, 0, 1, 0, 0, 0]), torch.tensor([0, 0, 2, 0, 0, 8, 0]))
Which leads to RuntimeError
:
self.assertEqual(torch.tensor([0, 2, 0, 1, 0, 0, 0]), torch.tensor([0, 0, 2, 0, 0, 8, 0]))
RuntimeError: Boolean value of Tensor with more than one value is ambiguous
How to avoid that?