返回故事列表Deep Learning Core
從鏈式法則到Transformer:訓練萬億參數AI的5個核心數學公式
Step-by-step mathematical anatomy of how Matrix Multiplication, Dot Product, Softmax, Cross-Entropy, and the Chain Rule power modern AI.
Forward Pass uses Matrix Multiplication and scaled Dot-Product Attention to compute contextual token representations.
Cross-Entropy Loss measures the Kullback-Leibler divergence between predicted token probabilities and ground truth.
Backpropagation applies the Calculus Chain Rule backward through layers to compute exact parameter gradients.
1. Why Divide by √d_k in Scaled Dot-Product Attention?
If q and k have independent unit-variance components, their dot product has variance d_k. Dividing by √d_k restores unit variance, preventing Softmax saturation and vanishing gradients.
2. The Miraculous Derivative of Softmax + Cross-Entropy
Differentiating Cross-Entropy Loss with respect to raw logits z_i cancels out the exponentials and logarithms via the Chain Rule, leaving the remarkably clean error signal (predicted_prob - true_label).