Check the updated Imagenet main.py here

  
      github.com
  
  
    pytorch/examples/blob/master/imagenet/main.py 93
import argparse
import os
import shutil
import time

import torch
import torch.nn as nn
import torch.nn.parallel
import torch.backends.cudnn as cudnn
import torch.distributed as dist
import torch.optim
import torch.utils.data
import torch.utils.data.distributed
import torchvision.transforms as transforms
import torchvision.datasets as datasets
import torchvision.models as models

model_names = sorted(name for name in models.__dict__
    if name.islower() and not name.startswith("__")
    and callable(models.__dict__[name]))


  This file has been truncated. show original

  
  
    
    
  
  


    val_loader = torch.utils.data.DataLoader(
        datasets.ImageFolder(valdir, transforms.Compose([
            transforms.Resize(256),
            transforms.CenterCrop(224),
            transforms.ToTensor(),
            normalize,
        ])),

Here it’s doing the central crop instead of a random crop as in the code you posted.
However, If you want to control better the cropping, you can do your custom transformation as in here:
http://pytorch.org/tutorials/beginner/data_loading_tutorial.html#transforms 71