Deep Learning Lab

Interactive math figures

用同一个声明式组件绘制文章与概念页中的数学图。二维图使用响应式 SVG,可以随指针和键盘滑块更新;未来的三维曲面会从同一入口按需加载 WebGL renderer。

二维函数

From log-odds to probability
z 0.0 →0.500
0.0
z is the log-odds of class 1. Sigmoid returns 0.5 at z = 0 and preserves the ordering of the scores.
From a hard threshold to a smooth one
z 0.0
Sigmoid 0.500 Step function 1.000
0.0
The step function is 0 on one side of the threshold and 1 on the other, with nothing in between. Sigmoid spreads the same threshold into a continuous ramp, so the output can move a little when the input does.
Four common activation functions
z 0.0
Sigmoid 0.500 Tanh 0.000 ReLU 0.000 GELU 0.000
0.0
All four change slope near the origin, but they make different choices about negative inputs, output range and whether the tails flatten. Note that they do not share the same vertical scale.
Two one-sided detectors added together
d 0.5
|d| 0.500 Linear d 0.500
0.5
d = x₁ − x₂. Plain subtraction goes negative when d < 0, which amounts to saying that only one direction counts. Two ReLUs fold both directions onto the positive side, and their sum is |d|.
A straight line cannot follow a band
x 21.0
Target (comfortable = 1) 1.000 Linear score z 0.150
21.0
The target is 1 between 18 and 24 °C and 0 on both sides. A linear score z = wx + b is monotone, so the region where z ≥ 0 is always a ray — it can never cover only the middle.
Two hinges enclose a band
x 21.0
Score z 2.000 h₁ = degrees above 22 0.000 h₂ = degrees below 20 0.000
21.0
h₁ only opens above 22 °C, h₂ only opens below 20 °C. The score z = 2 − h₁ − h₂ crosses zero once at 18 °C and once at 24 °C, enclosing exactly the target band.

平面图

没有卡片外壳的二维图,用点、直线和半平面着色。适合决策边界这类示意图。

0101x₁x₂

y = 1 y = 0

AND:只有 (1,1) 在 z>0 一侧。
0101x₁x₂

y = 1 y = 0

OR:只有 (0,0) 在 z<0 一侧。

三维曲面

三维图把两个输入或参数放在平面上,再用高度表达函数输出。两个示例共享同一套 WebGL 运行时,但拥有不同的交互控制。

双参数线性回归的损失曲面
拖动旋转曲面,播放或移动步数滑块,观察参数如何沿梯度逐步靠近最低点。
J(w₁, w₂)step 0 · J 7.940
正在生成曲面…
0
横向两个轴是模型参数 w₁、w₂,高度是损失 J。梯度下降不是让数据点往下掉,而是在参数空间中寻找让损失更小的位置。
双特征逻辑回归的概率曲面
改变偏置 b,观察概率曲面和 p = 0.5 的决策边界怎样一起移动。
p = σ(1.2x₁ − 0.9x₂ + b)b 0.0
正在生成曲面…
0.0
横向两个轴是特征 x₁、x₂,高度是属于类别 1 的概率。白线上的概率恰好为 0.5,它投影到特征平面后就是线性决策边界。