PyTorch torch.frac 函数

约 209 字 更新于 2026-11-18 5iyo.com

PyTorch torch.frac 函数


torch.frac 是 PyTorch 中用于计算逐元素小数部分的函数。

函数定义

torch.frac(input, out)

使用示例

实例

import torch

# 计算小数部分
x = torch.tensor([1.5, 2.7, 3.1, 4.9])
result = torch.frac(x)
print(result)