
Ĭontiguous here mens 1-2, 2-3 even 1-2-3, but not 1-3 for example. If you want to reshape the ordering only remains for contiguous dimensions. You achieve what you want which is all the colums of image 1, all the colums of image 2 However if u properly order the dimensions So it takes the information of the image1, colum 1, then image2, colum 1 and so on. Here you are filling taking the info of one image and then the other because u set N at the right.

If you permute and set dimensions before reshaping If u pay attention it 's resized to be fit in the desired shape What’s going on there? as you are reordering it’s getting the information in the original order which is, all colums of image 1, all rows of image 1, all colums of image 2, all rows of image 2 and so on. If you just reshape you get a wrong ordering The cat cropped looks like that (that’s grayscale) I’m converting RGB images to gray and croping to have same size Im2 = np.mean(skio.imread('/home/jfm/Downloads/cat.jpg'),axis=2) Im1 = np.mean(skio.imread('/home/jfm/Downloads/dog.jpg'),axis=2)

So lets see what happens if you reshape vs permute + reshape vs permute without paying attention
#Matlabe permute how to
So an example about how to apply view could be the following oneĪnd these tensor contains B batches of N images whose size is HxW and you want to make a montage of these images in a single one concatanating in the colums your outgoing dimension would be That’s why this operation is different from 0 It takes numbers until it fills the dimensions. On the other hand, if you reshape you can see you are modifying the ordering because this is not rotating the cube but mapping in an ordered way from right to left. You are just rotating the tensor, but order is preserved
