def test_addcdiv_1d(self): t1 = TensorBase(np.array([1, 2, 3])) t2 = TensorBase(np.array([2, 5, 4])) mat = TensorBase(np.array([5])) out = syft.addcdiv(t1, t2, mat, value=2) self.assertTrue(np.array_equal(out.data, [6., 5.8, 6.5]))
def test_addcdiv_2d(self): t1 = TensorBase(np.array([[1, 2], [1, 2]])) t2 = TensorBase(np.array([[1, 2], [1, 2]])) mat = TensorBase(np.array([[2, 3], [3, 4]])) out = syft.addcdiv(t1, t2, mat, value=2) self.assertTrue(np.array_equal(out.data, [[4., 5.], [5., 6.]]))
def addcdiv(self, tensor2, mat, value=1): """Performs the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to mat.""" return syft.addcdiv(self, tensor2, mat, value)