Complete the code to import the torchvision transforms module.
from torchvision import [1]
The transforms module in torchvision provides common image transformations used for data augmentation.
Complete the code to create a transform that randomly flips images horizontally.
transform = transforms.[1](p=0.5)
RandomHorizontalFlip randomly flips the image horizontally with a given probability p.
Fix the error in the transform pipeline to convert images to tensor after resizing.
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.[1](),
])ToTensor converts a PIL image or numpy array to a PyTorch tensor, which is needed after resizing.
Fill both blanks to create a transform pipeline that randomly crops and then normalizes images.
transform = transforms.Compose([
transforms.[1](size=100),
transforms.ToTensor(),
transforms.[2](mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
])RandomCrop crops the image randomly to the given size. Normalize adjusts pixel values to have the specified mean and standard deviation.
Fill all three blanks to create a transform pipeline that resizes, converts to tensor, and applies random rotation.
transform = transforms.Compose([
transforms.[1]((64, 64)),
transforms.[2](),
transforms.[3](degrees=30)
])The pipeline first Resizes images to 64x64 pixels, then converts them to tensors with ToTensor, and finally applies a random rotation up to 30 degrees with RandomRotation.