By default pytorch encodes images as [batch_size, channels, height, width] tensors. I want to build a network that upsamples [b, c, h, w] image to [b, c, 2*h, 2*w]. The way I implement this is by first producing [b, 4*c, h, w] and then I want to reshape it to [b, c, 2*h, 2*w] in such a way that each 4*c-channel pixel becomes 4 neighbouring c-channel pixels such that the neighbours form a small square rather than a line of 4 pixels. Unfortunately the reshape() function arranges the neighbours into a line.