About the MaxUnpool partial inverse property

I have a question regarding the class torch.nn.MaxUnpool2d. In the docs it says that it is a partial inverse of torch.nn.MaxPool2d. Moreover, “MaxPool2d is not fully invertible, since the non-maximal values are lost.” So this fact is clear to me, but I had a problem with the following example:

-1 -1

-2 -3

MaxPool2d with 2x2 kernel size would return -1 but MaxUnpool2d of -1 would be

-1 0

0 0.

Now MaxPool2d of this would return 0, which is somehow inconsistent.

This means that “invertibility” restricts to the cases where pooling blocks are not completely negative. Maybe you can mention this in the docs, as it reads that the only problem is that some values are lost.

Another suggestion would be to change the MaxUnpool2d to a right inverse function of MaxPool2d (maybe somehow more natural), i.e.

MaxPool2d(MaxUnpool2d(y)) = y for all input y and not only y with positive value.