oneflow.pow

oneflow.pow()
Takes the power of each element in input with exponent and returns a tensor with the result. Exponent can be either a single float number, a single int number, or a tensor with the same shape as input.

When exponent is a scalar value, the operation applied is:

\[\begin{split}\\text{out}_i = x_i ^ \\text{exponent}\end{split}\]
u200b

When exponent is a tensor, the operation applied is:

\[\begin{split}\\text{out}_i = x_i ^ {\\text{exponent}_i}\end{split}\]
Args:
  • input (Tensor): the input tensor.

  • exponent (int, float, Tensor): the exponent.

Returns:

Tensor: The result of variance on the specified axis of input Tensor

For example:

>>> import oneflow as flow
>>> import numpy as np

>>> x = flow.tensor(np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0]), dtype=flow.float32)
>>> out = flow.pow(x, 2)
>>> out
tensor([ 1.,  4.,  9., 16., 25., 36.], dtype=oneflow.float32)

>>> x = flow.tensor(np.array([1.0, 2.0, 3.0, 4.0]), dtype=flow.float32)
>>> y = flow.tensor(np.array([1.0, 2.0, 3.0, 4.0]), dtype=flow.float32)
>>> out = flow.pow(x, y)
>>> out
tensor([  1.,   4.,  27., 256.], dtype=oneflow.float32)