数学

梯度下降

梯度下降沿着负梯度方向最小化函数。调整学习率,观察步长如何影响收敛。

7 分钟难度 3/3交互演示区域不展示广告。
x2.500f(x)6.250Steps0Learning rate0.25

x_new = x − η·f′(x) = 2.50 − 0.25 × (5.00) = 1.25

Drag the ball or use arrow keys to choose a start.

The ball follows the negative slope. The dashed tangent and ghost point show the next update. Small rates crawl, a well-chosen rate settles, and a rate that is too large overshoots or diverges. Drag the ball, click the curve, or focus the canvas and use the arrow keys to choose a start.

你看到的是什么

1

曲线是损失函数,目标是找到最低点。

2

每一步计算斜率,并沿相反方向移动。

3

学习率太小会走得很慢;太大会过冲甚至发散。动量可以平滑路径。

为什么重要

梯度下降是机器学习的核心工具。神经网络、逻辑回归和大量优化问题都用它的变体训练。

复杂度与细节

每步对 d 个参数需要 O(d)。收敛速度取决于学习率和函数曲率。

常见问题

学习率太大会怎样?+

步长可能跨过最低点、来回震荡,甚至发散。较小的学习率更稳,但更慢。

为什么要用动量?+

动量累积过去的梯度,平滑噪声更新,并在平坦区域加速。