Sigmoid
二分类:把一个分数压到 0–1,变成一个概率。
先看神经网络怎样从输入走到新权重,再把 Sigmoid、Softmax、Cross Entropy 与 KL 放回同一个概率学习流程中。
二分类:把一个分数压到 0–1,变成一个概率。
多分类:把多个 logits 变成总和为 1 的概率分布。
给模型打分:真实类别的预测概率越低,Loss 越大。
衡量两个概率分布差多少;训练的本质是让这个差异越来越小。
例如 \(z=[1,2,3]\),必须先算 \(e^1,e^2,e^3\),再除以指数和;答案不是 \([1/6,2/6,3/6]\)。实际计算时可先减去 \(\max(z)\),结果不变且更稳定。For \(z=[1,2,3]\), first compute \(e^1,e^2,e^3\), then divide by their sum; the answer is not \([1/6,2/6,3/6]\). Subtracting \(\max(z)\) first gives the same result with better numerical stability.
同一个输入出现 100 次,其中 80 次标签为 1、20 次为 0。模型看不到可区分信息时,交叉熵下的最优输出是 \(P(y=1\mid x)=80/100=0.8\)。The same input appears 100 times: 80 labels are 1 and 20 are 0. With no distinguishing information, the Cross Entropy optimum is \(P(y=1\mid x)=80/100=0.8\).
The optimal prediction equals the empirical class probability.
隐藏层把 6D 输入映射成 \((h_1,h_2)\)。每个输出神经元在这个表示空间中学习自己的 decision boundary;隐藏层的目标是让后续类别更容易线性分离。The hidden layer maps a 6D input to \((h_1,h_2)\). Each output neuron learns its own decision boundary in this representation space, making the classes easier to separate linearly.
The hidden layer learns a representation in which the outputs become linearly separable.
矩阵乘法与偏置可以合并。因此堆叠 linear transfer functions 不会增加表达能力。
非线性激活打破 \(Wx+b\) 的合并,使网络能形成弯曲、分段或复杂的 decision boundary。没有非线性,再深也只是线性模型。Nonlinear activations prevent collapse into \(Wx+b\), allowing curved, piecewise, or complex decision boundaries. Without nonlinearity, depth still produces only a linear model.
当输出接近 0 或 1,Sigmoid 进入饱和区,导数很小。多层反向传播继续相乘后,学习信号可能接近 0。
交叉熵会抵消 Sigmoid 导数,输出层对 logit 的梯度简化为 z − t。即使预测很错,仍能提供较强学习信号。
正确类别分量为 \(p_y-1\),其他类别分量为 \(p_j\)。这里的 \(y\) 是 one-hot target。For the correct class, the component is \(p_y-1\); every other component is \(p_j\). Here \(y\) is the one-hot target.
它与 Cross Entropy 梯度方向相反,因为 Cross Entropy 前面多了负号。先看清题目是 \(\log p_y\) 还是 \(-\log p_y\)。Its gradient points in the opposite direction because Cross Entropy has a leading minus sign. Check whether the question uses \(\log p_y\) or \(-\log p_y\).
SSE combined with sigmoid may produce very small gradients when the output neuron is saturated. Cross Entropy cancels the sigmoid derivative, resulting in the simple gradient z−t, which provides stronger learning signals and faster convergence.
SSE 与 Sigmoid 结合时,在输出接近 0 或 1 的饱和区容易出现梯度很小的问题;而 Cross Entropy 会抵消 Sigmoid 导数,最终梯度简化为 z−t,因此训练更稳定、收敛更快。
很多小于 1 的导数跨层相乘,梯度越来越小,前面层几乎学不到。
较大的导数反复相乘,梯度迅速放大,更新不稳定。
合适的参数尺度让激活与梯度在层间保持合理范围。
BatchNorm 稳定激活分布;Residual 提供梯度捷径。
Sigmoid 在饱和区导数接近 0,多层反向传播时梯度不断相乘,容易导致 vanishing gradient。
ReLU 在正区间导数为 1,梯度更容易传播;但负区间长期无激活时可能出现 dead ReLU。
训练时先用 mini-batch 的 mean 与 variance 标准化:\(\hat{x}=(x-\mu_B)/\sqrt{\sigma_B^2+\epsilon}\),再用可学习的 \(\gamma,\beta\) 缩放和平移。它让训练更稳定、通常更快收敛;核心定义是 normalization,不要只回答“正则化”。During training, BatchNorm uses the mini-batch mean and variance: \(\hat{x}=(x-\mu_B)/\sqrt{\sigma_B^2+\epsilon}\), then applies learnable \(\gamma,\beta\) scale and shift. It stabilizes training and usually speeds convergence; its defining operation is normalization.
引入 skip connection,网络学习残差 F(x),输出为 x + F(x)。梯度可沿捷径传播,缓解梯度消失,使更深网络可训练。