PIXELBANKv9.1.0
Menu

Create a DataLoader

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 locked

The code editor is locked for Pro problems. It is only available for free problems. Please upgrade to gain access to the code editor for all problems.

solution.py

Test Results

0/0
Run code to see test results.
Create a DataLoader - Easy | PixelBank