I am studying the documentation at https://pytorch.org/docs/stable/generated/torch.nn.MaxPool2d.html.
In the parameters section, it states
return_indices – if True, will return the max indices along with the outputs. Useful for torch.nn.MaxUnpool2d later
Could someone explain to me what max indices mean here? I believe it is the indices corresponding to the maximal value. If the maximal value is unique, does that mean only 1 index will be returned?
I assume you already know how max pooling works. Then, let's print some results to get more insights.
output
output
output
If you
stretchthe input tensor and make it 1d, you can see thatindicescontains the positions of each1value (the maximum for each window of MaxPool2d). As written in the documentation oftorch.nn.MaxPool2d,indicesis required for thetorch.nn.MaxUnpool2dmodule: