I am doing an unittest, and was wondering wether to use .item()
or not. Both give the same result, so my question is it correct If I do it the 1-way? (more clean to me)
import unittest
import torch
class TestTensor(unittest.TestCase):
def test_values(self):
x = torch.arange(1, 10) > 8
self.assertTrue(x.any()) # 1-way
self.assertTrue(x.any().item()) # 2-way