Recall & Review
beginner
What is the purpose of creating a custom Dataset class in PyTorch?A custom Dataset class lets you load and prepare your own data in a way PyTorch understands. It helps organize data loading, transformation, and access for training models.Click to reveal answer
beginner
Which two methods must you implement when creating a custom Dataset class in PyTorch?You must implement
__len__ to return the size of the dataset and __getitem__ to get one data sample by index.Click to reveal answer
beginner
How does the
__getitem__ method work in a custom Dataset?It takes an index number and returns the data sample (like an image and label) at that position. This allows PyTorch to get data one piece at a time during training.
Click to reveal answer
intermediate
Why might you want to apply transformations inside a custom Dataset?
Applying transformations (like resizing or normalization) inside the Dataset ensures data is prepared consistently every time it is loaded, making training smoother and more reliable.
Click to reveal answer
intermediate
What is the benefit of using a custom Dataset with a DataLoader in PyTorch?
The DataLoader can automatically handle batching, shuffling, and parallel loading of data from your custom Dataset, making training efficient and easy.
Click to reveal answer
Which method in a custom Dataset returns the total number of samples?
✗ Incorrect
The __len__ method returns the size of the dataset.
What should __getitem__ return in a custom Dataset?
✗ Incorrect
__getitem__ returns one data sample at the given index.
Why use transformations inside a custom Dataset?
✗ Incorrect
Transformations prepare data (like resizing or normalizing) consistently each time it is loaded.
Which PyTorch class helps load data in batches from a Dataset?
✗ Incorrect
DataLoader loads data in batches and can shuffle or load in parallel.
What is the base class you inherit from to create a custom Dataset?
✗ Incorrect
Custom datasets inherit from torch.utils.data.Dataset.
Explain how to create a custom Dataset class in PyTorch and why it is useful.
Think about the two key methods and the role of the Dataset.
You got /5 concepts.
Describe how transformations can be integrated into a custom Dataset and their benefits.
Consider what happens to data before it is returned.
You got /4 concepts.