Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.pow function

PyTorch torch.pow function


PyTorch torch reference manual 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

)

print

(

result

)

The exponent can also be used as the first argument

result2

=

torch.

pow

(

2

,

x

)

print

(

result2

)


PyTorch torch reference manual PyTorch torch reference manual