mindspore.numpy.dot
- mindspore.numpy.dot(a, b)[source]
Returns the dot product of two arrays.
Specifically, If both a and b are 1-D arrays, it is inner product of vectors (without complex conjugation). If both a and b are 2-D arrays, it is matrix multiplication. If either a or b is 0-D (scalar), it is equivalent to multiply. If a is an N-D array and b is a 1-D array, it is a sum product over the last axis of a and b. If a is an N-D array and b is an M-D array (where
M>=2
), it is a sum product over the last axis of a and the second-to-last axis of b:dot(a, b)[i,j,k,m] = sum(a[i,j,:] * b[k,:,m])
Note
Numpy argument out is not supported. On GPU, the supported dtypes are np.float16, and np.float32. On CPU, the supported dtypes are np.float16, np.float32, and np.float64.
- Parameters
- Returns
Tensor or scalar, the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned
- Raises
ValueError – If the last dimension of a is not the same size as the second-to-last dimension of b.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> import mindspore.numpy as np >>> a = np.full((1, 3), 7).astype('float32') >>> b = np.full((2, 3, 4), 5).astype('float32') >>> output = np.dot(a, b) >>> print(output) [[[105. 105. 105. 105.] [105. 105. 105. 105.]]]