# tensorplay.functional.pow Source: https://www.tensorplay.cn/docs/generated/tensorplay.functional.pow.html ```python tensorplay.functional.pow(input, exponent, *, out=None) → Tensor ``` 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 or a Tensor with the same number of elements as input. When exponent is a scalar value, the operation applied is: $$\text{out}_i = x_i ^ \text{exponent}$$ When exponent is a tensor, the operation applied is: $$\text{out}_i = x_i ^ {\text{exponent}_i}$$ When exponent is a tensor, the shapes of input and exponent must be [broadcastable](/docs/notes/broadcasting.html#broadcasting-semantics). Parameters: - input ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the input tensor. - exponent ([float](https://docs.python.org/3/builtins/functions.html#float) or tensor) – the exponent value Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> a = tensorplay.randn(4) >>> a tensor([ 0.4331, 1.2475, 0.6834, -0.2791]) >>> tensorplay.pow(a, 2) tensor([ 0.1875, 1.5561, 0.4670, 0.0779]) >>> exp = tensorplay.arange(1., 5.) >>> a = tensorplay.arange(1., 5.) >>> a tensor([ 1., 2., 3., 4.]) >>> exp tensor([ 1., 2., 3., 4.]) >>> tensorplay.pow(a, exp) tensor([ 1., 4., 27., 256.]) ``` ```python tensorplay.functional.pow(self, exponent, *, out=None) → Tensor ``` self is a scalar float value, and exponent is a tensor. The returned tensor out is of the same shape as exponent The operation applied is: $$\text{out}_i = \text{self} ^ {\text{exponent}_i}$$ Parameters: - self ([float](https://docs.python.org/3/builtins/functions.html#float)) – the scalar base value for the power operation - exponent ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor)) – the exponent tensor Keyword Arguments: out ([Tensor](/docs/generated/tensorplay.Tensor.html#tensorplay.Tensor), optional) – the output tensor. Example: ``` >>> exp = tensorplay.arange(1., 5.) >>> base = 2 >>> tensorplay.pow(base, exp) tensor([ 2., 4., 8., 16.]) ```