mindspore.ops.float_power

View Source On Gitee
mindspore.ops.float_power(input, exponent)[source]

Computes input to the power of the exponent. For the real number type, cast input and exponent to mindspore.float64 to calculate. Currently, complex type calculation is not supported.

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

  • exponent (Union[Tensor, Number]) – The second input, if the first input is Tensor, the second input can be Number or Tensor. Otherwise, it must be a Tensor.

Returns

Tensor, the shape is the same as the one after broadcasting. For the complex type, the return value type is the same as the input type. For the real number type, the return value type is mindspore.float64.

Raises
  • TypeError – If neither input nor exponent is a Tensor.

  • TypeError – If the data type of input or exponent is not in Tensor and Number.

Supported Platforms:

GPU CPU

Examples

>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> input = Tensor(np.array([-1.5, 0., 2.]))
>>> output = ops.float_power(input, 2)
>>> print(output)
[2.25 0.   4.  ]