评价此页

torch.cummax#

torch.cummax(input, dim, *, out=None)#

返回一个命名元组 (values, indices),其中 valuesinputdim 维度上的累积最大值。 indices 是在 dim 维度上找到的每个最大值的索引位置。

yi=max(x1,x2,x3,,xi)y_i = max(x_1, x_2, x_3, \dots, x_i)
参数
  • input (Tensor) – 输入张量。

  • dim (int) – 要进行操作的维度

关键字参数

out (tuple, optional) – 包含两个输出张量(values, indices)的结果元组。

示例

>>> a = torch.randn(10)
>>> a
tensor([-0.3449, -1.5447,  0.0685, -1.5104, -1.1706,  0.2259,  1.4696, -1.3284,
     1.9946, -0.8209])
>>> torch.cummax(a, dim=0)
torch.return_types.cummax(
    values=tensor([-0.3449, -0.3449,  0.0685,  0.0685,  0.0685,  0.2259,  1.4696,  1.4696,
     1.9946,  1.9946]),
    indices=tensor([0, 0, 2, 2, 2, 5, 6, 6, 8, 8]))