There are several bugs in these lines https://github.com/pytorch/examples/blob/master/imagenet/transforms.py#L48 - h and w are integers in python and should be casted to float before division - should be self.size instead of w as in https://github.com/facebook/fb.resnet.torch/blob/master/datasets/transforms.lua#L45 (I only tested this class, was doing some visualizations)