• 文档 >
  • torch >
  • torch.min
快捷键

torch.min

torch.min(input) Tensor

返回张量 input 中所有元素的最小值。

参数:

input (Tensor) – 输入张量。

示例:

>>> a = torch.randn(1, 3)
>>> a
tensor([[ 0.6750,  1.0857,  1.7197]])
>>> torch.min(a)
tensor(0.6750)
torch.min(input, dim, keepdim=False, *, out=None)

返回一个命名元组 (values, indices) ,其中 valuesinput 张量每一行的最小值,在给定维度 dim 上。 indices 是每个最小值找到的索引位置(argmin)。

如果 keepdimTrue ,则输出张量的大小与 input 相同,除了在维度 dim 上大小为 1。否则, dim 被挤压(见 torch.squeeze() ),导致输出张量比 input 少一个维度。

注意

如果一个缩减行中有多个最小值,则返回第一个最小值的索引。

参数:
  • input (Tensor) – 输入张量。

  • dim(整数)- 要缩减的维度。

  • keepdim(布尔值)- 输出张量是否保留 dim

关键字参数:

out(元组,可选)- 包含两个输出张量的元组(min,min_indices)

示例:

>>> a = torch.randn(4, 4)
>>> a
tensor([[-0.6248,  1.1334, -1.1899, -0.2803],
        [-1.4644, -0.2635, -0.3651,  0.6134],
        [ 0.2457,  0.0384,  1.0128,  0.7015],
        [-0.1153,  2.9849,  2.1458,  0.5788]])
>>> torch.min(a, 1)
torch.return_types.min(values=tensor([-1.1899, -1.4644,  0.0384, -0.1153]), indices=tensor([2, 0, 1, 0]))
torch.min(input, other, *, out=None) Tensor

torch.minimum()


© 版权所有 PyTorch 贡献者。

使用 Sphinx 构建,并使用 Read the Docs 提供的主题。

文档

PyTorch 的全面开发者文档

查看文档

教程

深入了解初学者和高级开发者的教程

查看教程

资源

查找开发资源并获得您的疑问解答

查看资源