Index Ai Academy
Phase 4 · Deep learning · Tooling

PyTorch tensors

NumPy-like arrays that run on GPUs.

About 30 minutes · Free account required

Open this lesson Create a free account

Why it matters

PyTorch is the library most deep learning is written in, including most open LLMs and the code behind fine-tuning tools. Its core object, the tensor, is a NumPy array with two extra powers: it can live on a GPU, and it can track gradients. You already know arrays, so this lesson is mostly translation, plus the habits (shapes, dtypes, devices) that every PyTorch bug report starts with.

What you'll be able to do

  • Create PyTorch tensors and read their shape, dtype and device
  • Translate NumPy habits to PyTorch: operations, broadcasting, indexing, dim vs axis
  • Reshape tensors with view, reshape, transpose and unsqueeze
  • Explain what moving a tensor to a GPU means, and why dtypes matter there

Before this lesson

Next in this phase: PyTorch autograd and modules