PyTorch torch.fix Function

PyTorch torch.fix Function


Pytorch torch 参考手册PyTorch torch Reference Manual

torch.fixis a function in PyTorch used to extract the integer part element-wise (rounding towards zero).

Function Definition

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

Usage Example

Example

import torch

# Example of extracting the integer part
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 参考手册PyTorch torch Reference Manual

Other Extensions