This is probably very basic, but i have the following issue… i have an rgb image read as a tensor (torchvision.io.read_image) with the shape (c,rows,columns). Now, i’m trying to reshape it into a (rows x columns,3) array which contains in each row the 3 channel values (the rgb color), but i haven’t been able to figure out a way to tell reshape() to read the values iterating over the channel dimension first. When i use img.reshape((4140*2647,3)), the order for reading the values is row-wise.
I still think you might(!) need to swap the dimensions first since you c dimensions is the first in the input and the last in the output. Sure, you can reshape it immediately, but you might mess up your data semantically (see here)
I would have no doubt that your solution is perfectly fine, I honestly can’t tell from just look at the line. I’m just wondering if something like this
X = X.permute(1, 2, 0)
X = X.reshape(-1, 3) # not 100% sure if correct