现在位置: 首页 > PyTorch 教程 > 正文

PyTorch torch.minimum 函数


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

torch.minimum 是 PyTorch 中用于逐元素取最小值的函数。返回两个张量对应元素的最小值组成的新张量。

函数定义

torch.minimum(input, other)

使用示例

实例

import torch

# 创建两个张量
x = torch.tensor([3, 1, 4])
y = torch.tensor([1, 5, 2])

# 逐元素取最小值
result = torch.minimum(x, y)
print(result)

输出结果为:

tensor([1, 1, 2])

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