TUTORIALAI 与数据科学FETCHED

PyTorch torch.fix 函数

PyTorch torch.fix 函数 PyTorch torch.fix 函数 Pytorch torch 参考手册 torch.fix 是 PyTorch 中用于逐元素取整数部分(向零取整)的函数。 函数定义 torch.fix(input, *, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 取整数部分示例 x = ..

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.fix 函数

PyTorch torch.fix 函数


Pytorch torch 参考手册 Pytorch torch 参考手册

torch.fix 是 PyTorch 中用于逐元素取整数部分(向零取整)的函数。

函数定义

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

使用示例

实例

import torch

# 取整数部分示例
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 参考手册