Complete the code to import the PyTorch image dataset loader.
from torchvision.datasets import [1]
The ImageFolder class loads images from folders arranged by class.
Complete the code to create an ImageFolder dataset from the 'data/train' folder.
dataset = ImageFolder(root='[1]')
The root parameter should point to the folder containing class subfolders, here 'data/train'.
Fix the error in the code to apply transforms to the ImageFolder dataset.
from torchvision import transforms transform = transforms.Compose([transforms.Resize(256), transforms.CenterCrop(224), transforms.ToTensor()]) dataset = ImageFolder(root='data/train', [1]=transform)
The correct argument name is transform to apply transformations to the dataset.
Fill both blanks to create a DataLoader for the dataset with batch size 32 and shuffling enabled.
from torch.utils.data import [1] dataloader = [2](dataset, batch_size=32, shuffle=True)
The DataLoader class is imported and used to create batches and shuffle the dataset.
Fill all three blanks to print the class names from the ImageFolder dataset.
class_names = dataset.[1] for i, class_name in enumerate(class_names): print(f"Class [2]: [3]")
The classes attribute holds class names. The loop prints index i and name class_name.