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 you organize data and labels so you can easily use them for training models.Click to reveal answer
beginner
Which two methods must you always define in a PyTorch Custom Dataset class?
You must define
__len__ to return the number of samples, and __getitem__ to get a single 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 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 add data transformations inside a Custom Dataset?
Transformations like resizing or normalizing images help prepare data in a consistent way before training. Adding them inside the Dataset keeps data ready and clean.
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 faster and easier.
Click to reveal answer
Which method in a Custom Dataset returns the total number of samples?
✗ Incorrect
The __len__ method returns how many samples the dataset contains.
What does the __getitem__ method return?
✗ Incorrect
The __getitem__ method returns one data sample and its label by index.
Why add transformations inside a Custom Dataset?
✗ Incorrect
Transformations prepare data in a consistent way, like resizing or normalizing.
What does a DataLoader do when used with a Custom Dataset?
✗ Incorrect
DataLoader helps by batching, shuffling, and loading data in parallel.
Which PyTorch class do you inherit from to create a Custom Dataset?
✗ Incorrect
You inherit from torch.utils.data.Dataset to create a Custom Dataset.
Explain how to create a Custom Dataset class in PyTorch and why it is useful.
Think about the two main methods and the purpose of the class.
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.