mindspore.ops.cummax

mindspore.ops.cummax(input, axis)[源代码]

返回tensor在指定轴上的累积最大值及其索引。

\[\begin{split}\begin{array}{ll} \\ y_{i} = \max(x_{1}, x_{2}, ... , x_{i}) \end{array}\end{split}\]

警告

从2.9.0(不含)之后版本开始,该接口将发生非兼容性变更:参数 axis 将重命名为 dim

变更后的接口签名为 mindspore.ops.cummax(input, dim)

参数:
  • input (Tensor) - 输入tensor。

  • axis (int) - 指定计算的轴。

返回:

两个tensor组成的tuple(max, max_indices)

支持平台:

Ascend GPU CPU

样例:

>>> import mindspore
>>> input = mindspore.tensor([[3, 4, 6, 10],
...                           [1, 6, 7, 9],
...                           [4, 3, 8, 7],
...                           [1, 3, 7, 9]])
>>> mindspore.ops.cummax(input, axis=0)
(Tensor(shape=[4, 4], dtype=Int64, value=
 [[ 3,  4,  6, 10],
  [ 3,  6,  7, 10],
  [ 4,  6,  8, 10],
  [ 4,  6,  8, 10]]),
 Tensor(shape=[4, 4], dtype=Int64, value=
 [[0, 0, 0, 0],
  [0, 1, 1, 0],
  [2, 1, 2, 0],
  [2, 1, 2, 0]]))