快捷方式

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]))

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深入教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源