cummin
- paddle. cummin ( x: Tensor, axis: int | None = None, dtype: DTypeLike = 'int64', name: str | None = None, *, out: tuple[Tensor, Tensor] | None = None ) CumminRetType [source]
-
The cumulative min of the elements along a given axis.
This API has two signatures:
paddle.cummin(x, axis=None, dtype='int64', name=None)(Paddle-style): Compute cumulative min with optional axis parameter.paddle.cummin(input, dim, *, out=None)(PyTorch-style): Compute cumulative min with required dim parameter. The parameter nameinputis an alias forx,dimis an alias foraxis.
Note
The first element of the result is the same as the first element of the input.
- Parameters
-
x (Tensor) – The input tensor needed to be cummined. Alias:
input.axis (int, optional) – The dimension to accumulate along. -1 means the last dimension. The default (None) is to compute the cummin over the flattened array. Alias:
dim.dtype (str|paddle.dtype|np.dtype, optional) – The data type of the indices tensor, can be int32, int64. The default value is int64.
name (str|None, optional) – Name for the operation (optional, default is None). For more information, please refer to api_guide_Name.
- Keyword Arguments
-
out (tuple[Tensor, Tensor]|None, optional) – The output tuple of two tensors (values, indices). Default: None.
- Returns
-
values (Tensor), The result of cummin operation. The dtype of cummin result is same with input x.
indices (Tensor), The corresponding index results of cummin operation.
Examples
>>> import paddle >>> data = paddle.to_tensor([-1, 5, 0, -2, -3, 2]) >>> data = paddle.reshape(data, (2, 3)) >>> value, indices = paddle.cummin(data) >>> value Tensor(shape=[6], dtype=int64, place=Place(cpu), stop_gradient=True, [-1, -1, -1, -2, -3, -3]) >>> indices Tensor(shape=[6], dtype=int64, place=Place(cpu), stop_gradient=True, [0, 0, 0, 3, 4, 4]) >>> value, indices = paddle.cummin(data, axis=0) >>> value Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True, [[-1, 5, 0], [-2, -3, 0]]) >>> indices Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True, [[0, 0, 0], [1, 1, 0]]) >>> value, indices = paddle.cummin(data, axis=-1) >>> value Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True, [[-1, -1, -1], [-2, -3, -3]]) >>> indices Tensor(shape=[2, 3], dtype=int64, place=Place(cpu), stop_gradient=True, [[0, 0, 0], [0, 1, 1]]) >>> value, indices = paddle.cummin(data, dtype='int64') >>> assert indices.dtype == paddle.int64
