---
title: "Deep Learning from First Principles"
description: "Deep learning from first principles in 24 live 1-on-1 classes: build autograd, backprop, optimisers, CNNs, LSTMs and a GPT-style transformer from scratch."
slug: deep-learning-from-first-principles-course
canonical: https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/
category: "Advanced AI & Research"
keywords: ["deep learning from first principles", "deep learning course from scratch", "build a neural network from scratch course", "backpropagation explained course", "autograd from scratch", "micrograd course", "build a transformer from scratch pytorch", "build gpt from scratch course", "pytorch deep learning course for engineers", "maths for deep learning course"]
---
# Deep Learning from First Principles

> Deep learning from first principles in 24 live 1-on-1 classes: build autograd, backprop, optimisers, CNNs, LSTMs and a GPT-style transformer from scratch.

**Level:** Advanced: college students, working engineers, graduate students and researchers comfortable in Python  
**Duration:** 24 live 1-on-1 classes, 1 hour each  
**Commitment:** 1 live hour per class plus 3 to 5 hours of implementation, derivation and reading between classes  
**Certification:** Certificate from Modern Age Coders, awarded on passing the final assessment  
**1-on-1:** ₹4,999/month

## At a glance

- **Who it is for:** Advanced: college students, working engineers, graduate students and researchers comfortable in Python.
- **Prerequisites:** Confident Python: functions, classes, lists and dictionaries, and reading other people's code. NumPy familiarity helps but is taught where needed. No prior PyTorch is required
- **Format:** Live, interactive classes with a real instructor, never pre-recorded videos. Live classes run about one hour.
- **Language:** English or Hindi, depending on the batch.
- **Duration:** 24 live 1-on-1 classes, 1 hour each
- **Weekly commitment:** 1 live hour per class plus 3 to 5 hours of implementation, derivation and reading between classes
- **Class size:** Taught 1-on-1 only: every class is a private session with your own mentor.
- **Price:** [See the fees and plans, shown in your currency.](https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/#enroll)
- **Certificate:** Certificate from Modern Age Coders, awarded on passing the final assessment
- **Watch first:** [Free recordings of real classes for ages 13 and up](https://modernagecoders.graphy.com/courses/How-We-Teach-The-Modern-Age-Coders-Methodology-6a1888029a4f81888c408ab9), free with a Google sign-in. These recordings show how we teach, not the exact syllabus of this course.
- **Live demo:** Optional. Enrol directly on this page, or [book a Priority Demo](https://learn.modernagecoders.com/book-demo): a full live class of about 45 to 60 minutes with a mentor reserved for you.
- **Questions:** [WhatsApp +91 91233 66161](https://wa.me/919123366161?text=Hi%2C%20I%20have%20a%20question%20about%20the%20Deep%20Learning%20from%20First%20Principles%20course%20before%20enrolling.) or email [connect@modernagecoders.com](mailto:connect@modernagecoders.com?subject=Question%20about%20Deep%20Learning%20from%20First%20Principles).

## Deep Learning from First Principles: Every Layer, Every Gradient, Implemented

*24 live 1-on-1 classes. Derive it, implement it, break it, fix it: from a hand-written autograd engine to a small GPT you pre-train yourself, with a dedicated mentor and the maths kept honest throughout.*

Most people who use deep learning have never written a backward pass. They can call model.fit or wire up a Hugging Face pipeline, but when a loss goes to NaN, a transformer refuses to learn, or a paper's equation does not match its code, they have nothing underneath to reason with. This course builds that floor. In 24 private one-hour classes you implement the field from the bottom up. You start with tensors and the linear algebra of a single layer, refresh exactly the calculus and probability you need, and write a scalar autograd engine by hand in the spirit of Andrej Karpathy's micrograd. You derive backpropagation in matrix form, check it numerically, then move to PyTorch knowing what loss.backward() is doing. The second phase is optimisation and generalisation: SGD, momentum, Adam and AdamW, learning-rate schedules, Glorot and He initialisation, batch and layer normalisation, residual connections, weight decay, dropout, double descent, and the practical discipline of debugging a training run that silently fails. The third phase builds the architectures: convolutions written as loops before they become library calls, RNNs and LSTMs trained with backpropagation through time, attention derived from the alignment problem it was invented to solve, and a decoder-only transformer written from an empty file, including a byte-pair tokenizer, which you then pre-train on a small corpus and sample from. The final phase looks at the science around the models: scaling laws you reproduce in miniature, variational autoencoders and denoising diffusion built from the DDPM paper, and the basics of interpretability, from probes and the logit lens to superposition and sparse autoencoders. It ends with a capstone on a question you choose, written up and defended live. Because every class is 1-on-1, the pace and depth follow you: a graduate student can push into the derivations their thesis needs, an engineer can tie each class to the models their team ships, and the GPU budget you actually have shapes every experiment.

**What Makes This Different:**

- Everything is implemented, nothing is only described: autograd, backprop, every optimiser, every normalisation layer, convolution, LSTM, attention, the transformer, a tokenizer and a diffusion sampler are written by you before the library version is allowed.
- Maths-honest without being a maths degree: linear algebra, matrix calculus and probability refreshers sit inside the classes that need them, and every derivation is checked against code with numerical gradient checks.
- 1-on-1 only, by design: your research question, your codebase, your GPU budget and your gaps decide where each class goes deeper. There are no group batches for this course.
- Grounded in the real literature: you read the key passages of the papers the ideas come from (Rumelhart, Hinton and Williams on backprop; Kingma and Ba on Adam; He et al. on ResNets; Vaswani et al. on the transformer; Kaplan et al. and Hoffmann et al. on scaling; Ho et al. on diffusion) and reproduce small results from them.
- Debugging as a taught skill: overfit-one-batch, activation and gradient statistics, learning-rate range tests and ablations are practised every phase, so you can tell a bug from a bad hyperparameter.
- Runs on modest hardware: every experiment is sized to a laptop CPU, Apple Silicon or a free cloud notebook GPU, and scaled up only if you have the compute and want to.

**Learning Path:**

- Phase 1, Foundations: Tensors, Calculus and Autograd (Classes 1-6): tensors and the linear algebra of a layer, derivatives and the chain rule on computation graphs, a hand-written autograd engine, matrix-form backpropagation with gradient checks, probability and loss functions, and the move to PyTorch with a first trained model.
- Phase 2, Optimisation, Initialisation and Generalisation (Classes 7-12): SGD and the loss landscape, momentum, Adam, AdamW and schedules, initialisation and signal propagation, normalisation and residual connections, regularisation and double descent, and a systematic method for debugging training.
- Phase 3, Architectures from Scratch: CNNs, RNNs, Attention and Transformers (Classes 13-18): convolution and ResNets, RNNs and LSTMs with backpropagation through time, attention derived from first principles, a transformer block from an empty file, a byte-pair tokenizer, and pre-training a small GPT-style model.
- Phase 4, Scale, Generative Models, Interpretability and Capstone (Classes 19-24): scaling laws reproduced in miniature, VAEs and denoising diffusion from the papers, interpretability basics from probes to sparse autoencoders, and a capstone experiment written up and defended live.

**Career Outcomes:**

- The ability to read a deep learning paper's equations and write the matching code, or spot where the code and the paper disagree
- A from-scratch portfolio: an autograd engine, a hand-built CNN and LSTM, a transformer language model with its own tokenizer, a DDPM sampler, and a capstone report
- The debugging instincts that separate people who train models from people who run notebooks: gradient statistics, ablations, sanity checks and honest baselines
- A solid base for graduate study, research assistant roles, ML engineering interviews that probe fundamentals, and the deeper engineering and research courses in this track
- Working fluency in PyTorch from the autograd level up, rather than from the high-level API down

## Phase 1: Foundations: Tensors, Calculus and Autograd

Build the floor everything else stands on: tensors and the linear algebra of a layer, the chain rule on computation graphs, a hand-written autograd engine, matrix-form backpropagation with gradient checks, probability and loss functions, and a clean PyTorch training loop.

### Week 1

#### Class 1: Tensors, Shapes and the Linear Algebra of a Layer

**Topics:**

- Scalars, vectors, matrices and tensors as data structures: shape, dtype, strides and why a reshape can be free while a transpose followed by view fails
- Broadcasting rules written out by hand, and the silent shape bugs they cause in real training code
- A linear layer as a matrix multiply plus bias: what each dimension means for a batch of inputs
- Dot products, norms and cosine similarity as the geometry behind every embedding and attention score
- Matrix rank, linear maps and why stacking linear layers without a nonlinearity collapses to one linear layer
- Nonlinearities (sigmoid, tanh, ReLU, GELU) and the change they make to what a network can represent
- Einsum notation as a precise language for tensor operations you will use for the rest of the course

**Projects:**

- Implement a two-layer network's forward pass in plain NumPy for a batch of inputs, with every intermediate shape asserted

**Practice:** Rewrite five tensor operations from a real model's forward pass in einsum and confirm the outputs match to floating-point tolerance.

**Assessment:** Shape drill: predict the output shape of ten broadcasting and matmul expressions on paper, then verify each in code.

### Week 2

#### Class 2: Calculus for Learning: Derivatives, the Chain Rule and Computation Graphs

**Topics:**

- Derivatives as local linear approximations, and the finite-difference estimate you will use as ground truth all course
- Partial derivatives, gradients and the direction of steepest ascent
- The chain rule on a computation graph: forward values, local derivatives and how gradients flow backwards and accumulate at shared nodes
- Forward-mode versus reverse-mode differentiation, and why reverse mode wins when there are many parameters and one scalar loss
- Jacobians and vector-Jacobian products: the object a backward pass really computes
- Numerical stability: catastrophic cancellation, overflow in exp, and choosing a finite-difference step size
- Drawing the graph for a small expression and computing every gradient by hand before touching code

**Projects:**

- Hand-derive and code the gradients of a small expression graph, then verify every one with central finite differences

**Practice:** Draw the computation graph for logistic regression on one example and compute all gradients by hand.

**Assessment:** Written check: derive the gradient of a composite function with a shared subexpression and explain why the two paths add.

### Week 3

#### Class 3: Build an Autograd Engine by Hand

**Topics:**

- A Value object that stores data, gradient, parents and a backward closure, in the style of Karpathy's micrograd
- Operator overloading for add, multiply, power, exp, tanh and ReLU, each with its local derivative
- Topological sort of the graph and the reverse pass that calls each node's backward exactly once
- Gradient accumulation with +=, and the bug you get if you assign instead
- Zeroing gradients between steps and why frameworks make you do it explicitly
- Building neurons, layers and an MLP on top of your engine and training it on a toy classification set
- Comparing your engine's gradients against PyTorch's on the same graph

**Projects:**

- Ship your own scalar autograd engine with a small MLP library on top, a test suite comparing every gradient to PyTorch, and a trained classifier

**Practice:** Add two new operations of your choice (for example log and sigmoid) to the engine with tests.

**Assessment:** Your mentor introduces three bugs into a copy of your engine; find and fix them using only gradient checks.

### Week 4

#### Class 4: Backpropagation in Matrix Form

**Topics:**

- Moving from scalars to tensors: matrix calculus for a linear layer, with the shapes that force the answer
- Backprop through ReLU, tanh and softmax, and the Jacobian structure of each
- The softmax plus cross-entropy gradient derived cleanly, and why fusing them is both faster and more stable
- Backprop for a full MLP written manually in NumPy, layer by layer
- Gradient checking at scale: relative error, which tolerance is suspicious, and checking a random subset of parameters
- Reading the 1986 paper by Rumelhart, Hinton and Williams, "Learning representations by back-propagating errors", and mapping its notation to yours
- Memory cost of backprop: which activations must be stored and why training uses far more memory than inference

**Projects:**

- Implement forward and backward for a multi-layer perceptron in pure NumPy, train it on MNIST, and pass a full gradient check

**Practice:** Derive the backward pass for a layer you have not seen (for example a bilinear layer) and verify it numerically.

**Assessment:** Live derivation: on a shared whiteboard, derive dL/dW for a two-layer network with softmax output, then explain each shape.

### Week 5

#### Class 5: Probability, Likelihood and Loss Functions

**Topics:**

- Random variables, expectations and variance: the minimum needed to reason about stochastic gradients
- Maximum likelihood estimation and how mean squared error and cross-entropy both fall out of it
- Softmax as a distribution over classes, logits, temperature and the log-sum-exp trick
- Entropy, cross-entropy and KL divergence, with worked numbers rather than only definitions
- Bayes' rule and the gap between a model's predicted probability and a calibrated one
- Sampling from categorical and Gaussian distributions, and the reparameterisation idea you will use again for VAEs
- Choosing a loss for the task: regression, classification, multi-label and sequence prediction

**Projects:**

- Build a character-level bigram language model two ways, by counting and by gradient descent on negative log-likelihood, and show they converge to the same distribution

**Practice:** Compute entropy, cross-entropy and KL by hand for three small distributions, then confirm in code.

**Assessment:** Explain, in writing, why minimising cross-entropy is equivalent to maximising likelihood, with your bigram model as the example.

### Week 6

#### Class 6: From Your Engine to PyTorch: The Training Loop Done Properly

**Topics:**

- PyTorch autograd mapped onto your engine: requires_grad, the dynamic graph, .backward(), .grad and torch.no_grad()
- nn.Module, parameters, state dicts and the anatomy of a clean model definition
- Datasets, DataLoaders, batching and shuffling, and the train, validation and test split you will respect all course
- The training loop line by line: forward, loss, zero_grad, backward, step, and logging that tells you something
- Device handling on CPU, CUDA and Apple Silicon (MPS) so every exercise runs on the hardware you have
- A character-level MLP language model in the style of Bengio et al., 2003, "A Neural Probabilistic Language Model", with learned embeddings
- Phase 1 review: what your engine did that PyTorch also does, and what PyTorch adds

**Projects:**

- Port your bigram model to an MLP language model with embeddings in PyTorch, train it, and beat the bigram baseline on held-out data

**Practice:** Re-implement one Phase 1 project in PyTorch and confirm the gradients match your hand-written version.

**Assessment:** Phase 1 gate: a timed written paper on tensor shapes, chain rule and loss derivations, plus a live code review of your autograd engine.

## Phase 2: Optimisation, Initialisation and Generalisation

Make networks actually train: SGD and the loss landscape, momentum, Adam and AdamW, schedules, initialisation and signal propagation, normalisation and residual connections, regularisation and double descent, and a systematic debugging method.

### Week 7

#### Class 7: Gradient Descent and the Loss Landscape

**Topics:**

- Full-batch gradient descent, stochastic gradient descent and minibatches, and what the noise in SGD does
- The learning rate as the most important hyperparameter: too small, too large and divergent, shown on real curves
- Convex versus non-convex objectives, saddle points and why local minima are less of a problem in high dimensions than intuition suggests
- Condition number and ill-conditioning: why a long narrow valley makes plain gradient descent zig-zag
- Learning-rate range tests to find a sensible starting value quickly
- Visualising a loss surface along random and filter-normalised directions, with the caveats of a 2D slice of a huge space
- Batch size, gradient noise and the trade-off between steps and examples

**Projects:**

- Implement SGD from scratch for your MLP, run a learning-rate range test and a batch-size sweep, and plot the results with an interpretation

**Practice:** Optimise a hand-built ill-conditioned quadratic with gradient descent and record how the condition number changes convergence.

**Assessment:** Given five training curves, diagnose each one (learning rate too high, too low, noisy batch, bug, healthy) and justify it.

### Week 8

#### Class 8: Momentum, Adam, AdamW and Learning-Rate Schedules

**Topics:**

- Momentum and Nesterov momentum derived as a moving average, and the physics intuition with its limits
- RMSProp and adaptive per-parameter learning rates
- Adam from Kingma and Ba, 2014, "Adam: A Method for Stochastic Optimization": first and second moments, bias correction, and each line implemented
- AdamW from Loshchilov and Hutter, "Decoupled Weight Decay Regularization": why L2 regularisation and weight decay differ under Adam
- Learning-rate schedules: step, linear warmup, cosine decay and warmup-stable-decay, and why transformers almost always use warmup
- Gradient clipping by norm and when it is a fix versus a mask over a bug
- Newer optimisers such as Muon, at the level of what they change and how you would test whether they help on your problem

**Projects:**

- Write SGD with momentum, RMSProp, Adam and AdamW as your own optimizer classes, verify them against torch.optim, and compare all four on the same model with fixed seeds

**Practice:** Add a warmup plus cosine schedule to your training loop and run an ablation with and without warmup.

**Assessment:** Implement Adam from memory in under fifteen minutes, then explain bias correction with a numerical example.

### Week 9

#### Class 9: Initialisation and Signal Propagation

**Topics:**

- Why initialisation matters: the variance of activations and gradients as they pass through many layers
- Vanishing and exploding gradients measured, not just described, with per-layer histograms
- Glorot and Bengio, 2010, "Understanding the difficulty of training deep feedforward neural networks": the fan-in and fan-out argument derived
- He et al., 2015, "Delving Deep into Rectifiers": the ReLU correction and why it is a factor of two
- Dead ReLUs, saturated tanh units and how to detect both from activation statistics
- Initialising the output layer and biases sensibly so the initial loss matches what theory predicts
- Building a diagnostic dashboard of activation, gradient and update-to-weight ratios per layer

**Projects:**

- Train a deep MLP with naive, Glorot and He initialisation, log per-layer activation and gradient statistics, and write up which runs fail and why

**Practice:** Predict the initial loss of a 10-class classifier before training, then check it in code.

**Assessment:** Given a set of per-layer histograms from a broken run, identify the layer and the cause.

### Week 10

#### Class 10: Normalisation and Residual Connections

**Topics:**

- Batch normalisation (Ioffe and Szegedy, 2015): forward and backward pass implemented, running statistics and train versus eval behaviour
- The batch-dependence problem and the bugs it causes with small batches and in evaluation mode
- Layer normalisation (Ba, Kiros and Hinton, 2016) and RMSNorm, and why sequence models prefer them
- Residual connections from He et al., 2015, "Deep Residual Learning for Image Recognition", seen as a gradient highway
- Pre-norm versus post-norm placement and its effect on training stability in deep stacks
- How normalisation and residuals change what initialisation has to do
- Writing each layer's backward pass by hand and gradient-checking it

**Projects:**

- Implement BatchNorm and LayerNorm with hand-written backward passes, then train a 20-layer MLP with and without residuals and normalisation and compare

**Practice:** Find and fix a deliberately planted train-versus-eval mode bug in a BatchNorm model.

**Assessment:** Explain in writing why LayerNorm does not depend on batch size, and derive its backward pass.

### Week 11

#### Class 11: Generalisation and Regularisation

**Topics:**

- Train, validation and test error, the bias-variance picture, and where it stops describing modern networks
- Weight decay, dropout (Srivastava et al., 2014) and early stopping implemented and compared
- Data augmentation as encoded prior knowledge, with examples for images and text
- Zhang et al., "Understanding deep learning requires rethinking generalization": networks that memorise random labels, reproduced at small scale
- Double descent (Nakkiran et al., "Deep Double Descent") and what it means for choosing model size
- Data leakage and evaluation hygiene: the mistakes that make a result look better than it is
- Seeds, variance across runs and reporting a mean with a spread instead of a single best number

**Projects:**

- Reproduce the random-labels experiment on a small image dataset, then run a regularisation ablation with at least three seeds per setting and report means and spreads

**Practice:** Add dropout and weight decay to an overfitting model and chart train and validation curves for each.

**Assessment:** Critique a provided results table for leakage, missing seeds and unfair baselines.

### Week 12

#### Class 12: Debugging Neural Network Training

**Topics:**

- Karpathy's "A Recipe for Training Neural Networks" (2019) as a working checklist, and where you would adapt it
- Overfit a single batch first: the fastest test that your model, loss and optimiser are wired correctly
- Silent failures: wrong loss reduction, labels shifted by one, data not shuffled, augmentations applied at evaluation, and gradients never reaching a layer
- NaNs and infinities: finding the first operation that produced one and the usual numerical causes
- Ablations as a debugging tool: remove one thing at a time and measure
- Reading training curves and gradient norms like a doctor reads vital signs
- Phase 2 review: optimisation, initialisation, normalisation and regularisation as one system

**Projects:**

- Debug three broken training scripts supplied by your mentor, each with a different silent failure, and write a one-page incident report for each

**Practice:** Build your own pre-flight checklist script that runs the standard sanity checks on any new model.

**Assessment:** Phase 2 gate: a live debugging session on an unseen broken run, plus a written paper covering optimisers, initialisation and regularisation.

## Phase 3: Architectures from Scratch: CNNs, RNNs, Attention and Transformers

Implement the architectures that defined the field, from convolution loops and LSTMs to attention and a GPT-style transformer with its own tokenizer, then pre-train a small language model on your own corpus.

### Week 13

#### Class 13: Convolutional Networks from Loops to ResNets

**Topics:**

- Convolution as a sliding dot product, written as explicit loops, then vectorised with unfold (im2col)
- Padding, stride, dilation, channels and the shape arithmetic for each
- The backward pass of a convolution derived and implemented, and why it is itself a convolution
- Weight sharing, translation equivariance and receptive fields as the inductive biases that make CNNs work
- Pooling and strided convolution for downsampling
- A short history in architectures: LeNet, AlexNet (Krizhevsky, Sutskever and Hinton, 2012) and ResNet, and what each changed
- Visualising learned filters and feature maps

**Projects:**

- Implement Conv2d forward and backward from scratch, verify against PyTorch, then build and train a small ResNet on CIFAR-10 and report test accuracy with seeds

**Practice:** Compute the receptive field of every layer in your ResNet by hand and check it empirically.

**Assessment:** Derive the output shape and parameter count of a given CNN stack without running code.

### Week 14

#### Class 14: Recurrent Networks and LSTMs

**Topics:**

- Sequence modelling and why fixed-size inputs are not enough
- A vanilla RNN cell implemented from scratch, unrolled over time
- Backpropagation through time and truncated BPTT
- Why RNN gradients vanish or explode, shown with the repeated Jacobian product
- The LSTM from Hochreiter and Schmidhuber, 1997: gates, cell state and the additive path that preserves gradients
- GRUs as a simpler gated alternative
- Where RNNs still make sense, and the sequential bottleneck that pushed the field towards attention

**Projects:**

- Implement an RNN and an LSTM cell by hand, train both as character-level language models on the same corpus, and compare loss and samples

**Practice:** Measure gradient norms across time steps for your RNN and LSTM and plot them side by side.

**Assessment:** Explain in writing, with equations, why the LSTM cell state eases the vanishing gradient problem.

### Week 15

#### Class 15: Attention from First Principles

**Topics:**

- The alignment problem in translation and Bahdanau, Cho and Bengio, 2014, "Neural Machine Translation by Jointly Learning to Align and Translate"
- Attention as a differentiable lookup: queries, keys and values
- Scaled dot-product attention and the variance argument behind the square root of d_k
- Causal masking for autoregressive models and padding masks for batches
- Self-attention versus cross-attention
- Multi-head attention as several smaller attention operations in parallel, with the reshapes written out
- The quadratic cost in sequence length and what that means for context windows

**Projects:**

- Implement scaled dot-product and multi-head self-attention from scratch with causal masking, and test it against torch.nn.functional.scaled_dot_product_attention

**Practice:** Visualise the attention weights of your layer on a small toy task (for example copying or sorting) and interpret them.

**Assessment:** Derive the attention output shape for a given batch, sequence length, head count and model dimension, and explain the mask.

### Week 16

#### Class 16: The Transformer Block from an Empty File

**Topics:**

- Vaswani et al., 2017, "Attention Is All You Need": reading the architecture section with your own code beside it
- The decoder-only block: attention, MLP, residual stream and pre-norm LayerNorm
- Positional information: sinusoidal encodings, learned embeddings and rotary embeddings from "RoFormer" (Su et al., 2021)
- Weight tying between input embeddings and the output head
- Parameter counting and FLOP estimates for a transformer, done by hand
- Initialisation and residual scaling choices used in GPT-style models
- Testing a transformer: shape tests, causal leakage tests and overfitting a single batch

**Projects:**

- Write a GPT-style decoder-only transformer from an empty file, with RoPE, a causal leakage test and a parameter count that matches your hand calculation

**Practice:** Swap learned positional embeddings for RoPE and compare validation loss on the same budget.

**Assessment:** Live review: walk your mentor through every line of your transformer and answer why each design choice is there.

### Week 17

#### Class 17: Tokenisation and the Language Modelling Objective

**Topics:**

- Characters, words and subwords: the trade-offs in vocabulary size and sequence length
- Byte-pair encoding from Sennrich, Haddow and Birch, 2016, implemented from scratch
- Byte-level BPE, special tokens and the encode-decode round trip
- How tokenisation causes odd model behaviour with numbers, spelling and non-English text
- Next-token prediction as the training objective, and the shift between inputs and targets
- Perplexity and bits per byte as evaluation metrics, and why bits per byte compares across tokenizers
- Building a clean small corpus: deduplication, splits and avoiding test leakage

**Projects:**

- Implement and train a byte-level BPE tokenizer on your chosen corpus, and measure compression ratio and round-trip correctness

**Practice:** Tokenise the same paragraph in English and one other language you know, and compare token counts.

**Assessment:** Explain why perplexity from two different tokenizers cannot be compared directly, and what to use instead.

### Week 18

#### Class 18: Pre-training a Small Language Model

**Topics:**

- Putting it together: your tokenizer, your transformer and your training loop on a small corpus such as TinyStories (Eldan and Li, 2023) or Tiny Shakespeare
- Sizing the model to your compute: parameters, tokens and the time per step on your hardware
- Training stability for transformers: warmup, gradient clipping, AdamW settings and loss spikes
- Sampling: greedy, temperature, top-k and nucleus sampling from Holtzman et al., "The Curious Case of Neural Text Degeneration"
- The KV cache for fast generation, implemented and timed
- Reading open minimal implementations such as Karpathy's nanoGPT and nanochat and comparing them with yours
- Phase 3 review: CNNs, RNNs and transformers as different answers to the same question about inductive bias

**Projects:**

- Pre-train your own small GPT-style model end to end on your corpus, add a KV cache, and publish a short report with loss curves, samples and a timing table

**Practice:** Run a sampling study: the same prompts at five temperature and top-p settings, with your judgement of each.

**Assessment:** Phase 3 gate: a live whiteboard derivation of attention plus a code review of your trained language model and its report.

## Phase 4: Scale, Generative Models, Interpretability and Capstone

Study the science around the models: scaling laws reproduced in miniature, VAEs and denoising diffusion from the original papers, interpretability basics, and a capstone experiment defended live.

### Week 19

#### Class 19: Scaling Laws in Miniature

**Topics:**

- Kaplan et al., 2020, "Scaling Laws for Neural Language Models": loss as a power law in parameters, data and compute
- Hoffmann et al., 2022, "Training Compute-Optimal Large Language Models" (Chinchilla) and why it changed the recommended ratio of tokens to parameters
- The compute approximation C ≈ 6ND and using it to plan a training run
- Fitting a power law properly: log-log plots, the irreducible loss term and the danger of extrapolating far
- What scaling laws do and do not predict: smooth loss versus jumps in specific capabilities
- Designing a small sweep that fits your GPU budget
- Hyperparameter transfer across model sizes as a practical concern when you scale

**Projects:**

- Run your own scaling sweep of at least five model sizes on your corpus, fit a power law to final loss versus compute, and state honestly how far you would trust it

**Practice:** Use C ≈ 6ND to plan the largest run your hardware could finish in a fixed number of GPU-hours, and justify the split between N and D.

**Assessment:** Given a published scaling plot, read off the exponent and explain what it implies for doubling compute.

### Week 20

#### Class 20: Generative Models I: Autoencoders and VAEs

**Topics:**

- Autoencoders as learned compression and the bottleneck that forces structure
- Latent variable models and why the likelihood is intractable
- The evidence lower bound (ELBO) derived step by step from Kingma and Welling, 2013, "Auto-Encoding Variational Bayes"
- The reparameterisation trick revisited and implemented
- Reconstruction versus KL terms, posterior collapse and the beta weighting trade-off
- Sampling and interpolating in latent space
- Where VAEs sit today: as the latent compressor inside latent diffusion systems

**Projects:**

- Implement a VAE from scratch on an image dataset, derive its ELBO in your write-up, and show reconstructions, samples and a latent interpolation

**Practice:** Vary the KL weight and record what happens to reconstructions and samples.

**Assessment:** Written derivation of the ELBO from the log-likelihood with every inequality justified.

### Week 21

#### Class 21: Generative Models II: Denoising Diffusion from the Paper

**Topics:**

- Ho, Jain and Abbeel, 2020, "Denoising Diffusion Probabilistic Models": the forward noising process and its closed form
- The reverse process and why predicting the noise is a convenient parameterisation
- The simplified training objective and the noise schedule
- A small U-Net style denoiser with time-step embeddings
- Ancestral sampling, and faster samplers at the level of what they trade
- The connection to score matching and to flow matching (Lipman et al., "Flow Matching for Generative Modeling") at an intuitive level
- Classifier-free guidance as a sampling-time control knob

**Projects:**

- Implement DDPM training and sampling from scratch on a small image dataset and produce a grid of samples across denoising steps

**Practice:** Change the noise schedule from linear to cosine and compare sample quality at a fixed step budget.

**Assessment:** Explain, with equations, why the forward process can be sampled at any time step in one shot.

### Week 22

#### Class 22: Interpretability Basics

**Topics:**

- What interpretability tries to answer, and the difference between explaining a prediction and understanding a mechanism
- Linear probes on hidden states, and the trap of a probe that learns the task itself
- Attention pattern analysis and why attention weights alone are weak evidence
- The residual stream view and the logit lens: reading intermediate layers through the output head
- Activation patching as a causal test of where information lives
- Superposition, from Anthropic's "Toy Models of Superposition" (Elhage et al., 2022), reproduced on a toy model
- Sparse autoencoders for finding features, as in "Towards Monosemanticity" (Bricken et al., 2023), at a scale you can run

**Projects:**

- Apply probes, the logit lens and activation patching to the language model you trained in Class 18, and write up one mechanism you can support with causal evidence

**Practice:** Reproduce one plot from "Toy Models of Superposition" on a toy model you train yourself.

**Assessment:** Critique an interpretability claim: what evidence would make it causal rather than correlational?

### Week 23

#### Class 23: Capstone Build: Your Own Question

**Topics:**

- Choosing a capstone question you can answer with the compute you have, agreed with your mentor in advance
- Typical shapes: reproduce a small result from a paper, run a careful ablation on your transformer, extend your diffusion model, or answer an interpretability question
- Writing a one-page plan: hypothesis, baseline, metric, seeds and the result that would change your mind
- Running experiments with a log you can trust: configs, seeds and saved checkpoints
- Mid-build review of first results, and pruning the plan to what the evidence supports
- Figures that carry the argument: what to plot and what to leave out
- Personalisation: graduate students often tie this to their thesis topic, engineers to a model their team ships

**Projects:**

- Build the capstone experiment, with a reproducible codebase, a results table with multiple seeds and the core figures

**Practice:** Rerun your key result from a clean checkout to confirm it reproduces.

**Assessment:** Mentor review of your plan and first results, with written feedback you must address before Class 24.

### Week 24

#### Class 24: Capstone Defence and Final Assessment

**Topics:**

- Writing the capstone report in the structure of a short workshop paper: question, method, results, limitations
- Stating limitations honestly and separating what you showed from what you suspect
- Presenting the work in fifteen minutes to a technical audience
- Handling questions about baselines, seeds, compute and alternative explanations
- A cumulative written assessment covering derivations and implementation from all four phases
- Planning next steps: the engineering, paper-reading and research-engineering courses in this track, or graduate study
- Course retrospective: the three ideas that changed how you think about neural networks

**Projects:**

- Submit the capstone report and code, and defend it live with your mentor in the role of a reviewer

**Practice:** Revise the report once based on the defence feedback.

**Assessment:** Final assessment: the live capstone defence plus a written paper across all phases, which together decide the certificate, with a free retest after revision if needed.

## Prerequisites

**Device:** A laptop or desktop (Windows, Mac or Linux) with Python 3.10 or newer. Phases 1 and 2 run comfortably on a CPU or Apple Silicon. For the transformer, diffusion and scaling classes, any CUDA GPU helps, and a free cloud notebook GPU such as Google Colab or Kaggle is enough for every required exercise

**Coding Experience:** Confident Python: functions, classes, lists and dictionaries, and reading other people's code. NumPy familiarity helps but is taught where needed. No prior PyTorch is required

**Maths:** School-level algebra and the idea of a derivative. Linear algebra (vectors, matrices, matrix multiplication), multivariable calculus and probability are refreshed inside the classes that use them, and your mentor adds extra refreshers 1-on-1 where you need them

**Mindset:** Patience with derivations and a habit of checking your work in code. This is a demanding course: expect to be stuck on a gradient or a shape bug more than once, and to learn the most from exactly those moments

## Who Is This For

**College Students:** Computer science, engineering, maths and physics students who want to understand deep learning properly before they specialise, and who are tired of tutorials that stop at model.fit

**Working Engineers:** Software and ML engineers who use models at work and want to understand them well enough to debug training, read papers and make architecture decisions with confidence

**Graduate Students And Researchers:** Master's and PhD students and researchers from adjacent fields who need deep learning foundations for their own research, with the derivations their work depends on covered 1-on-1

**Career Switchers With Strong Python:** Developers moving into ML who want interview-proof fundamentals rather than a list of library calls

**Strong Teens:** Strong students aged 16 and over may join after the free demo class if they meet the Python and maths prerequisites; the course is otherwise designed for adults 18 and over

## Career Paths After Completion

- ML engineer and applied scientist roles where interviews probe fundamentals: backprop, optimisers, normalisation, attention and debugging
- Research assistant, research engineer and graduate research paths, with a from-scratch portfolio and a capstone report to show
- Graduate study in machine learning, with the mathematical and implementation footing the first courses assume
- Moving into model training work inside your current team, because you can now read, change and debug the model code rather than only call it
- The natural next steps in this track: Deep Learning Engineering for training and serving at scale, How to Read AI Research Papers, and AI Research Engineering for reproducing and extending published work

## Course Guarantees

**One On One Only:** This course is taught 1-on-1 only: every class is a private session with a dedicated mentor, built around your background, your research question or codebase, and the compute you actually have.

**Live Classes:** Live, interactive classes with a real instructor, never pre-recorded videos.

**Structured Curriculum:** A structured 24-class curriculum taught step by step, with a real implementation deliverable in every single class.

**Doubt Support:** Doubt support between classes over WhatsApp, so a failing gradient check or a NaN loss never waits until the next class.

**Certificate:** A certificate you earn by passing the final assessment, with a free retest after revision if needed.

**Free Demo:** A free demo class before you enrol, so you can meet the mentor and judge the depth for yourself.

**Real Assessment:** Classwork every session, a task after every class, phase-gate reviews that mix in earlier topics, and a capstone defended live, plus a written assessment that decides the certificate: real knowledge and real work, with a free retest after revision if needed.

## Additional Learning Resources

**Total Projects Built:** 24 implementation deliverables, one per class, finishing with a capstone experiment and a report written like a short workshop paper

**Projects Throughout Course:**

- Phase 1: a NumPy forward pass with asserted shapes, hand-derived gradients checked by finite differences, your own scalar autograd engine with tests against PyTorch, a pure NumPy MLP with full backprop on MNIST, a bigram language model two ways, and a PyTorch MLP language model
- Phase 2: an SGD learning-rate and batch-size study, your own SGD, RMSProp, Adam and AdamW optimizers, an initialisation study with per-layer diagnostics, hand-written BatchNorm and LayerNorm with a residual ablation, a random-labels and regularisation study with seeds, and three debugging incident reports
- Phase 3: Conv2d from scratch and a small ResNet on CIFAR-10, an RNN and LSTM compared as language models, multi-head attention from scratch, a GPT-style transformer with RoPE, a byte-level BPE tokenizer, and a pre-trained small language model with a KV cache and report
- Phase 4: a miniature scaling-law sweep with a fitted power law, a VAE with its ELBO derivation, a DDPM implementation, an interpretability study of your own language model, and the capstone build and live defence
- Total: 24 implementation deliverables, one per class, finishing with a capstone experiment and report

#### Weekly Structure

**Live Classes:** 24 private 1-on-1 classes, 1 hour each

**Implementation Work:** 2-3 hours between classes implementing, testing and running the class deliverable

**Derivations And Reading:** 1-2 hours working through derivations and the assigned passages from the original papers

**Review And Doubts:** 30-60 minutes reviewing mentor feedback and clearing doubts over WhatsApp before the next class

**Homework:** A task after every class, and a phase-gate review at the end of each phase that deliberately folds in earlier topics

#### Certification

**Completion:** Certificate from Modern Age Coders, awarded on passing the final assessment. Fall short and there is focused revision and a free retest: the certificate certifies real learning, not attendance

**Skills Mastered:**

- Tensor manipulation, broadcasting and einsum with shape discipline
- Matrix calculus and backpropagation derived by hand and verified with numerical gradient checks
- Building an autograd engine and understanding exactly what PyTorch autograd does
- Optimisers implemented from their papers: SGD, momentum, RMSProp, Adam and AdamW, with schedules and clipping
- Initialisation, normalisation and residual design grounded in signal propagation
- Generalisation, regularisation, evaluation hygiene and multi-seed reporting
- CNNs, RNNs, LSTMs, attention and transformers implemented from scratch
- Tokenizer construction and small-scale language model pre-training and sampling
- Scaling-law reasoning, VAEs, denoising diffusion and interpretability basics
- Systematic debugging of training runs and honest experimental write-ups

#### Support Provided

**Dedicated Mentor:** The same mentor for all 24 classes, who knows your background, your goals and your capstone

**Whatsapp Doubts:** Doubt support between classes over WhatsApp

**Compute Guidance:** Help in Class 1 setting up your environment on your own machine or a free cloud notebook GPU, and sizing every experiment to the compute you have

**Session Recordings:** Class recordings available for revision, so a missed derivation is never lost

**Pytorch Docs:** https://docs.pytorch.org/docs/stable/index.html

**Pytorch Autograd Docs:** https://docs.pytorch.org/docs/stable/autograd.html

**Micrograd Repository:** https://github.com/karpathy/micrograd

**Attention Is All You Need Paper:** https://arxiv.org/abs/1706.03762

**Ddpm Paper:** https://arxiv.org/abs/2006.11239

**Understanding Deep Learning Book:** https://udlbook.github.io/udlbook/

## Why This Course

**The Gap:** Plenty of people can fine-tune a model by following a notebook. Far fewer can explain why their transformer uses warmup, derive the gradient of softmax cross-entropy, or find the one line that stopped gradients reaching a layer. That understanding is what lets you debug, read papers and do original work, and it only comes from building the pieces yourself.

**First Principles:** Every idea in this course is derived, implemented and tested before the library version is used: autograd, backprop, optimisers, normalisation, convolution, LSTMs, attention, transformers, tokenizers, VAEs and diffusion. When you finish, PyTorch is a convenience, not a black box.

**Grounded In The Literature:** The course follows the real papers the ideas came from, from Rumelhart, Hinton and Williams (1986) to Vaswani et al. (2017), Kaplan et al. (2020), Hoffmann et al. (2022) and Ho et al. (2020), so you learn to move between equations and code, which is the core skill of anyone working near research.

**One On One:** Deep learning fundamentals are learned at the point where you are stuck, and everyone gets stuck in a different place. A private mentor reviews your derivations and code every class, adds the maths refreshers you specifically need, and shapes experiments around your hardware and your goals. That is why this course is taught 1-on-1 only.

## Faqs

**Question:** Who is Deep Learning from First Principles for?

**Answer:** College students, working engineers, graduate students and researchers who are comfortable in Python and want to understand deep learning properly: how gradients are computed, why optimisers and normalisation work, and how a transformer is built. Strong students aged 16 and over can join after the free demo if they meet the prerequisites.

**Question:** What maths do I need before I start?

**Answer:** School-level algebra and the idea of a derivative. Linear algebra, multivariable calculus and probability are refreshed inside the classes that use them, always tied to code. Because the classes are 1-on-1, your mentor adds extra refreshers where you need them and moves faster where you do not.

**Question:** Do I need a GPU?

**Answer:** No. Phases 1 and 2 run on a normal laptop CPU or Apple Silicon. For the transformer, diffusion and scaling classes a GPU makes runs faster, and a free cloud notebook GPU such as Google Colab or Kaggle is enough for every required exercise. If you have your own GPU or cluster access, experiments are scaled up to use it.

**Question:** Is this course 1-on-1 only?

**Answer:** Yes. Every class is a private live session with a dedicated mentor, and there are no group batches for this course. That lets each class follow your background, your research question or codebase, and the compute you have.

**Question:** How is this different from Deep Learning Engineering: Train, Scale and Ship Models?

**Answer:** This course is the science: deriving and implementing every component from scratch so you understand why networks train. Deep Learning Engineering is the engineering: mixed precision, profiling, torch.compile, distributed training, fine-tuning with LoRA, quantization and serving. Many learners take this course first and the engineering course next.

**Question:** How is it different from the research paper reading and research engineering courses?

**Answer:** How to Read AI Research Papers teaches a method for reading, critiquing and presenting papers. AI Research Engineering teaches reproducing a paper end to end, experiment design and writing results up. This course gives you the technical foundations both of those assume, and you already read key passages of real papers here as you implement them.

**Question:** What will I actually build?

**Answer:** One implementation deliverable per class: a hand-written autograd engine, a NumPy MLP with full backprop, your own optimizers, normalisation layers with hand-written backward passes, a CNN and ResNet, an LSTM, multi-head attention, a GPT-style transformer with its own BPE tokenizer that you pre-train on a small corpus, a scaling-law sweep, a VAE, a DDPM sampler, an interpretability study, and a capstone experiment with a written report.

**Question:** Does it cover large language models like the ones in the news?

**Answer:** It covers the foundations they are built on: tokenisation, the transformer, pre-training, sampling, the KV cache and scaling laws, at a scale you can train yourself. It does not train frontier-scale models, and it does not cover production fine-tuning and serving, which belong to the Deep Learning Engineering course.

**Question:** Do I get a certificate?

**Answer:** Yes. The Modern Age Coders certificate is awarded on passing the final assessment, which combines a live capstone defence and a written paper across all four phases. If you fall short, there is focused revision and a free retest.

**Question:** Can I start if I have never used PyTorch?

**Answer:** Yes. You build your own autograd engine first and then move to PyTorch in Class 6, so you learn the framework from the inside. Confident Python is the real prerequisite; the free demo class is the place to check that the starting level suits you.

**Question:** Can I watch how you teach before enrolling in this course?

**Answer:** Yes. Full recordings of real, unedited classes for ages 13 and up are free to watch: Free to watch. No payment, no card, just a quick Google sign-in. These recordings show how we teach, not the exact syllabus of this course. Some classes are in English and some in Hindi; everyone follows at their own pace. Watch a class end to end, like you are in it. Sessions are interactive and each moment builds on the last.

**Question:** Can I enroll without a live demo?

**Answer:** Yes. Choose a plan on this page and enrol directly. A demo is optional: if you would like to see a full class with a mentor first, book a Priority Demo, a live class of about 45 to 60 minutes. Questions: WhatsApp +91 91233 66161 or email connect@modernagecoders.com.

## Related Courses

- deep-learning-engineering-course
- ai-research-paper-reading-course
- ai-research-engineering-course

## Straight answers about this course

### Who should take this course?

Advanced: college students, working engineers, graduate students and researchers comfortable in Python. It suits computer science, engineering, maths and physics students who want to understand deep learning properly before they specialise, and who are tired of tutorials that stop at model.fit; software and ml engineers who use models at work and want to understand them well enough to debug training, read papers and make architecture decisions with confidence; master's and phd students and researchers from adjacent fields who need deep learning foundations for their own research, with the derivations their work depends on covered 1-on-1.

### What will they learn and build?

Most people who use deep learning have never written a backward pass. They can call model.fit or wire up a Hugging Face pipeline, but when a loss goes to NaN, a transformer refuses to learn, or a paper's equation does not match its code, they have nothing underneath to reason with. This course builds that floor. In 24 private one-hour classes you implement the field from the bottom up.

### How deeply are topics covered?

The course runs 24 live 1-on-1 classes, 1 hour each at 1 live hour per class plus 3 to 5 hours of implementation, derivation and reading between classes, across 4 phases listed week by week in the syllabus below. A structured 24-class curriculum taught step by step, with a real implementation deliverable in every single class.

### Who teaches it?

Modern Age Coders mentors, who teach the live classes themselves. You can watch them at work in the free class recordings before you decide.

### How do practice, feedback and assessment work?

Classwork every session, a task after every class, phase-gate reviews that mix in earlier topics, and a capstone defended live, plus a written assessment that decides the certificate: real knowledge and real work, with a free retest after revision if needed. Doubt support between classes over WhatsApp, so a failing gradient check or a NaN loss never waits until the next class. A certificate you earn by passing the final assessment, with a free retest after revision if needed.

### What does it cost?

One plan, taught 1-on-1 only, billed per month of private classes. [The price is shown in your currency in the plans section](https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/#enroll). Monthly billing, cancel any time.

### When can classes take place?

Live classes are scheduled around your week: as a 1-on-1 student you choose your own slots with your mentor, and international students are scheduled in their own timezone. Ask on WhatsApp for the current availability.

### Can I watch the teaching before deciding?

Yes. [Full recordings of real 13 and up classes](https://modernagecoders.graphy.com/courses/How-We-Teach-The-Modern-Age-Coders-Methodology-6a1888029a4f81888c408ab9) are free to watch, free with a Google sign-in. These recordings show how we teach, not the exact syllabus of this course. Some classes are in English and some in Hindi; everyone follows at their own pace. Watch a class end to end, like you are in it. Sessions are interactive and each moment builds on the last.

### Can I enroll without a live demo?

Yes. Choose a plan on this page and enrol directly; a demo is not required. If you would like to see a full class with a mentor first, [book a Priority Demo](https://learn.modernagecoders.com/book-demo).

### How do I reach you with a question?

[WhatsApp +91 91233 66161](https://wa.me/919123366161?text=Hi%2C%20I%20have%20a%20question%20about%20the%20Deep%20Learning%20from%20First%20Principles%20course%20before%20enrolling.), email [connect@modernagecoders.com](mailto:connect@modernagecoders.com?subject=Question%20about%20Deep%20Learning%20from%20First%20Principles), or call +91 91233 66161. Tell us the student's age and what they have learned so far, and we will point you to the right plan and batch.

## Our promise

**The world's best learning experience, open to everyone.**

- **World-class instructors:** Every class is taught by an instructor who specialises in that exact field.
- **No compromise on quality:** Every lesson, project and piece of feedback is held to the highest standard.
- **Education for everyone:** Learners aged 6 to 67, from first-time beginners to working professionals, in 25+ countries.

If you want the highest quality, Modern Age Coders is the right choice.

## How enrolment works

1. **Pick a plan.** This course is taught 1-on-1 only: private live classes with your own mentor, about one hour each. Billing is monthly.
2. **Press Enrol and pay.** Fill in the student's name, email and phone, then pay securely: UPI, cards or net banking in India, or a debit or credit card from any other country.
3. **Fix your class timing.** After paying, WhatsApp or call +91 91233 66161 with the student's name and your preferred time. We confirm the batch or 1-on-1 slot and send the class link.
4. **Start learning.** Join your first live class at the time you chose. Your mentor takes it from there.

Want to see a class first? Book a Priority Demo: a live class of about 45 to 60 minutes with a mentor reserved for you. If you enrol, the demo fee is adjusted against your first month's fee. Share your demo Order ID with us on WhatsApp and we take it off.

Billing is monthly and you can cancel any time.

## Contact

- WhatsApp: +91 91233 66161 (https://wa.me/919123366161?text=Hi%2C%20I%20have%20a%20question%20about%20the%20Deep%20Learning%20from%20First%20Principles%20course%20before%20enrolling.)
- Email: connect@modernagecoders.com
- Phone: +91 91233 66161

---

## Enroll

- Enroll directly, no demo required (plans in your currency): https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/#enroll
- Book a Priority Demo, optional (a full live class with a mentor reserved for you): https://learn.modernagecoders.com/book-demo
- Course page: https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/
- All courses: https://learn.modernagecoders.com/courses

*Source: https://learn.modernagecoders.com/courses/deep-learning-from-first-principles-course/*
