Start studying
Module 2 · Deep Learning Module contents
Module 2  ·  Card 23 / 25intermediate

PyTorch

PyTorch is the dominant framework for deep learning research and increasingly for production.

Its central object is the tensor, a multi-dimensional array that can live on a GPU.

Autograd tracks operations and computes gradients for you automatically.

You define models as classes with a forward method describing the computation.

The training loop is written explicitly, which makes debugging straightforward.

Learn in depth ↓
Module 02 · Deep Learning · 25 concepts
In depth  /  15 lines

PyTorch, in more detail

PyTorch is the framework most research and an increasing share of production runs on.

Its basic object is the tensor, an array of numbers that can sit on a GPU.

Tensors behave much like NumPy arrays, with the same slicing and broadcasting.

Moving one onto the device with a single call is what buys the parallel hardware.

Autograd records every operation performed on a tensor that requires gradients.

That record is a graph, built fresh on each forward pass and thrown away after the backward one.

Building it on the fly is what makes ordinary control flow work inside a model.

You can put an if statement in a model and it simply behaves as written.

Models are classes holding layers, with a forward method describing the computation.

The training loop is yours to write: zero the gradients, forward, loss, backward, step.

Forgetting to zero the gradients makes them accumulate, which is a rite of passage bug.

Because the loop is explicit you can print or break anywhere inside it.

That debuggability is most of why it won research against the graph-first frameworks.

The ecosystem around it matters as much as the library, from Hugging Face to Lightning.

TensorFlow remains capable and deployed, but new work overwhelmingly starts here.

Want the full technical article? Wikipedia ↗
Test yourself

One question on this card. Every option explains itself once you pick, right or wrong.

Question 1
What does autograd do for you?
Deep Learning

25 concepts in this module, then a graded test with every answer explained.

Study this module →
↑↓ move↵ openesc close