torch.cummax
- torch.cummax(input, dim, *, out=None)
-
返回一个命名元组
(values, indices)
,其中values
是input
在维度dim
上的元素的累积最大值。而indices
则是每个最大值在维度dim
上的位置索引。$y_i = max(x_1, x_2, x_3, \dots, x_i)$示例:
>>> 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]))