Skip to content
← All PyTorch tracks

Tensor Foundations

PyTorch

The basics of working with tensors — shapes, indexing, broadcasting, and the operations you'll reach for daily.

7 exercises

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Not solved yet. Create a Tensor from a List Practice · Easy
  2. 2 Not solved yet. Reshape a Tensor Practice · Easy
  3. 3 Not solved yet. Transpose a Matrix Practice · Easy
  4. 4 Not solved yet. Broadcasting Addition Practice · Easy
  5. 5 Not solved yet. Tensor Indexing and Slicing Practice · Easy
  6. 6 Not solved yet. Masked Fill Practice · Medium
  7. 7 Not solved yet. Concatenate Tensors Practice · Easy

Check yourself

4 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 4 correct

With deterministic filling disabled, what can you assume about x before fill_ runs?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

import torch

torch.use_deterministic_algorithms(False)
x = torch.empty(3)
# Initialize every element before reading its value.
x.fill_(2.0)
print(x.tolist())
print(torch.zeros(3).tolist())
Question 1 of 4