TUTORIALAI 与数据科学FETCHED

PyTorch torch.remainder 函数

PyTorch torch.remainder 函数 Pytorch torch 参考手册 torch.remainder 是 PyTorch 中用于计算逐元素取余运算的函数。 函数定义 torch.remainder(input, other, out=None) 使用示例 实例 [mycode4 type='python'] import torch # 逐元素取余 x = torch.te..

更新于 2026/7/16

教程详情页默认 noindex。

PyTorch torch.remainder 函数


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

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

函数定义

torch.remainder(input, other, out=None)

使用示例

实例

import torch

# 逐元素取余
x = torch.tensor([10.0, 20.0, 30.0])
y = torch.tensor([3.0, 4.0, 7.0])
result = torch.remainder(x, y)
print(result)

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