Complete the code to import the AutoAugment policy from torchvision.
from torchvision.transforms import [1]
The AutoAugment class is imported from torchvision.transforms to apply augmentation policies automatically.
Complete the code to create an AutoAugment transform with the CIFAR10 policy.
transform = AutoAugment(policy=[1])The CIFAR10 policy is used here to apply augmentation suitable for CIFAR10 images.
Fix the error in applying AutoAugment transform to the dataset.
dataset = datasets.CIFAR10(root='./data', train=True, download=True, transform=[1])
The transform argument expects a callable transform object, so AutoAugment() must be instantiated.
Fill both blanks to create a composed transform with AutoAugment and normalization.
transform = transforms.Compose([
AutoAugment(policy=[1]),
transforms.Normalize(mean=[2], std=[0.247, 0.243, 0.261])
])The CIFAR10 policy is used for AutoAugment, and the mean values correspond to CIFAR10 dataset normalization.
Fill all three blanks to define a training loop that applies AutoAugment and computes accuracy.
for images, labels in dataloader: images = images.to(device) labels = labels.to(device) outputs = model([1]) loss = criterion(outputs, labels) optimizer.zero_grad() loss.backward() optimizer.step() _, predicted = outputs.[2](1) correct += (predicted == labels).[3]().item()
The model input is images. The max function returns max values and indices, and sum counts correct predictions.