mindspore.mint.pow

View Source On Gitee
mindspore.mint.pow(input, exponent)[source]

Calculates the exponent power of each element in input.

When exponent is a Tensor, the shapes of input and exponent must be broadcastable.

\[out_{i} = input_{i} ^{ exponent_{i}}\]

Warning

This is an experimental API that is subject to change or deletion.

Parameters
  • input (Union[Tensor, Number]) – The first input is a Number or a tensor whose data type is number or bool_.

  • exponent (Union[Tensor, Number]) –

    The second input is a Number or a tensor whose data type is number or bool_.

Returns

Tensor, the shape is the same as the one after broadcasting, and the data type is the one with higher precision or higher digits among the two inputs.

Raises
  • TypeError – If types of input and exponent are bool.

  • TypeError – The input is tensor and of type int or bool, while the exponent is negative int.

Supported Platforms:

Ascend

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, mint
>>> input = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32)
>>> exponent = 3.0
>>> output = mint.pow(input, exponent)
>>> print(output)
[ 1.  8. 64.]
>>>
>>> input = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float32)
>>> exponent = Tensor(np.array([2.0, 4.0, 3.0]), mindspore.float32)
>>> output = mint.pow(input, exponent)
>>> print(output)
[ 1. 16. 64.]