def test_same_result(self, im_shape, input_type):
     data = self.get_data(im_shape, input_type)
     alpha = [0.5, 0.8]
     t = RandGibbsNoised(KEYS, 1.0, alpha)
     t.set_random_state(42)
     out1 = t(deepcopy(data))
     t.set_random_state(42)
     out2 = t(deepcopy(data))
     for k in KEYS:
         torch.testing.assert_allclose(out1[k], out2[k], rtol=1e-7, atol=0)
         self.assertIsInstance(out1[k], type(data[k]))
Exemplo n.º 2
0
 def test_same_result(self, im_shape, as_tensor_output, as_tensor_input):
     data = self.get_data(im_shape, as_tensor_input)
     alpha = [0.5, 0.8]
     t = RandGibbsNoised(KEYS, 1.0, alpha, as_tensor_output)
     t.set_random_state(42)
     out1 = t(deepcopy(data))
     t.set_random_state(42)
     out2 = t(deepcopy(data))
     for k in KEYS:
         np.testing.assert_allclose(out1[k], out2[k])
         self.assertIsInstance(
             out1[k], torch.Tensor if as_tensor_output else np.ndarray)
Exemplo n.º 3
0
 def test_same_result(self, im_shape, input_type):
     data = self.get_data(im_shape, input_type)
     alpha = [0.5, 0.8]
     t = RandGibbsNoised(KEYS, 1.0, alpha)
     t.set_random_state(42)
     out1 = t(deepcopy(data))
     t.set_random_state(42)
     out2 = t(deepcopy(data))
     for k in KEYS:
         assert_allclose(out1[k],
                         out2[k],
                         rtol=1e-7,
                         atol=0,
                         type_test="tensor")