Horizontal compression and vertical elongation as Data Augmentation

Reading Yann LeCun’s report “Gradient-based learning applied to document recogniition” i saw he used a couple of data augmentation techniques on the MNIST dataset, including squeezing (“simultaneous horizontal compression and vertical elongation, or the reverse”). I would like to implement squeezing as data augmentation in my own PyTorch project, however I can’t seem to find a proper way to do it. I have been searching around but haven’t found anything useful.

Anyone who knows how to implement squeezing in pytorch, either with the pre-built torchvision transformations or as a custom transformation?

Hi Elias!

I think that torchvision.transforms.Resize will do what you want. If you
want the shape of your squeezed image to be the same as the shape
of the untransformed image, you will have to pad and crop the result
of Resize.


K. Frank

Tanks a lot KFrank!

I will definitely try that out and let everybody know if it works.

Kind Regards,