We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Reductions and dim
PyTorchReduce tensors along selected dimensions and use keepdim to preserve axes. Handle dtypes, numerical accuracy and ties when choosing reduction operations.
7 exercises
Explore freely. Sign in to keep your progress.
Your learning sequence
- 1 Not solved yet. Find the predicted class for each row Practice · Easy
- 2 Not solved yet. Accuracy from a comparison Practice · Easy
- 3 Not solved yet. Softmax from the definition Practice · Medium
- 4 Not solved yet. Compute row means while ignoring NaNs Practice · Easy
- 5 Not solved yet. Per-channel statistics Practice · Medium
- 6 Not solved yet. Sum float32 values using float64 accumulation Practice · Medium
- 7 Not solved yet. Running totals Practice · Easy
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.
Which shapes do these two reductions produce?
Choose one answer to reveal the explanations. Answers are kept only while this page is open.
import torch
x = torch.arange(12).reshape(3, 4)
print(x.sum(dim=0).shape)
print(x.sum(dim=0, keepdim=True).shape)