As explained in the docs for MaxUnpool
, the when doing MaxPooling, there might be some pixels that get rounded up due to integer division on the input size. For example, if your image has size 5, and your stride is 2, the output size can be either 2 or 3, and you can’t retrieve the original size of the image.
That’s why there is an optional argument to MaxUnpool that allows you to specify the desired output size. In your case, it should be something like
output3 = unpool1(output2, indices2, output_size=output1.size())
output4 = unpool2(output3, indices1, output_size=input.size())