S2-12 · 进阶 · 3DS2-12 · Advanced · 3D

梯度 · 脚下哪边最陡Gradient · Which Way Is Steepest Here?

local slope across parameters → steepest ascent vector

梯度是损失对各参数的局部变化率,指向当前位置最陡的上升方向。它不是误差本身;沿相反方向,损失才下降。A gradient collects the local rate of loss change for each parameter and points toward steepest ascent. It is not the error itself; loss falls in the opposite direction.

01 · 站在山坡上01 · Stand on a hillside

不用看整座山,只看脚下的一小块,怎样知道哪边上升最快?Without seeing the whole mountain, can the patch under your feet reveal the fastest way up?

02把球放到损失曲面,读取局部箭头Place the Ball and Read the Local Arrows

唯一变量:球的位置One variable: ball position
θ1
2.35
参数 1parameter 1
θ2
1.80
参数 2parameter 2
‖∇L‖
局部陡峭度local steepness
正在加载曲面;若提示持续显示,则需要 WebGL / three.js。Loading surface; if this remains visible, WebGL or three.js is unavailable.
粉红 = +∇L · 青色 = −∇Lpink = +∇L · cyan = −∇L
双击放球 · 拖动旋转double-click to place · drag to orbit
梯度:最陡上升gradient: steepest ascent
反梯度:下降方向negative gradient: descent
绿环:曲面低谷green ring: basin floor

03梯度不是一个神秘箭头A Gradient Is Not a Mysterious Arrow

position · partials · vector · direction
POSITION

当前位置Current position

一组参数决定球在曲面上的位置。A parameter pair locates the ball.

PARTIALS

分方向变化率Per-axis rates

分别问每个参数轻微增加会怎样。Ask what a small increase on each axis does.

VECTOR

合成向量Combined vector

各方向变化率组成 ∇L。Axis-wise rates form ∇L.

LOCAL

只保证局部Local only

换一个位置,箭头会重新计算。Move elsewhere and the arrow changes.

04最小机制:两个偏导组成一个方向Minimal Mechanism: Two Partial Derivatives Form One Direction

∇L = [∂L/∂θ1, ∂L/∂θ2]
∇L(θ) = [∂L/∂θ1, ∂L/∂θ2]
箭头方向给出最陡上升;箭头长度 ‖∇L‖ 表示局部有多陡。下降要取负号。Direction gives steepest ascent; length ‖∇L‖ gives local steepness. Descent uses the negative.
移动球Move ball参数位置改变parameters change
重算局部斜率Recompute local slopes两个偏导变化partials change
箭头转向缩放Arrow turns and scales显示最陡方向shows steepest direction

05边界实验:在谷底寻找“大梯度”Boundary Test: Demand a Large Gradient at the Bottom

主动制造失败Create a failure

把球放到最低附近Place the ball near the minimum

损失仍是一个正数,但局部几乎平坦,梯度接近零。这直接证明“梯度 ≠ 误差”。Loss remains positive while the surface is locally flat and gradient nears zero. This directly shows gradient is not error.

尚未执行。Not run yet.
梯度就是损失值。Gradient is the loss value. → ✓ 梯度描述损失对参数的局部变化率。Gradient describes local loss change with parameters.
沿梯度走会降低损失。Following the gradient lowers loss. → ✓ 梯度指上坡,下降要沿 −∇L。Gradient points uphill; descent follows −∇L.
一个梯度方向适用于整座曲面。One gradient direction works everywhere. → ✓ 它只属于当前参数位置。It belongs only to the current parameter position.
06 · 一句话带走06 · One line to keep

梯度把各参数的局部变化率合成最陡上坡方向;真正下山要沿它的反方向。A gradient combines local parameter-wise rates into steepest ascent; going downhill means taking its opposite.