示例#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.Rot180(), (input, ), raise_exception=True)
示例#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.Rot180(), (input, ), raise_exception=True)
示例#3
0
    def test_rot180(self):

        f = kornia.Rot180()
        input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1.,
                                                           1.]])  # 3 x 3

        expected = torch.tensor([[1., 1., 0.], [0., 0., 0.], [0., 0.,
                                                              0.]])  # 3 x 3

        assert (f(input) == expected).all()
示例#4
0
    def test_rot180(self, device, dtype):

        f = kornia.Rot180()
        input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]],
                             device=device,
                             dtype=dtype)  # 3 x 3

        expected = torch.tensor([[1., 1., 0.], [0., 0., 0.], [0., 0., 0.]],
                                device=device,
                                dtype=dtype)  # 3 x 3

        assert (f(input) == expected).all()
示例#5
0
    def test_batch_rot180(self):

        input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1.,
                                                           1.]])  # 3 x 3

        input = input.repeat(2, 1, 1)  # 2 x 3 x 3

        f = kornia.Rot180()
        expected = torch.tensor([[1., 1., 0.], [0., 0., 0.],
                                 [0., 0., 0.]])  # 1 x 3 x 3

        expected = expected.repeat(2, 1, 1)  # 2 x 3 x 3

        assert (f(input) == expected).all()
示例#6
0
    def test_batch_rot180(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)  # 3 x 3

        input = input.repeat(2, 1, 1)  # 2 x 3 x 3

        f = kornia.Rot180()
        expected = torch.tensor(
            [[1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]],
            device=device,
            dtype=dtype)  # 1 x 3 x 3

        expected = expected.repeat(2, 1, 1)  # 2 x 3 x 3

        assert (f(input) == expected).all()
示例#7
0
 def smoke_test(self, device, dtype):
     f = kornia.Rot180()
     repr = "Rot180()"
     assert str(f) == repr
示例#8
0
        def op_script(data: torch.Tensor) -> torch.Tensor:

            return kornia.Rot180(data)
示例#9
0
 def smoke_test(self):
     f = kornia.Rot180()
     repr = "Rot180()"
     assert str(f) == repr