I was trying to use “MaxPool2d” and “MaxUnpool2d” in encoder and decoder, but the output of MaxUnpool2d is not making sense.
the following is the code
maxpool = nn.MaxPool2d(kernel_size=3, stride=2, ceil_mode=True, return_indices=True)
maxunpool = nn.MaxUnpool2d(kernel_size=3, stride=2)
x = Variable(torch.rand(1,1,4,4).type(torch.FloatTensor))
y, ind = maxpool(x)
z = maxunpool(y, ind)
print(x)
print(y)
print(z)
and output is
(‘x’, Variable containing:
(0 ,0 ,.,.) =
0.3408 0.3246 0.5888 0.9761
0.0153 0.2923 0.7274 0.3501
0.7108 0.1856 0.2272 0.2173
0.3640 0.3814 0.9054 0.9198
[torch.FloatTensor of size 1x1x4x4]
)
(‘y’, Variable containing:
(0 ,0 ,.,.) =
0.7274 0.9761
0.9054 0.9198
[torch.FloatTensor of size 1x1x2x2]
)
(‘z’, Variable containing:
(0 ,0 ,.,.) =
0.0000 0.0000 0.0000 0.9761 0.0000
0.0000 0.7274 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.9054
0.9198 0.0000 0.0000 0.0000 0.0000
0.0000 0.0000 0.0000 0.0000 0.0000
[torch.FloatTensor of size 1x1x5x5]
)
am I missing something or is there some implementation mistake…