📘
Create a DataLoader
EasyPyTorch Datasets
Problem Statement
Create a DataLoader to batch a dataset.
Background
DataLoader wraps a Dataset and provides automatic batching, shuffling, and parallel loading — the standard way to feed data into a training loop.
Your Task
Write a function create_dataloader(dataset, batch_size) that returns a DataLoader for the given dataset with the specified batch size (no shuffling).
Output Format
Return a DataLoader object.
Example:
Input:
dataset (6 samples), batch_size=2, shuffle=False
Output:
DataLoader with 3 batches
Reasoning:
DataLoader automatically handles batching - 6 samples with batch_size=2 gives 3 batches
Constraints:
- Use torch.utils.data.DataLoader
- batch_size will be a positive integer
- shuffle will be a boolean
Editor
Python 3.13.1
Test Results
0/0Run code to see test results.