Recall & Review
beginner
What is a data transform in PyTorch?
A data transform is a function or operation applied to data samples to change or prepare them before feeding into a model. It can include resizing images, normalizing values, or converting data types.
Click to reveal answer
beginner
Why do we normalize images in data transforms?
Normalization scales image pixel values to a standard range, often zero mean and unit variance. This helps the model learn better and faster by keeping input values consistent.
Click to reveal answer
intermediate
How does the Compose transform work in PyTorch?
Compose chains multiple transforms together. It applies each transform in order to the data sample, making it easy to combine steps like resizing, cropping, and normalizing.
Click to reveal answer
beginner
What is the purpose of ToTensor transform?
ToTensor converts images or data from PIL Image or numpy arrays into PyTorch tensors. It also scales pixel values from 0-255 integers to 0-1 floats.
Click to reveal answer
intermediate
Give an example of a common data transform pipeline for image classification.
A typical pipeline: Resize image to fixed size, convert to tensor, normalize with mean and std. For example: Compose([Resize(256), CenterCrop(224), ToTensor(), Normalize(mean, std)]).
Click to reveal answer
What does the Normalize transform do in PyTorch?
✗ Incorrect
Normalize adjusts data values to have a mean of zero and a standard deviation of one, helping model training.
Which transform converts a PIL image to a PyTorch tensor?
✗ Incorrect
ToTensor converts images from PIL or numpy format into PyTorch tensors.
What is the main use of Compose in data transforms?
✗ Incorrect
Compose allows applying several transforms in sequence to data samples.
Why do we resize images in data transforms?
✗ Incorrect
Models require inputs of fixed size, so resizing ensures consistency.
Which transform would you use to randomly flip images horizontally?
✗ Incorrect
RandomHorizontalFlip randomly flips images left to right to augment data.
Explain the role of data transforms in preparing images for a PyTorch model.
Think about steps to make images ready and consistent for training.
You got /4 concepts.
Describe how you would create a data transform pipeline for training an image classifier.
Consider both preparing and augmenting images.
You got /4 concepts.