'combine dimensions without distortion pytorch images

I have pytorch tensor shape like [ shapes,images,H,W,C]

its like that " for each shape I have 12 Images" . I want to reshape it like [shapes*images,H,W,C] (stack all images together) while keeping images without distortion.

when I do

img=img.contiguous()
shape, images, H, W, c = img.shape
img = img.view((shape * images, W, H,c))

the image corrupted.

how to preserve the images?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source