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

PyTorch torch.fix function

PyTorch torch.fix function

PyTorch torch.fix function


PyTorch torch reference manual PyTorch torch reference manual

torch.fix is a PyTorch function for taking the integer part of each element (rounding toward zero).

Function definition

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


Usage examples

Example

import

torch

Integer-part example

x

=

torch.

tensor

(

[

1.5

,

0.5

,

0.5

,

1.5

,

2.7

]

)

result

=

torch.

fix

(

x

)

print

(

result

)

 

tensor([-1., -0., 0., 1., 2.])


PyTorch torch reference manual PyTorch torch reference manual