PyTorch torch.pow function
Pytorch torch Reference Manual
torch.powIt is a function in PyTorch used to compute element-wise power operations.
Function definition
torch.pow(input, exponent, out)
Usage example
Example
import torch
# Compute the power operation
x = torch.tensor([2, 3, 4])
result = torch.pow(x, 2)
print(result)
# You can also use the exponent as the first argument
result2 = torch.pow(2, x)
print(result2)
# Compute the power operation
x = torch.tensor([2, 3, 4])
result = torch.pow(x, 2)
print(result)
# You can also use the exponent as the first argument
result2 = torch.pow(2, x)
print(result2)
Other extensions