PyTorch torch.fmod 函数

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

PyTorch torch.fmod 函数


torch.fmod 是 PyTorch 中用于计算逐元素取模余数的函数。

函数定义

torch.fmod(input, other, out)

使用示例

实例

import torch

# 计算逐元素取模
x = torch.tensor([10, 15, 20])
y = torch.tensor([3, 4, 7])

result = torch.fmod(x, y)
print(result)