We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Batching and the Data Path
PyTorchAssemble batches with stack, cat, padding and masks. Write collation logic and make shuffling reproducible while preserving the intended shapes.
5 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Adding an axis, or extending one Practice · Easy
- 2 Not solved yet. Pad, and then say where you padded Practice · Medium
- 3 Not solved yet. Weight batch losses by the number of examples Practice · Medium
- 4 Not solved yet. Split without copying Practice · Easy
- 5 Not solved yet. Shuffle the same way twice Practice · Medium
Check yourself
4 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
What does setting num_workers=2 change in this DataLoader?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
from torch.utils.data import DataLoader
# Run as a script; the guard supports platforms that spawn worker processes.
if __name__ == "__main__":
loader = DataLoader(list(range(6)), batch_size=2, num_workers=2)
print([batch.tolist() for batch in loader])