Shape of input must match shape of indices

How to fix this error:

RuntimeError: Shape of input must match shape of indices

in max_unpool2d

return torch._C._nn.max_unpool2d(input, indices, output_size)

when I’m trying to do unpooling on different size layer

As the error states the shape of the input and indices tensor have to match, which doesn’t seem to be the case in your script. Check the shapes via print(input.shape) and print(indices.shape) and make sure they are equal.