目录
1. torch.minimum
2. torch.minimum可以进行一个数组与多维度的比较
3.torch.min()
4. torch.min()多维度比较
1. torch.minimum
torch.minimum()
函数用于逐元素地比较两个张量,并返回一个新的张量,其中每个元素是两个输入张量对应元素中的最小值。
使用:
a = torch.tensor([10, 2, 3])
b = torch.tensor([30, 1, 2])
result = torch.minimum(a, b)
print(result)
2. torch.minimum进行一个数组与多维度的比较
a = torch.tensor([10, 2, 3])
b = torch.tensor([[30, 1, 2],
[30, 1, 2],
[1, 2, 3]
])
result = torch.minimum(a, b)
print(result)
3.torch.min()
a = torch.tensor([1, 2, 3]) min_value = torch.min(a) print("最小值:", min_value)
4. torch.min()多维度比较
b = torch.tensor([[30, 1, 2], [30, 1, 2], [1, 2, 3] ]) # a = torch.tensor([1, 2, 3]) min_value = torch.min(a,b) print("最小值:", min_value)