Beispiel #1
0
    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)
Beispiel #2
0
    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)
Beispiel #3
0
    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()
Beispiel #4
0
    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()
Beispiel #5
0
    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()
Beispiel #6
0
    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()
Beispiel #7
0
 def smoke_test(self, device, dtype):
     f = kornia.Hflip()
     repr = "Hflip()"
     assert str(f) == repr
Beispiel #8
0
 def smoke_test(self):
     f = kornia.Hflip()
     repr = "Hflip()"
     assert str(f) == repr
Beispiel #9
0
        def op_script(data: torch.Tensor) -> torch.Tensor:

            return kornia.Hflip(data)