Exemplo n.º 1
0
 def test_multidimensional_product(self, t1, t2):
     """Test that the multi-dimensional dot product reduces across the last dimension of the first
     tensor, and the second-to-last dimension of the second tensor."""
     res = fn.dot(t1, t2)
     expected = np.array([[[[7, 7], [9, 5]], [[15, 15], [21, 11]],
                           [[2, 2], [0, 1]]],
                          [[[23, 23], [33, 17]], [[-3, -3], [-3, -2]],
                           [[5, 5], [9, 4]]]])
     assert fn.allequal(res, expected)
Exemplo n.º 2
0
 def test_matrix_matrix_product(self, t1, t2):
     """Test that the matrix-matrix dot product of two vectors results in a matrix"""
     res = fn.dot(t1, t1)
     assert fn.allequal(res, np.array([[7, 10], [15, 22]]))
Exemplo n.º 3
0
 def test_matrix_vector_product(self, t1, t2):
     """Test that the matrix-vector dot product of two vectors results in a vector"""
     res = fn.dot(t1, t2)
     assert fn.allequal(res, [20, 46])
Exemplo n.º 4
0
 def test_vector_matrix_product(self, t1, t2):
     """Test that the vector-matrix dot product of two vectors results in a vector"""
     res = fn.dot(t2, t1)
     assert fn.allequal(res, [27, 40])
Exemplo n.º 5
0
 def test_vector_product(self, t1, t2):
     """Test that the dot product of two vectors results in a scalar"""
     res = fn.dot(t1, t2)
     assert fn.allequal(res, 14)