mindspore.numpy.power
- mindspore.numpy.power(x1, x2, dtype=None)[源代码]
First array elements raised to powers from second array, element-wise.
Raises each base in x1 to the positionally-corresponding power in x2.
说明
Numpy arguments out, where, casting, order, subok, signature, and extobj are not supported. On GPU, the supported dtypes are np.float16, and np.float32.
- 参数
x1 (Tensor) – The bases.
x2 (Tensor) – The exponents.
dtype (
mindspore.dtype
, optional) – Default:None
. Overrides the dtype of the output Tensor.
- 返回
Tensor or scalar, the bases in x1 raised to the exponents in x2. This is a scalar if both x1 and x2 are scalars.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> x1 = np.full((3, 2), [1, 2]).astype('float32') >>> x2 = np.full((3, 2), [3, 4]).astype('float32') >>> output = np.power(x1, x2) >>> print(output) [[ 1. 16.] [ 1. 16.] [ 1. 16.]]