chainer.functions.matmul¶
-
chainer.functions.matmul(a, b, transa=False, transb=False)[source]¶ Computes the matrix multiplication of two arrays.
Parameters: - a (
Variableor N-dimensional array) – The left operand of the matrix multiplication. Ifaandbare both 1-D arrays,matmulreturns a dot product of vector a and vector b. If 2-D arrays,matmulreturns matrix product ofaandb. If either’s dimension is larger than 2, they are treated as a stack of matrices residing in the last two indexes.matmulreturns a stack of each two arrays. In this case,aandbare broadcasted along axes except the last two. - b (
Variableor N-dimensional array) – The right operand of the matrix multiplication. Its array is treated as a matrix in the same way asa’s array. - transa (bool) – If
True, each matrices inawill be transposed. Ifa.ndim == 1, do nothing. - transb (bool) – If
True, each matrices inbwill be transposed. Ifb.ndim == 1, do nothing.
Returns: The result of the matrix multiplication.
Return type: Example
>>> a = np.array([[1, 0], [0, 1]], np.float32) >>> b = np.array([[4, 1], [2, 2]], np.float32) >>> F.matmul(a, b).data array([[4., 1.], [2., 2.]], dtype=float32)
- a (