mindspore.numpy.outer
- mindspore.numpy.outer(a, b)[source]
Computes the outer product of two vectors.
Given two vectors,
a = [a0, a1, ..., aM]andb = [b0, b1, ..., bN], the outer product is:[[a0*b0 a0*b1 ... a0*bN ][a1*b0 . ][ ... . ][aM*b0 aM*bN ]]Note
Numpy argument
outis 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,
out[i, j] = a[i] * b[j].- Raises
TypeError – If the input is not a tensor.
- Supported Platforms:
AscendGPUCPU
Examples
>>> import mindspore.numpy as np >>> a = np.full(7, 2).astype('float32') >>> b = np.full(4, 3).astype('float32') >>> output = np.outer(a, b) >>> print(output) [[6. 6. 6. 6.] [6. 6. 6. 6.] [6. 6. 6. 6.] [6. 6. 6. 6.] [6. 6. 6. 6.] [6. 6. 6. 6.] [6. 6. 6. 6.]]