30 / 90

第 30 天:优化——梯度下降及其失败模式

在凸碗形函数上手推梯度下降更新,构造发散与慢爬反例,解释鞍点,并练习不虚构成功的失败分析。本日收束数学模块。

数学与算法基础 480 分钟有效学习(8 小时专注学习)
01 120 分钟

凸碗形函数上的梯度下降机制

仅在记录预测与观察证据之后允许求助。

前置要求

完成第 29 天评估;掌握数学模块中的单变量求导(幂法则)。

学习目标

推导梯度下降更新 x ← x − η·2x = x(1 − 2η),并由因子 (1 − 2η) 预测整条优化轨迹。

操作指引

这里的优化指迭代地降低损失。在 f(x) = x² 上梯度为 2x,每步把 x 乘以 (1 − 2η)。从 x₀ = 4、η = 0.1 出发,因子为 0.8:x₁ = 3.2、x₂ = 2.56、x₃ = 2.048,一般地 x_k = 4·0.8^k。先手工推演,再用短 Python 循环确认。注意 η = 0.5 时因子为 0——在这个纯二次函数上一步收敛。

自主演练与记录

对 f(x) = x²、x₀ = 4:(a) 写出 x_k 的闭式;(b) 计算 η = 0.1 时的 x₁、x₂、x₃ 与 x₁₀;(c) 对 f(x) = (a/2)x²,因子为 (1 − ηa)——推导稳定条件 |1 − ηa| < 1 及其蕴含的学习率上界。

独立掌握标准

闭式推导正确,四个迭代值全部正确,并陈述 η < 2/a 条件及 a = 2 的特例。

权威源资源与权利证明

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

作者 / 机构: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | 原始出处链接 ↗

对应章节 / 时间戳: Chapter Optimization Algorithms: Gradient Descent

验证版本与日期: Current online edition (Verified: 2026-10-30)

入选理由:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

来源前置条件:

Linear algebra, calculus, and probability at the Days 19-28 level.

安全回退方案(离线弹性):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

