def test_gradcheck(self): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]).double() # 3 x 3 input = utils.tensor_to_gradcheck_var(input) # to var assert gradcheck(kornia.Hflip(), (input, ), raise_exception=True)
def test_gradcheck(self, device, dtype): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]], device=device, dtype=dtype) # 3 x 3 input = utils.tensor_to_gradcheck_var(input) # to var assert gradcheck(kornia.Hflip(), (input, ), raise_exception=True)
def test_hflip(self): f = kornia.Hflip() input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]) # 3 x 3 expected = torch.tensor([[0., 0., 0.], [0., 0., 0.], [1., 1., 0.]]) # 3 x 3 assert (f(input) == expected).all()
def test_hflip(self, device, dtype): f = kornia.Hflip() input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]], device=device, dtype=dtype) # 3 x 3 expected = torch.tensor([[0., 0., 0.], [0., 0., 0.], [1., 1., 0.]], device=device, dtype=dtype) # 3 x 3 assert (f(input) == expected).all()
def test_batch_hflip(self): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]) # 1 x 3 x 3 input = input.repeat(2, 1, 1) # 2 x 3 x 3 f = kornia.Hflip() expected = torch.tensor([[[0., 0., 0.], [0., 0., 0.], [1., 1., 0.]]]) # 3 x 3 expected = expected.repeat(2, 1, 1) # 2 x 3 x 3 assert (f(input) == expected).all()
def test_batch_hflip(self, device, dtype): input = torch.tensor( [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 1 x 3 x 3 input = input.repeat(2, 1, 1) # 2 x 3 x 3 f = kornia.Hflip() expected = torch.tensor( [[[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 0.0]]], device=device, dtype=dtype) # 3 x 3 expected = expected.repeat(2, 1, 1) # 2 x 3 x 3 assert (f(input) == expected).all()
def smoke_test(self, device, dtype): f = kornia.Hflip() repr = "Hflip()" assert str(f) == repr
def smoke_test(self): f = kornia.Hflip() repr = "Hflip()" assert str(f) == repr
def op_script(data: torch.Tensor) -> torch.Tensor: return kornia.Hflip(data)