Exemple #1
0
 def test_matmul_2d_float(self):
     t1 = TensorBase(np.array([[1.3, 2.5],
                               [3.4, 4.5]]))
     t2 = TensorBase(np.array([[5.8, 6.5],
                               [7.8, 8.9]]))
     self.assertTrue(syft.equal(syft.matmul(t1, t2), [[27.04, 30.7],
                                                      [54.82, 62.15]]))
Exemple #2
0
 def test_matmul_2d_int(self):
     t1 = TensorBase(np.array([[1, 2],
                               [3, 4]]))
     t2 = TensorBase(np.array([[5, 6],
                               [7, 8]]))
     self.assertTrue(syft.equal(syft.matmul(t1, t2), [[19, 22],
                                                      [43, 50]]))
Exemple #3
0
 def test_matmul_2d_identity(self):
     t1 = TensorBase(np.array([[1, 0],
                               [0, 1]]))
     t2 = TensorBase(np.array([[5.8, 6.5],
                               [7.8, 8.9]]))
     self.assertTrue(syft.equal(syft.matmul(t1, t2), [[5.8, 6.5],
                                                      [7.8, 8.9]]))
Exemple #4
0
 def test_matmul_1d_float(self):
     t1 = TensorBase(np.array([1.3, 2.5, 3.7]))
     t2 = TensorBase(np.array([4.9, 5.8, 6.5]))
     self.assertEqual(syft.matmul(t1, t2), syft.dot(t1, t2))
Exemple #5
0
 def test_matmul_1d_int(self):
     t1 = TensorBase(np.array([1, 2, 3]))
     t2 = TensorBase(np.array([4, 5, 6]))
     self.assertEqual(syft.matmul(t1, t2), syft.dot(t1, t2))
Exemple #6
0
    def __matmul__(self, tensor):
        """Performs matrix multiplication between two tensors"""
        if self.encrypted:
            return NotImplemented

        return syft.matmul(self, tensor)