Deep Learning with PyTorch: From Tensors to Transfer Learning

Deep Learning with PyTorch is an advanced-level course of 5 lessons (about 3 h 58 min), with 15 exercises and 15 quiz questions. Prerequisites: Model Evaluation and Validation. The course needs a full project environment, planned for a later phase of the platform.

  • Data science
  • Advanced
  • 5 lessons
  • 3 h 58 min
  • 15 exercises
  • Full project environment (phase 2)

The course in brief

This course takes you from classical machine learning to neural networks with PyTorch. You will understand tensors and backpropagation, write your own models and training loops, learn to avoid overfitting, then use pre-trained convolutional networks for vision.

What you will be able to do

  • Manipulate PyTorch tensors and compute gradients with autograd
  • Define a neural network with nn.Module and check its dimensions and parameters
  • Write a complete training and evaluation loop with DataLoader, loss, and optimizer
  • Diagnose overfitting and apply dropout, weight decay, normalization, and early stopping
  • Build a CNN and adapt a pre-trained model through transfer learning
  • Save, reload, and make a training run reproducible

Syllabus: 5 lessons

    • Create and manipulate PyTorch tensors (shape, type, device)
    • Understand the computation graph and compute gradients with autograd
    • Check a gradient with finite differences

    TensorAutogradGradient

  1. 02

    Build a Neural Network with nn.Module

    15 min
    • Describe a multilayer perceptron: linear layers and activation functions
    • Define a PyTorch model by inheriting from nn.Module
    • Count parameters and check output shapes

    Multilayer perceptronActivation functionsnn.Module

  2. 03

    The Training Loop: Loss, Optimizer, DataLoader

    20 min
    • Write a complete training and evaluation loop
    • Choose a suitable loss function and optimizer
    • Feed the model with mini-batches using Dataset and DataLoader

    Loss functionOptimizer (SGD, Adam)Dataset and DataLoaderTraining loop

  3. 04

    Generalize: Overfitting and Regularization

    18 min
    • Diagnose underfitting and overfitting from the curves
    • Apply dropout, weight decay, data augmentation, and normalization
    • Set up early stopping with saving of the best model

    OverfittingDropoutWeight decayEarly stoppingNormalization (BatchNorm, LayerNorm)

  4. 05

    Convolutional Networks and Transfer Learning

    20 min
    • Understand convolution, padding, stride, and pooling
    • Build a small CNN and compute the size of its outputs
    • Reuse a pre-trained model (transfer learning, fine-tuning)

    ConvolutionConvolutional networkTransfer learning

Final project

End-to-End Image Classifier with PyTorch

Build an image classifier with 3 to 5 classes (for example a subset of CIFAR-10 or your own product photos). Compare a small CNN trained from scratch with a fine-tuned pre-trained model, and deliver a saved model ready to be deployed.

Deliverables

  • A Dataset and DataLoaders with augmentation for training and simple preprocessing for validation
  • A small CNN defined with nn.Module and a fine-tuned pre-trained model (head replaced, then partial unfreezing)
  • A training loop with loss tracking, early stopping, and saving of the best state_dict
  • The learning curves and a confusion matrix on the test set
  • A predict.py script that reloads the weights and classifies an image passed as an argument

Assessment criteria

  • Correct training loop (order of steps, train/eval modes, no_grad in evaluation)
  • Strict separation of training / validation / test and no leakage
  • Reasoned comparison of the two approaches with figures
  • Reproducibility: seeds set, versions noted, reloadable weights
  • Code quality and readability

Frequently asked questions

Do I need a GPU to take this deep learning course?

No. The exercises are sized to run on CPU. A GPU only speeds up the fine-tuning task in the last lesson; the code automatically detects the available device.

Why learn PyTorch rather than another framework?

PyTorch is the reference framework in both research and industry, and the foundation of the Hugging Face ecosystem. Its explicit training loop also helps you understand what is really going on.

What knowledge is needed before starting?

Python, numpy, and the basics of machine learning: training and validation sets, metrics, overfitting. The DS4 course on model evaluation is the recommended prerequisite.

Does this course prepare for LLMs and NLP?

Yes. Tensors, nn.Module, the training loop, LayerNorm, and fine-tuning are the foundations of the following course on natural language processing and large language models.

This course, told for your job

Say what you want to be able to do: “Deep Learning with PyTorch” takes its place in your path, with examples from your field. The concepts stay those of the course.

The preview is free, and you can take the courses one at a time without paying. The path only contains lessons from the catalogue.