Pow
torch_pow(self, exponent)
self
: (float) the scalar base value for the power operationexponent
: (float or tensor) the exponent valueTakes 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:
When exponent
is a tensor, the operation applied is:
When exponent
is a tensor, the shapes of input
and exponent
must be broadcastable .
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:
if (torch_is_installed()) { a = torch_randn(c(4)) a torch_pow(a, 2) exp <- torch_arange(1, 5) a <- torch_arange(1, 5) a exp torch_pow(a, exp) exp <- torch_arange(1, 5) base <- 2 torch_pow(base, exp) }
Useful links