🌏 中文版
Video status: Videos included. This post is written from the English transcript of the Spring 2026 Lecture 7 recording published by Stanford Online, with formulas and notation checked against Sections 7.1 to 7.3 of Chapter 7 (Deep learning) in the 2026 main lecture notes. I did not see the whiteboard. Where the transcript has the lecturer pointing at the board, I reconstructed the content from the surrounding context and the notes.
This is the first deep learning lecture in Reading Stanford CS229, taught by Tengyu Ma. Up through the previous lecture, almost every used for regression and classification had the form , linear in the parameters. This lecture moves the same training recipe to nonlinear models and then defines the most widely used kind of nonlinear model, the neural network. The prerequisites are linear regression, softmax, and gradient descent from the earlier lectures, plus matrix multiplication. After reading, given the layer widths of a multi-layer network, you should be able to write down the shape of every weight matrix, count the parameters, run one forward pass by hand, and say what a residual connection and LayerNorm each do in terms of the formula.
The lecturer opens by setting the scope (recording 00:05–02:11): these two lectures only lay the groundwork for deep learning, and diffusion models and large language models come in later weeks. He also explains why he uses the whiteboard instead of slides. With slides you only see one at a time, "there's not enough memory there"; the whiteboard has six panels he can look back at, and writing forces him to slow down.
What "nonlinear" model means (recording 02:11–08:00)
A linear model looks like this, where is the input and is the parameter vector:
The lecture first rules out a case that looks nonlinear but does not count:
It is quadratic in , but set and treat as the new input, and the model is back to . What we learn is , and is a fixed number we can compute, so every tool from linear regression still applies. In the lecturer's words, "this nonlinear in the data is not nonlinear enough in some sense" (in the passage starting at 03:12).
Nonlinear, in this lecture, means nonlinear in the parameters. He writes down an offhand example, , and stresses that it is only an illustration; the model the lecture is really about is the neural network. A student asks what the difference is. His answer: a model that is nonlinear only in can be turned back into a linear model by changing the input, so from a learning point of view nothing changes. A model that is nonlinear in the parameters cannot be converted this way, so some of the techniques for linear models no longer apply.
An addition in this article: the lecturer says there is no way to turn this offhand example back into a linear model, and for this particular example that claim is too strong. Set and it is a linear model whose coefficient is constrained to . Treat it as a notational illustration. The example that really cannot be converted is later on, and self-check question 1 uses a set of numbers to confirm that it is not linear in the parameters.
Section 7.1 of the notes words it slightly differently. It says the models to be considered next are nonlinear in both the parameters and the inputs , and the example in its footnote is .
The regression loss, and why it equals the negative log-likelihood under a Gaussian assumption (recording 08:00–10:27, 17:53–19:55)
The dataset is pairs of inputs and labels, . The notation follows the convention used throughout the course: the superscript says which example, and a subscript says which coordinate.
In a regression problem the label is and the model is . The loss on example and the overall loss are
The loss is written as a function of because the data is given and only the parameters can move. The formula is the same as in linear regression; the only difference is that is no longer . Equation (7.1) in the notes has an extra in front, which the lecture leaves out; multiplying by a constant does not change where the minimum is. The lecturer mentions in passing that error, loss, and cost all mean the same thing. The notes still say cost, and researchers today more often say loss.
Later a student follows up: why does squared error count as a likelihood too? The lecturer derives it on the spot. The derivation is the same one Lecture 3 did for the linear model, with replaced by a general . Assume the data is generated like this:
Then, given , follows a Gaussian distribution with mean and variance :
Take the negative log. The product becomes a sum, and the cancels the exponential:
The first term does not depend on . The second is the squared error times the positive constant . So when you minimize over , the negative log-likelihood and the squared error pick the same parameters.
Multi-class classification: logits, softmax, and cross-entropy (recording 10:27–17:53)
The notes also have a passage on binary classification; to save time the lecture goes straight to the multi-class case. Here the lecturer drops the superscript and looks at a single example , where the label is a discrete class index.
The model outputs one real number per class, and these numbers are called logits. The bar is there only to tell it apart from the regression . Softmax turns the logits into probabilities:
The exponential makes every term positive, and dividing by the sum makes them add up to 1. The loss is again the negative log-likelihood. There is one detail the lecturer stops to spell out: the formula above gives a probability for every , but the label we actually have is one specific , so we substitute for :
This is the cross-entropy loss. Its two inputs are the logits vector and the label. The lecturer notes that PyTorch has a module of the same name that you can call directly. The loss over the whole dataset is still the average: .
Numerical example (made up for this article, not from the lecture). Three classes, and the logits for some example are .
- Exponentiate: , , , which sum to about .
- Probabilities: , , .
- If the label is class 1, the loss is ; if the label is class 3, the loss is .
What this means: the model gave its highest score to class 1. If the answer really is class 1, the loss is small; if the answer is class 3, the one the model favored least, the loss is nearly six times larger. A second way to check the arithmetic: expanded, the loss is , which is .
Why is it called cross-entropy? A student asks this and the lecturer answers verbally, saying the derivation is a bit long to write out. Filling it in along the direction he describes (the formulas below are added by this article): let , and let be the true distribution of the label given . Take the expectation of the loss under the true distribution:
The right-hand side is the cross-entropy between and : the probabilities of one distribution times the log probabilities of the other, summed.
What about one-hot vectors? In the lecture's notation is just an integer, so it can be used directly as a subscript. The lecturer says you can also encode as a one-hot vector. Mathematically it is the same thing, except that "take the -th coordinate" is rewritten as an inner product with the one-hot vector.
Optimization: gradient descent, SGD, and minibatches (recording 19:55–34:23)
The total loss is a function of , and the next job is to find a that makes it small. Newton's method is off the table here. The lecturer's reason is that the function is no longer convex, so Newton's method has no guarantee; he adds that in fact no method has guarantees for all non-convex functions.
Gradient descent treats as a whole. At each step
The lecture writes the step size as ; the notes write . Computing once means computing the gradient for each of the examples and averaging.
Stochastic gradient descent (SGD), in its plainest form, draws one uniformly from at each step and uses only that example:
Why is looking at a single example defensible? is random and each value is drawn with probability , so the expectation of the single-example gradient is
The middle equality uses the fact that the sum of gradients equals the gradient of the sum. The conclusion: the single-example gradient averages out to exactly the full gradient, but each individual draw carries noise.
A small example shows what the noise looks like (made up for this article): a one-dimensional parameter and three examples whose single-example gradients at the current are , , and . The full gradient is their average, , so gradient descent moves in the negative direction. SGD goes too far if it draws the first example and even goes the opposite way if it draws the third, but the three cases are equally likely and the average is still . The lecturer draws the same thing on the whiteboard with arrows: the black arrow is the full gradient, the blue arrows scatter around it and sometimes point backward, and along the trajectory the blue line wiggles while roughly following the black one. He also cautions that how closely the two trajectories track each other in the long run depends on the step size and many other details, and the error is sometimes amplified and sometimes shrunk.
A student then asks: so why use SGD at all? The lecturer gives three reasons.
- The full gradient is too expensive. The numbers he cites are about a million examples in 2015 and roughly a trillion tokens in 2026. You cannot go through every gradient at every step.
- Computing the full gradient is wasteful. The gradients of different examples are highly correlated. If every example tells you to go the same way, a small subset is enough to know the direction.
- The process does not need to be precise. If one step goes astray, later steps correct it; the force that every step shares washes out the perturbations.
The Q&A on local minima. A student asks whether SGD's noise can help you jump out when you are stuck at a local minimum. The lecturer first draws the one-dimensional case: you walk downhill to the bottom of a valley, the gradient is 0, and you stop. The idea that noise bounces you into another valley sounds reasonable, but he says the research community does not see it that way:
"I don't think people believe that stochastic descent can help you to jump out of a local minimum." (in the passage starting at 29:18)
The other side is that people also do not think high-dimensional loss functions have many bad local minima. The lecturer says he has worked on theory in this area himself and stresses that no one is sure it is right. The hypothesis closest to a consensus today is that bad local minima are very rare, and possibly every local minimum is a global minimum. He uses a skiing analogy: slide down a mountain in any direction and you will most likely end up at some parking lot; occasionally you slide into the backcountry and get stuck, and even then you can usually find a creek valley that keeps going down. He adds on his own that the analogy does not fully hold in two dimensions; it is in high dimensions that you can more reliably find a direction that goes down.
Another student says this is counterintuitive and wants the mathematical reason. The lecturer says it is not something that holds in general and he can only give a sentence or two of intuition: a local minimum requires the Hessian at that point to be positive semidefinite in every direction, and that condition is hard to satisfy. A zero gradient is already equations; requiring in addition that the Hessian has no negative direction leaves far fewer points. For certain specific models, papers by him and other researchers have actually counted the local minima, and the count matches the number of global minima; the general case is hard to compute. The transcript records the tool used as "categorize formula", which should be the Kac–Rice formula.
Minibatches. In practice you do not draw a single example at a time. Using all the data is too expensive, using one example is too noisy, and the compromise is to draw examples each time. The lecturer also gives a hardware reason: computing one example at a time leaves GPU utilization far too low, and if you have ten thousand GPUs most of them sit idle. He says the term SGD covers both batch size 1 and the larger versions. The update follows equation (7.10) in the notes, with the step size changed to the lecture's :
where are indices drawn from (the notes specify sampling without replacement).
The framework is in place; two questions remain (recording 34:23–36:25)
The recipe so far: define a loss for each example, take the average, and pick an optimization method to run. The lecturer says unsupervised learning later on uses the same scaffold, except the loss has no in it. The recipe holds for any , so two questions are left:
- How do we define (or )? That is the second half of this lecture.
- How do we compute the single-example gradient ? Once you can compute it for one example, the gradient of a batch is just the average. The algorithm is called backpropagation, or automatic differentiation, and it is the topic of the next lecture.
One neuron: ReLU and activation functions (recording 36:25–43:34)
The example is still house price prediction, which the lecturer himself says is probably twenty years old. The horizontal axis is the size of the house and the vertical axis is the price. The data he describes has this shape: at first the price does not rise much with size, and only later does it become close to a straight line. A single straight line would not fit well enough, so we want a model that can at least draw a "flat first, then sloped" kinked line. That kinked line can be written as
clips every part of the line below 0 to 0, and then shifts the whole line up or down. The lecturer notes that clipping negative values is also sensible because house prices are not negative. Equation (7.11) in the notes has no term, and the motivation it gives is only to keep the house price from going negative.
The function is called ReLU (rectified linear unit) in deep learning:
The negative side is 0, and the positive side is a straight line with slope 1. The model above is therefore written . Without the ReLU, it is just a straight line.
Numerical example (made up for this article). Take , , , with in square feet and the output in thousands of dollars.
- : , which is after the ReLU, so the output is .
- : , and the output is .
- : , and the output is .
The kink is where , that is, at . To the left of the kink the model outputs a constant 200; to the right, each extra square foot adds 0.3. sets the slope, together with sets the position of the kink, and sets the height of the flat part. All three parameters have to be learned from data.
Nonlinear functions like ReLU that map one real number to one real number are called activation functions. The lecturer explains where the name comes from: a biological neuron is stimulated by other neurons and fires only above some threshold, with no response below it, so the response is a nonlinear function of the stimulus. He says he is no expert on this, and that the biological function does not happen to look like ReLU. It looks more like a sigmoid, which is why early deep learning used the sigmoid; it was later replaced because of computational problems. The transcript records this sentence as "this ReLU is actually a bad idea"; from context it refers to the sigmoid. One reason Section 7.2 of the notes gives is that the gradients of sigmoid and tanh vanish as the input moves toward either extreme.
When the input is a -dimensional vector, replace with an inner product:
is called the weight vector and the bias. is a scalar; add the scalar , apply ReLU once, and the output is still a scalar. The activation function is used once, so this is one neuron, also called a one-layer network.
Stacking neurons: the two-layer fully connected network (recording 43:34–50:58)
The lecturer uses the house price example to explain why you would stack. The raw inputs are the size, the number of bedrooms, the zip code, and an that, looking at his notes, he says he cannot remember (the notes have the wealth of the neighborhood). What really drives the price may be intermediate quantities that are not in the data, such as walkability and school quality . Each intermediate quantity can be thought of as some linear combination of the raw inputs passed through a ReLU, and the final price is in turn a linear combination of these intermediate quantities, for example . He says the notation here is very loose; the point is only to convey the idea of applying "linear, nonlinear, linear again" repeatedly. The same example in the notes has three intermediate quantities, the extra one being the family size the house can hold.
Older papers often draw this structure as a row of circles connected to the next row of circles. The lecturer's comment:
"once you know what they are talking about, the drawings are very useful. But when you don't really know what they are talking about, it's kind of confusing." (in the passage starting at 46:52)
So he defines it with formulas instead. The input is , and there are intermediate variables. Each one is a neuron, and each takes all of the inputs:
Each and . The output is a linear combination of these . Collect into a vector and there is no need to write out a long :
The square-bracket superscript is the layer index: the parameters turn into , and the parameters turn into the output. Note that has dimension , the same as and unrelated to , because it takes an inner product with . This is the two-layer fully connected neural network; "fully connected" means every depends on all of the .
Keep the three kinds of indices apart: a parenthesized superscript is which example, a square-bracket superscript is which layer, and a subscript is which coordinate or which neuron.
Vectorization: one layer is ReLU(Wx + b) (recording 50:58–54:15)
There are too many indices, and the lecturer himself says it is a mess. Transpose the weight vectors of the first layer into row vectors and stack them row by row into a matrix:
By the definition of matrix multiplication, the -th coordinate of is exactly the inner product of row with , namely . So the equations collapse into one:
Here ReLU acts on a vector, which means it is applied elementwise; the lecturer says to remember this. He reminds the class that all vectors are column vectors by default and become row vectors only after a transpose. He also says that most of the time you do not need to remember the correspondence above, only that what one layer does is "multiply by a matrix, add a bias vector, take the ReLU elementwise, and get a vector".
Parameter count: turns a -dimensional input into an -dimensional output and has numbers; has . The layer has parameters in total.
Full numerical example (made up for this article). Take , :
The linear part of the first layer, one row at a time:
- Row 1: ; adding the bias gives .
- Row 2: ; adding the bias gives .
Take the ReLU elementwise: . Second layer: .
The result shows two things. The first neuron outputs 0 for this input, so its weights contribute nothing to this output; ReLU makes each example activate only a subset of the neurons. Also, the final output is negative, because the last layer has no ReLU after it. The footnote to equation (7.13) in the notes specifically mentions that multi-layer networks usually do not put a ReLU near the output, especially when the output is not necessarily positive.
Parameter count: the first layer has , the second has , for 11 in total.
One level more abstract: MM, other activation functions, and multiple layers (recording 54:15–1:04:48)
To write fewer symbols, the lecturer defines "multiply by a matrix and add a bias" as a module (the notes call it MM, for matrix multiplication):
ReLU can also be swapped for another activation function . An activation function is always a scalar function , applied elementwise when used on a vector. One layer is then written .
In class the lecturer sketches several of them without writing formulas and tells everyone to look at the notes. Section 7.2 of the notes lists:
- sigmoid:
- tanh:
- leaky ReLU: ,
- GELU:
The lecturer's summary is that these functions are roughly increasing and are often close to 0 to the left of 0 (his word is often; by the formulas above, tanh approaches on the left, so it is not one of these). GELU is the one that is not strictly increasing: on the negative side it dips down a little before coming back. Scanning the notes' formula numerically, the minimum is at about with a value of about (these numbers were computed for this article). As for why you would pick one over another, the lecturer is frank:
"So exactly why use any of this is like a little like a magic." (in the passage starting at 57:24)
His observation is that smoother functions seem to help, and ReLU is not smooth enough; beyond that, sometimes the consideration is stability and sometimes it is simply what worked when people tried it. The notes also list Swish, ReLU², Softplus, and gated activation functions such as GLU, which the lecture does not mention.
With these two modules, a multi-layer network is repeated application:
The lecturer says the number of layers is roughly the number of matrix multiplications. Each layer uses a different and . Their shapes may be similar, but they are different variables, so the full expression needs square-bracket superscripts to tell them apart.
The dimensions have to be compatible. For to make sense, the number of columns of must equal the dimension of , and the number of rows can be chosen freely. Suppose the input is -dimensional:
- , with an -dimensional output; the dimension does not change after .
- must therefore have columns, that is, , and is again free to choose.
The output dimension of each layer becomes the input dimension of the next. The lecturer adds that the dimension of the raw input is fixed by the data and cannot be changed; after that you usually do not change dimensions often, keeping the same width for a long stretch and changing it once or twice along the way. Counting as in the previous section, layer has parameters, and the notes write the total as .
Architecture diagrams in papers today are more abstract than the circle drawings: one box labeled MM, one box labeled , stacked upward. Merge several boxes into one and it is called an MLP (multilayer perceptron). The lecturer cautions that the term refers to different things in different papers, sometimes one matrix multiplication plus one , sometimes two.
A student asks whether the intermediate dimensions usually get smaller and smaller. The lecturer says in most cases yes, because the raw input tends to be large. A language model starts at the vocabulary size, perhaps 250,000, shrinks to around 2,000 first, and then keeps using that; an image has three RGB channels, each for example 256×256, and also has to be shrunk first.
Residual connections (recording 1:04:48–1:11:50)
A residual block is defined as follows: apply two matrix multiplications and activation functions alternately to the input , then add itself back at the end.
The two MMs each have their own weights. One constraint follows immediately from the definition: is added to the term after it, so the input and output dimensions of the block must be the same. also does not have to be the raw input; it can be the output of any intermediate layer.
A residual network is put together roughly like this: one transformation at the start to change the raw dimension into the intermediate dimension, many residual blocks stacked in the middle, and possibly one more change of dimension at the end. The notes write a simplified version as .
The lecturer says this design comes from the famous 2015 residual network paper (the notes cite it as He et al., 2016) and relays the original motivation. Suppose that by some layer the intermediate variable is already close to the target . Since it is already close, let the network describe only the gap:
Move to the right-hand side:
This is almost the residual block. The only difference is that people later found one layer was not good enough to describe the gap and switched to two. The lecturer says that about seven to ten years ago people tried putting two, three, or more layers inside, two to three turned out best, and the reason was never really understood. Here is how he frames the whole account:
"So this is just a story. It's not like there's any formal proof there." (in the passage starting at 1:08:59)
One student gets confused about "which one is the assumption". The lecturer's answer is that the two equations are equivalent: if you believe describing the residual directly is advantageous, you write the first one, and rearranging gives the second, "nothing profound". Intuitively, predicting the original label is hard and predicting a gap that is already small is easier, so the easy job goes to those two layers.
He also mentions another family of explanations that looks at it from the optimization side: in some cases you can argue that adding improves the condition number of the optimization problem and makes training easier, and some of his own papers belong to this family. There are many explanations, and it is hard to know which one is the real reason.
An observation you can check yourself (an addition in this article): if the weights and biases of both MMs are all 0 and the activation function is ReLU, then , so . In other words, for a residual block to represent "do nothing", you only need to set the parameters to 0.
LayerNorm and RMSNorm (recording 1:11:50–1:18:50)
With seven minutes left, the lecturer chooses to cover layer normalization first. It is a module whose input is and whose purpose is to normalize .
Step one: compute the mean and standard deviation of this vector's own coordinates, subtract the mean, and divide by the standard deviation. The notes call this step LN-S:
Afterward, the coordinates of the vector have mean 0 and standard deviation 1. Note that the mean is taken over the coordinates of the same vector and has nothing to do with other examples. A footnote in the notes explains that the denominator is and not because the goal is for the output variance to be exactly 1, not to do statistical estimation.
Step two: mean 0 and standard deviation 1 are not necessarily the best choice, so add two learnable scalars, and :
The output's mean becomes and its standard deviation becomes . The lecturer calls this step the clever part: normalize to 1 first, then leave a so that training itself decides how large to normalize to, without locking the scale at 1.
The lecturer says LayerNorm is still used in large language models, in a form slightly different from the original, and then introduces the simpler RMSNorm (the examples the notes give are LLaMA and Qwen). It does not subtract the mean. It only divides by the square root of the mean of the squared coordinates and then multiplies by a learnable :
In class he briefly writes it as keeping and immediately corrects it to keeping . The meaning is that you do not care whether the mean is 0 but still want to control the scale. As for why this is better, he says it is mainly an empirical result.
Numerical example (made up for this article). .
- The mean is ; the deviations are and the mean of their squares is , so .
- .
- With , : , with mean 0.5 and standard deviation 2.
- RMSNorm (): the mean of the squares is , , and the output is about . All four numbers are still positive because the mean was not subtracted.
Now scale the input up by ten, . The mean becomes 50 and the standard deviation becomes , so , exactly the same as before. The same goes for RMSNorm: .
This is the scale invariance the lecturer covers in the last minute. In general, multiply by a scalar and both the mean and the standard deviation are multiplied by :
The in the numerator and denominator cancels, so . The notes connect this to the preceding layer: , and therefore . Scale the preceding layer's weights and bias up or down together, and the output after normalization does not change. The notes restrict this to ; when is negative, is only multiplied by and the normalized vector flips sign (this sentence is an addition in this article).
What this property is good for, in the lecturer's telling: in the past, when tuning a model, the outputs could grow layer after layer, up to something like , and then everything would blow up; normalizing at every layer keeps it from getting there. Initialization also becomes less sensitive, and getting the scale wrong does not lead to total collapse. He adds one caveat that he himself calls somewhat advanced: the forward pass is invariant to scale but the gradient is not, so part of the problem is pushed over to the optimization side, which is much more complicated.
Convolution: the one-minute version (recording 1:18:50–1:20:15)
There is no time in class for convolutional networks. The lecturer uses the last minute to give a one-sentence version and leaves the rest to the notes: a convolutional layer is also a matrix multiplication, except the matrix is not a dense one but one with special structure. The transcript records it as "topless matrix"; from the description it should be a Toeplitz matrix. The nonzero entries appear only in a band near the diagonal, and every row holds the same set of numbers, shifted one position to the right. That shared set of numbers is called the filter, and the effect is to apply the same filter once at every position of the data.
The matrix and parameter counts that follow are filled in from the notes; the lecture does not write them. Equation (7.53) in the notes gives the general form of this matrix. This article plugs in filter length and input dimension (with zero padding at the boundary), with filter , and gets
A general matrix has 16 parameters; this one has only 3. The general conclusion in the notes is that convolution has parameters and costs to compute, while a general matrix multiplication has parameters and costs . The two-dimensional and multi-channel versions are in the notes.
The lecturer's assessment of convolution is that it is not used much anymore. What remains is mostly vision, and vision has also largely moved to transformers, so "probably it's fine to skip them" (in the passage starting at 1:20:12).
Self-check
1. Is linear in the parameters ? Give a set of numbers to show it.
No. If it were linear, adding two sets of parameters would add the outputs. Take : the parameters give ; the parameters give ; the sum of the two parameter sets is , which gives , but . Criterion: the answer needs a concrete counterexample; saying "because there is a ReLU" is not enough.
2. Three classes, the logits are , and the label is class 2. What is the cross-entropy loss?
The denominator is , the probability of class 2 is , and the loss is . You can also compute it directly as .
3. A network takes a 10-dimensional input, has two hidden layers of width 5, and outputs 3 logits. Write the shapes of the three weight matrices and compute the total number of parameters. By the lecture's definition, how many layers does this network have?
, , . The parameter count is . There are three matrix multiplications, so it has three layers. Criterion: the number of columns of each matrix must equal the output dimension of the previous layer.
4. Why must the input and output dimensions of a residual block be the same? If you want to change the dimension from 512 to 256 partway through a network, can you use the residual block as defined in the lecture directly?
Because the definition contains , and two vectors of different dimensions cannot be added. You cannot use it directly. The residual network described in the lecture puts the change of dimension outside the residual blocks, with one matrix multiplication at the start and one at the end. A change partway through can be handled the same way: insert an with between two groups of residual blocks (changing dimension partway through is a scenario this article adds as an extension).
5. . Compute and with . After adding 10 to every coordinate to get , which one's output stays the same?
, , and . RMSNorm: the mean of the squares is , , and the output is about . After adding 10, the mean for LN-S becomes 12 and the standard deviation is still 1, so the output is still ; RMSNorm becomes , which has changed. The thing to see in this question is that the two differ only in whether the mean is subtracted: both are invariant to scaling up or down, and only LayerNorm is also invariant to shifting everything by a constant. (The shift part is an exercise this article adds as an extension; the lecture only covers scale.)
Corresponding reading
Chapter 7, Deep learning, of the main lecture notes main_notes.pdf:
- 7.1 Supervised learning with non-linear models (pp. 80–83): corresponds to the first half of this lecture. The notes have an extra passage on binary classification that the lecture skips; the squared loss carries a factor of ; SGD and minibatch SGD are written as Algorithms 1 and 2, with the step size denoted .
- 7.2 Neural networks (pp. 84–93): a single neuron, stacking neurons, the two-layer fully connected network, vectorization, multiple layers, and other activation functions.
- 7.3 Modules in Modern Neural Networks (pp. 93–99): the module notation for MM and MLP, residual connections, layer normalization and scale invariance, RMSNorm, and convolutional layers.
Parts the lecture covers that Chapter 7 of the notes either lacks or treats very briefly: where the name cross-entropy comes from, the three reasons for using SGD, the whole Q&A on local minima and the high-dimensional loss landscape, and the motivating story for residual connections. For these, the recording is the main source. The derivation connecting squared error and the Gaussian likelihood is not in Chapter 7; the notes put it in the linear regression chapter, and this series covers it in Lecture 3.
Parts in the notes that the lecture does not get to, worth reading on your own:
- Why the activation function cannot be the identity (pp. 91–92). If and the biases are 0, a two-layer network is , and no matter how many layers you stack it is still just a linear model.
- The connection to kernel methods (pp. 92–93). View everything before the last layer as a learned feature map , and the whole network is a linear model on those features; the difference is that the features are trained too.
- The full definition of convolution (pp. 97–99): one-dimensional convolution, and the parameter counts for multi-channel and two-dimensional convolution.
- Batch normalization and group normalization (p. 96), each of which the notes mention in a single sentence.
Backpropagation in Section 7.4 and vectorization over training examples in Section 7.5 belong to the next lecture.
Series navigation: Previous: Lecture 6: bias and variance, regularization, and model selection | Next: Lecture 8: backpropagation
Course video sources
Original video: Stanford CS229 Machine Learning | Spring 2026 | Lecture 7: Neural Networks 1 (Architecture)
- Stanford CS229 Machine Learning | Spring 2026 playlist (Stanford Online, 17 videos)
- CS229 course website
- CS229 main lecture notes, main_notes.pdf
Checked: 2026-10-12.
Content check: verified against the video transcript (2026-10-12): the whole article was compared passage by passage against the English transcript of this recording (about 80 minutes), and the time ranges marked on each section come from the transcript's paragraph timestamps. I did not view the whiteboard; the full forms of the formulas come from Chapter 7 of the main lecture notes, and places where the lecture and the notes disagree are marked in the text.
References
- Stanford CS229 Machine Learning | Spring 2026 | Lecture 7: Neural Networks 1 (Architecture): the main source for this article; the lecture's statements and quotations all come from the English transcript of this recording.
- CS229 main lecture notes, main_notes.pdf: Sections 7.1–7.3 of Chapter 7 (pp. 80–99), used to fill in the formulas, notation, and page numbers for what was on the whiteboard.
- CS229 course website: the official entry point for the course and the notes.
- Reading Stanford CS229: course overview: the overview and self-study route for this series.
Loading...