[Solved] Visualizing Images Augmented by ToTensor()

Hello! Thanks for dropping by.

I have a quick question about images that are processed by ToTensor() - I’ve simply swapped the dimensions from a channel leading configuration to the standard HxWxC configuration and visualize them with matplotlib.


The original image is simply a full scale image of a single grid; e.g. an image of a single car. The only other transformation applied before is normalization. I have isolated each transformation individually, and it seems that ToTensor() is the cause.

The outputs seem to be these 3x3 images, which are not I have expected. Is this the way its supposed to be and I have simply missed out something about the nature of the transformation, or have I gotten something catastrophically wrong?

Thank you for reading :grinning:

Are you using reshape or view to swap the axes?
If so, try to use permute, since view/reshape might yield these interleaved outputs.

1 Like

Ah yes, problem solved, I was using view indeed.

Thank you very much :slight_smile:

1 Like