PyTorch torch.pow function
PyTorch torch reference manual
torch.pow is a function in PyTorch used to compute element-wise exponentiation.
Function definition
torch.pow(input, exponent, out)
Usage examples
Example
import
torch
Compute exponentiation
x
=
torch.
tensor
(
[
2
,
3
,
4
]
)
result
=
torch.
pow
(
x
,
2
)
(
result
)
The exponent can also be used as the first argument
result2
=
torch.
pow
(
2
,
x
)
(
result2
)