Robotics
← Roadmap/Learning

Deep Learning (PyTorch)

CNNs, transformers, training — modern perception & policies.

Progress0/15 questions

Prerequisites

Why it matters in robotics

Modern robotics perception (object detection, segmentation, depth) and learned policies (imitation and RL, visuomotor and language-conditioned control) are built on layered neural networks trained on large datasets. The training loop — forward pass, loss, backpropagation, optimizer step — together with the failure modes of divergence and overfitting, and how these networks learn to extract spatial and sequential structure directly from images and sequences, are what make these models work. Deep learning is now the default toolkit for perception and, increasingly, for control.

What to study

  • CNN building blocks: convolution, pooling, receptive fields, and classic backbones (ResNet) for perception
  • Transformers and self-attention: Q/K/V, multi-head attention, positional encodings; intuition for ViT and policy transformers
  • The training loop and optimization: autograd, loss functions, SGD/Adam, learning-rate schedules, batch norm
  • Generalization and debugging: overfitting vs underfitting, regularization, data augmentation, and transfer learning / fine-tuning

Where to study

Cheatsheet

Symbols used below

WWlayer weights
KKconvolution kernel size
SSstride
PPpadding
Q,Ka,VQ, K_a, Vquery, key, value projections in attention
dkd_kdimension of the key/query vectors
η\etalearning rate

Conv output size

For an input of width WW, kernel size KK, stride SS, padding PP:

out=WK+2PS+1\text{out} = \dfrac{W - K + 2P}{S} + 1

Stacking layers grows the receptive field, letting deeper layers respond to larger regions of the input image.

Scaled dot-product attention

Attention(Q,Ka,V)=softmax(QKadk)V\text{Attention}(Q,K_a,V) = \text{softmax}\left(\dfrac{Q K_a^\top}{\sqrt{d_k}}\right) V

Each output position is a weighted average of value vectors, with weights set by query-key similarity. The dk\sqrt{d_k} scaling keeps dot products from growing too large and saturating the softmax. Multi-head attention runs several of these in parallel subspaces and concatenates the results.

Training loop

Forward pass computes predictions and loss; backpropagation applies the chain rule to get loss/W\partial \text{loss}/\partial W for every parameter; the optimizer (SGD, Adam) updates weights using those gradients and a learning rate η\eta.

Autograd handles the backward pass automatically by tracking the computation graph built during the forward pass.

Optimizers: SGD vs Adam

Plain SGD: WWηWlossW \leftarrow W - \eta \nabla_W \text{loss}, often with momentum to smooth out noisy gradients.

Adam adapts the effective step size per-parameter using running estimates of the gradient's mean and variance, which usually converges faster and needs less learning-rate tuning.

Generalization tools

Batch normalization rescales activations per mini-batch, stabilizing and speeding up training.

Data augmentation (crops, flips, color jitter) and dropout reduce overfitting by preventing the network from memorizing exact pixels or co-adapting units. Transfer learning fine-tunes a model pretrained on a large dataset, needing far less task-specific data.

Divergence and vanishing/exploding gradients

Very deep networks or too-high learning rates can make gradients blow up (loss goes to NaN) or shrink toward zero (early layers stop learning).

Residual (skip) connections, careful initialization, batch norm, and learning-rate warmup/schedules are the standard fixes.

input 5×53×3 kerneloutput 3×3stride 1, no padout = (W − K + 2P) / S + 1
A conv layer slides a K×K kernel over the input; with stride S and padding P the output side is (W − K + 2P)/S + 1.

Application focus

Select an application above.

Practice questions (15)