对比候选资源与选型分析 (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

作者 / 机构: Grant Sanderson (3Blue1Brown) | 原始出处链接 ↗

对应章节 / 时间戳: Neural networks chapter 2: the gradient and the descent update

验证版本与日期: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

入选理由:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

来源前置条件:

High-school functions and slope intuition.

安全回退方案(离线弹性):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

对比候选资源与选型分析 (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

02 120 分钟

不稳定的步长:发散与慢爬

独立掌握检查(无 AI 辅助)。

前置要求

完成活动 30-01;不使用 AI 辅助。

学习目标

在同一函数上构造三种优化失败形态——发散振荡、冻结振荡与慢爬——并按因子 (1 − 2η) 对任意 η 分类。

操作指引

在优化中,因子 (1 − 2η) 决定一切:|因子| < 1 收敛;因子 = −1 永远振荡;|因子| > 1 带交替符号发散;小的正因子收敛慢到没有意义。在 f(x) = x²、x₀ = 4 上计算每种形态,并诚实记录轨迹——这些是真实失败模式,不是异常。

自主演练与记录

在 f(x) = x²、x₀ = 4 上分类并追踪:(a) η = 1.2 → x₁、x₂、x₃ 与 |x₁₀|;(b) η = 1.0 → 第 1 步之后的轨迹;(c) η = 0.01 → x₁₀,以及为什么这个『能跑』的学习率仍是实际失败;(d) 为每种形态命名。

独立掌握标准

三条轨迹全部正确,每种形态连同其因子命名,并解释为什么『损失下降』是必要而非充分条件。

权威源资源与权利证明

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

作者 / 机构: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | 原始出处链接 ↗

对应章节 / 时间戳: Chapter Optimization Algorithms: Gradient Descent; learning-rate selection

验证版本与日期: Current online edition (Verified: 2026-10-30)

入选理由:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

来源前置条件:

Linear algebra, calculus, and probability at the Days 19-28 level.

安全回退方案(离线弹性):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

对比候选资源与选型分析 (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

作者 / 机构: Grant Sanderson (3Blue1Brown) | 原始出处链接 ↗

对应章节 / 时间戳: Neural networks chapter 2: step size intuition

验证版本与日期: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

入选理由:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

来源前置条件:

High-school functions and slope intuition.

安全回退方案(离线弹性):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

对比候选资源与选型分析 (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

03 120 分钟

鞍点与诚实的失败分析

仅在记录预测与观察证据之后允许求助。

前置要求

完成活动 30-02;求助前先预测。

学习目标

用 f(x,y) = x² − y² 解释为什么梯度为零不是极小值,并练习在不虚构成功的前提下报告优化失败。

操作指引

在鞍点处梯度为 0,但该点不是极小值:对 f(x,y) = x² − y²,原点在 x 方向是极小、在 y 方向是极大。梯度下降按 x ← x(1−2η) 更新,但 y ← y(1+2η):精确算术中 y = 0 保持为 0,所以从 (0.5, 0) 出发会收敛到 (0,0)——一个鞍点——而微小的 y₀ = 0.001 会缓慢逃出(y₁₀ ≈ 0.006,到 k = 20 时 f 已为负)。失败分析规则:报告观察到的轨迹、诊断出的原因与修复——永远不要把失败粉饰成成功。

自主演练与记录

(a) 验证 ∇f = (2x, −2y) 在 (0,0) 处为零,且对任意 ε ≠ 0 有 f(0, ε) = −ε² < 0。(b) 从 (0.5, 0) 以 η = 0.1 出发,10 步后梯度下降到达哪里?该点是极小值吗?(c) 训练日志显示损失 2.0 → 2.6 → 3.5 → 4.9 → 6.8:写诚实的失败分析条目——原因假设、修复、复查。

独立掌握标准

用 −ε² 论证验证鞍点,被困轨迹计算正确,失败条目记录原因、修复与复查且不虚构改进。

权威源资源与权利证明

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

作者 / 机构: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | 原始出处链接 ↗

对应章节 / 时间戳: Chapter Optimization Algorithms: Optimization and Deep Learning (local minima, saddle points)

验证版本与日期: Current online edition (Verified: 2026-10-30)

入选理由:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

来源前置条件:

Linear algebra, calculus, and probability at the Days 19-28 level.

安全回退方案(离线弹性):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

对比候选资源与选型分析 (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

作者 / 机构: Grant Sanderson (3Blue1Brown) | 原始出处链接 ↗

对应章节 / 时间戳: Neural networks chapter 2: valleys, plateaus, and saddle intuition

验证版本与日期: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

入选理由:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

来源前置条件:

High-school functions and slope intuition.

安全回退方案(离线弹性):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

对比候选资源与选型分析 (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.

04 120 分钟

考核:预测、分类并诊断优化行为

独立掌握检查(无 AI 辅助)。

前置要求

完成活动 30-01 至 30-03;独立闭卷。

学习目标

在无辅助下把优化机制迁移到新的二次函数,对一个学习率分类,并诊断给定的失败。

操作指引

在 g(x) = 2x² 上梯度为 4x,故 x ← x(1 − 4η)。先预测再分类:x₀ = 2、η = 0.3 时因子为 −0.2——收敛、振荡还是发散?计算 x₁、x₂、x₃。给出 g 的稳定上界。最后诊断损失轨迹 2.0 → 2.6 → 3.5 → 4.9 并写出纠正条目。

自主演练与记录

g(x) = 2x²、x₀ = 2、η = 0.3:(a) x_k 的闭式;(b) x₁、x₂、x₃ 及所属形态;(c) η 的稳定上界;(d) 诊断损失轨迹 2.0 → 2.6 → 3.5 → 4.9 并写出一行纠正措施。

独立掌握标准

闭式、三个迭代值、形态与上界全部无辅助正确,诊断指出原因与纠正措施——以诚实的失败分析收束数学模块。

权威源资源与权利证明

linking CC BY-SA 4.0 (book text) / modified MIT (sample code) share-alike

Dive into Deep Learning (d2l.ai)

作者 / 机构: Aston Zhang, Zachary C. Lipton, Mu Li, Alexander J. Smola | 原始出处链接 ↗

对应章节 / 时间戳: Chapter Optimization Algorithms: Gradient Descent; Optimization and Deep Learning

验证版本与日期: Current online edition (Verified: 2026-10-30)

入选理由:

Primary open reference tying evaluation discipline (model selection, underfitting, overfitting) and optimization algorithms (gradient descent, minibatch) to the rest of the curriculum.

来源前置条件:

Linear algebra, calculus, and probability at the Days 19-28 level.

安全回退方案(离线弹性):

All required formulas and worked numbers are reproduced as original explanations; the book is further reading.

对比候选资源与选型分析 (2)
Deep Learning (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Detailed treatment of optimization difficulties (chapter 8) including saddle points and plateaus; all-rights-reserved text kept as a linking-only alternative.

fast.ai: Practical Deep Learning for Coders ↗ compared_alternative [Course site copyright / Apache-2.0 (fastai code)]

Strong practitioner framing, but organized around the fastai library and video lessons rather than self-contained mathematics.

linking 3Blue1Brown copyright (all rights reserved); site FAQ permits only short clips under stated conditions No video, audio, transcript or frame redistribution permitted

Gradient Descent, How Neural Networks Learn

作者 / 机构: Grant Sanderson (3Blue1Brown) | 原始出处链接 ↗

对应章节 / 时间戳: Neural networks chapter 2: the gradient and the descent update

验证版本与日期: Neural networks series chapter 2, 2017 (Verified: 2026-10-30)

入选理由:

Visual intuition connecting the gradient vector to steepest descent; complements d2l.ai's worked equations for the optimization day.

来源前置条件:

High-school functions and slope intuition.

安全回退方案(离线弹性):

The lesson contains complete derivations and numerical traces; the video is optional visual intuition.

对比候选资源与选型分析 (2)
Convex Optimization (Boyd and Vandenberghe) ↗ compared_alternative [Cambridge University Press; free PDF for individual use]

A detailed optimization text, kept as an advanced alternative; its scope exceeds a single study day.

Deep Learning chapter 8 (Goodfellow, Bengio, Courville) ↗ compared_alternative [MIT Press; free HTML for reading, all rights reserved]

Rigorous discussion of saddle points and plateaus in high-dimensional optimization; kept as a linking-only alternative.