PyTorch torch.divide 函数
torch.divide 是 PyTorch 中用于逐元素除法的函数(等同于 div)。
函数定义
torch.divide(input, other, *, rounding_mode=None, out=None)
使用示例
实例
import torch
# 逐元素除法示例
x = torch.tensor([10.0, 20.0, 30.0])
y = torch.tensor([2.0, 4.0, 5.0])
result = torch.divide(x, y)
print(result) # tensor([5.0000, 5.0000, 6.0000])
# 逐元素除法示例
x = torch.tensor([10.0, 20.0, 30.0])
y = torch.tensor([2.0, 4.0, 5.0])
result = torch.divide(x, y)
print(result) # tensor([5.0000, 5.0000, 6.0000])

Pytorch torch 参考手册