# Neural Network Training &amp; Gradient Descent

A bilingual \(Chinese/English\) instrument bench showing a small neural network training: forward pass, loss, backpropagation, weight updates and gradient descent on a loss landscape

By DUSK

Topic: Computing, AI &amp; Electronics

[Open the interactive Jig](https://ask.jig.com/j/ztMW82xd437n)

## Transcript

### 1. 神经网络如何学习 · How a neural network learns

This bench holds a tiny neural network: glowing neurons \(神经元\) joined by connections called weights \(权重\)\. It learns by trying, measuring its mistake and nudging every weight a little\. Drag anywhere to turn the bench\.
这台小网络靠反复尝试、衡量错误、微调权重来学习。拖动可旋转视角。

A network that reads handwritten digits has about 13,000 weights and biases\. 识别手写数字的小网络约有一万三千个参数。

### 2. 前向传播 · Forward pass

Data enters on the left and flows forward, layer \(层\) by layer\. Each neuron adds up its inputs, each multiplied by a weight, then squashes the total into a value between 0 and 1\. Brighter cyan means a bigger value\.
数据从左向右逐层传递：每个神经元把加权输入相加，再压缩到0到1之间。

Brighter connections are stronger weights\. 连线越亮，权重越大。

### 3. 预测与损失 · Prediction and loss

The two output neurons give the network's guess, its prediction \(预测\)\. Beside them, cyan bars show the guess and white rings mark the right answer, the target \(目标\)\. The amber gap is the error, and the loss \(损失\) gauge adds up those errors into one number\.
预测与目标之差就是误差，损失把误差汇总成一个数。

Here the loss is half the sum of squared errors\. 这里的损失是误差平方和的一半。

### 4. 反向传播 · Backpropagation

Now purple signals travel backward from the loss\. Using the chain rule \(链式法则\), a maths rule for passing effects back step by step, each connection learns how much it added to the error\. Nothing is updated yet: backpropagation only measures the blame\.
反向传播只计算每个权重该改多少，还没有修改权重。

Data flows forward; only the error signals flow backward\. 数据向前，误差信号向后。

### 5. 权重更新 · Weight update

The gradient \(梯度\) points the way the loss would grow, so gradient descent \(梯度下降\) nudges every weight a small step the opposite way\. Press Train to run many rounds of forward, loss, backward and update\. Watch the amber gaps shrink and the loss gauge fall\.
按下训练，网络会多次循环，误差逐渐缩小。

One full pass over all the training data is called an epoch \(周期\)\.

### 6. 损失地形 · The loss landscape

Picture every possible setting of two weights as a map\. The height of the ground is the loss, so the lowest point is the best setting\. The glowing ball marks the current values of those two weights: each step it measures the local slope and hops downhill\.
地形高度代表损失，小球每一步都沿坡度向下跳。

Real networks have millions of weights; this bowl is a two\-weight slice\. 真实网络有百万个维度，这里只取两个。

### 7. 学习率 · Learning rate

The learning rate \(学习率\) sets how far each hop goes: too small and the ball crawls, just right and it glides to the bottom\. Too large and it zig\-zags across the valley or flies right out of the bowl\. Slide to try each one\.
学习率太小走得慢，太大会振荡甚至发散。

Each hop is the learning rate times the slope, so hops shrink near the flat bottom\.

### 8. 训练循环 · The training loop

Put together: forward pass, loss, backpropagation, update, then repeat\. Here each network update also triggers one hop of the ball\. The same loop, repeated billions of times, trains the largest AI models\.
前向、损失、反向、更新，不断重复，这就是训练。

GPT\-3 has 175 billion weights, trained by this same loop\. GPT\-3有1750亿个参数。
