torchvision transforms

Solutions on MaxInterview for torchvision transforms by the best coders in the world

showing results for - "torchvision transforms"
Hannah
06 Jul 2018
1from torchvision import transforms as transforms
2transform = transforms.Compose([
3    transforms.RandomCrop(32, padding=4),  #先四周填充0,在把图像随机裁剪成32*32
4    transforms.RandomHorizontalFlip(),  #图像一半的概率翻转,一半的概率不翻转
5    transforms.RandomRotation((-45,45)), #随机旋转
6    transforms.ToTensor(),
7    transforms.Normalize((0.4914, 0.4822, 0.4465), (0.229, 0.224, 0.225)), #R,G,B每层的归一化用到的均值和方差
8])
9