Complete the code to import the CIFAR10 dataset from torchvision.datasets.
from torchvision.datasets import [1]
The CIFAR10 dataset is imported from torchvision.datasets using from torchvision.datasets import CIFAR10.
Complete the code to download the CIFAR10 training dataset with transforms.
train_dataset = CIFAR10(root='./data', train=[1], download=True, transform=None)
Setting train=True loads the training split of CIFAR10.
Fix the error in the code to apply a ToTensor transform to the CIFAR10 dataset.
from torchvision.transforms import [1] train_dataset = CIFAR10(root='./data', train=True, download=True, transform=ToTensor())
The ToTensor transform converts images to PyTorch tensors and must be imported from torchvision.transforms.
Fill both blanks to create a DataLoader for the training dataset with batch size 32 and shuffling enabled.
from torch.utils.data import DataLoader train_loader = DataLoader(train_dataset, batch_size=[1], shuffle=[2])
Batch size 32 and shuffle=True are common settings for training data loaders.
Fill all three blanks to create a dictionary comprehension that maps class indices to class names from CIFAR10.
class_to_name = [1]: [2] for [3] in range(len(train_dataset.classes))}
This dictionary comprehension uses the index i to map to the class name at train_dataset.classes[i].