Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PyTorch torch.cummin function

PyTorch torch.cummin function


PyTorch torch reference manual PyTorch torch reference manual

torch.cummin is a PyTorch function for computing the cumulative minimum. It returns the cumulative minimum along a specified dimension together with the corresponding indices.

Function definition

torch.cummin(input, dim, dtype=None)


Usage examples

Example

import

torch

Compute the cumulative minimum

x

=

torch.

tensor

(

[

3

,

1

,

4

,

1

,

5

,

9

,

2

,

6

]

)

values

,

indices

=

torch.

cummin

(

x

,

dim

=

0

)

print

(

"Input:"

,

x

)

print

(

"Cumulative minimum:"

,

values

)

print

(

"Minimum value indices:"

,

indices

)

2D tensor

x

=

torch.

tensor

(

[

[

3

,

1

,

4

]

,

[

1

,

5

,

9

]

,

[

2

,

6

,

5

]

]

,

dtype

=

torch.

float32

)

Cumulative by column

values_col

,

indices_col

=

torch.

cummin

(

x

,

dim

=

0

)

print

(

"nCumulative by column:"

)

print

(

"Cumulative minimum:"

)

print

(

values_col

)

print

(

"Indices:"

)

print

(

indices_col

)

Cumulative by row

values_row

,

indices_row

=

torch.

cummin

(

x

,

dim

=

1

)

print

(

"nCumulative by row:"

)

print

(

"Cumulative minimum:"

)

print

(

values_row

)


PyTorch torch reference manual PyTorch torch reference manual