matmul¶
dragon.vm.tensorflow.linalg.
matmul
(
a,
b,
name=None
)[source]¶Compute the matrix multiplication.
\[\text{out} = a \times b \]The behavior depends on the shape of input tensors:
- If both tensors are 1d, computes the vector product.
- If tensors are 1d and >=2d, computes the vector-matrix multiplication.
- If tensors are >=2d and 1d, computes the matrix-vector multiplication.
- If both tensors are >= 2d, computes the matrix-matrix multiplication.
- If one tensor is >= 3d, applies batching and broadcasting to the computation.
Examples:
# Vector x Vector a = tf.ones((2,), 'float32') b = tf.ones((2,), 'float32') print(tf.linalg.matmul(a, b)) # Vector x Matrix a = tf.ones((2,), 'float32') b = tf.ones((2, 3), 'float32') print(tf.linalg.matmul(a, b)) # Matrix x Vector a = tf.ones((3, 2), 'float32') b = tf.ones((2,), 'float32') print(tf.linalg.matmul(a, b)) # Matrix x Matrix a = tf.ones((2, 3), 'float32') b = tf.ones((3, 2), 'float32') print(tf.linalg.matmul(a, b))
- Parameters:
- a (dragon.Tensor) – The matrix \(a\).
- b (dragon.Tensor) – The matrix \(b\).
- name (str, optional) – The operation name.
- Returns:
dragon.Tensor – The output tensor.