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

PyTorch torch.exp2 function

PyTorch torch.exp2 function

PyTorch torch.exp2 function


PyTorch torch reference manual PyTorch torch reference manual

torch.exp2 is a PyTorch function for computing powers of 2 element-wise.

Function definition

torch.exp2(input, *, out=None)


Usage examples

Example

import

torch

Power-of-2 example

x

=

torch.

tensor

(

[

0

,

1

,

2

,

3

,

4

]

,

dtype

=

torch.

float32

)

result

=

torch.

exp2

(

x

)

print

(

result

)

 

tensor([1., 2., 4., 8., 16.])


PyTorch torch reference manual PyTorch torch reference manual