Ejemplo n.º 1
0
 def testClampFloatInPlace(self):
     t1 = TensorBase(np.arange(1, step=0.1))
     t1.clamp_(minimum=0.2, maximum=0.7)
     expected_tensor = TensorBase(np.array([0.2, 0.2, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.7, 0.7]))
     self.assertEqual(t1, expected_tensor)
Ejemplo n.º 2
0
 def testClampIntInPlace(self):
     t1 = TensorBase(np.arange(10))
     t1.clamp_(minimum=2, maximum=7)
     expected_tensor = TensorBase(np.array([2, 2, 2, 3, 4, 5, 6, 7, 7, 7]))
     self.assertEqual(t1, expected_tensor)