PyTorch torch.trunc 函数
torch.trunc 是 PyTorch 中用于逐元素截断(取整数部分)的函数。
函数定义
torch.trunc(input, out=None)
使用示例
实例
import torch
# 逐元素截断
x = torch.tensor([1.5, 2.7, -3.3])
result = torch.trunc(x)
print(result)
# 逐元素截断
x = torch.tensor([1.5, 2.7, -3.3])
result = torch.trunc(x)
print(result)

Pytorch torch 参考手册