Lesson deck

CNNs, ResNets, transfer learning and recurrent networks, with RMSNorm and label smoothing flashcards

Reviewing needs JavaScript. You can read every card in the list below.

Loading your cards...

Back to the lesson10 cards in this deck

Read all 10 cards as a list
  1. Front
    Output size and parameter count of a convolution layer?
    Back
    Per axis: floor((n + 2p - k) / s) + 1, with p zeros on each side; height and width are separate. Parameters: k_h x k_w x c_in x c_out + c_out, independent of the image size. A 3x3 conv from 3 to 64 channels has 1,792; a dense layer to the same 32x32x64 output would need 201,326,592 weights.
  2. Front
    How do you compute a receptive field for a stack of layers?
    Back
    Start with r = 1 and jump j = 1. For each (kernel k, stride s): r = r + (k - 1) * j, then j = j * s. Three 3x3 stride-1 layers: 7. Three 3x3 stride-2 layers: 15. Pool (2, stride 2) then a 3x3 conv: 6; the other order: 4. Derived here; it matches CS231n's 7x7 for three 3x3 layers.
  3. Front
    What does weight sharing give a convolution, and what does pooling add?
    Back
    Sharing one kernel across positions gives far fewer parameters and translation equivariance: shift the input and the output shifts. Pooling has no parameters and works per channel; it gives invariance only to shifts inside its window (a pixel moving from position 3 to 4 changed the 2x2 stride-2 pooled output in the lesson's script).
  4. Front
    Why does y = x + F(x) help deep networks train, and what does it not do?
    Back
    He et al. report degradation (deeper plain nets have higher training error, not from overfitting) and fix it by fitting the residual F(x) = H(x) - x; doing nothing means F near 0. The Jacobian is I + J_F, so a gradient has an identity path (derived here). It does not cap the gradient: an unscaled residual stack returned a gradient norm of 22.6 at depth 50, against 0.0183 plain.
  5. Front
    What is the fine-tuning recipe, and what must augmentation respect?
    Back
    Pretrain on a source task, copy everything except the output layer, randomly initialise a new output layer, train it from scratch at a larger rate (10x in the book) and fine-tune the rest at a small rate. Freeze the backbone with very little data (common practice). Augmentation is training-only and must keep the label: a left-right flip is fine for a cat, wrong for digits or text.
  6. Front
    Why do RNN gradients vanish or explode, and what does clipping fix?
    Back
    dh_T/dh_0 is a product over steps of diag(1 - h^2) W_h. With zero input the state stays near 0 and the factor is w: w = 0.9 gives 0.00515 at 50 steps, w = 1.5 gives 6.38e8. With constant input 0.1 the large weight saturates the state (h = 0.894 for w = 1.5, 0.996 for w = 3), the factor w(1 - h^2) is 0.302 or 0.025, and the gradient vanished (7.55e-24 and 6.55e-75 at 50 steps). Clipping caps large gradients but cannot raise vanished ones.
  7. Front
    Write the LSTM update and say why it helps gradients.
    Back
    i, f, o = sigmoid(...), g = tanh(...); c_t = f * c_(t-1) + i * g; h_t = o * tanh(c_t). The direct derivative of c_t with respect to c_(t-1) is diag(f), with no matrix multiplication or squashing, so gates near 1 keep the gradient (0.99^100 = 0.366, 0.5^100 = 7.89e-31). The full derivative has extra terms through the gates, so this is the direct path.
  8. Front
    Write the GRU update. Parameter counts for d = 10, H = 20?
    Back
    r, z = sigmoid(...); n = tanh(W_in x + b_in + r * (W_hn h + b_hn)); h_t = (1 - z) * n + z * h_(t-1) in PyTorch's convention; z near 1 keeps the old state. PyTorch has two biases per gate: LSTM 4H(d + H + 2) = 2,560 and GRU 3H(d + H + 2) = 1,920, against 2,480 and 1,860 with one bias. The counts do not depend on sequence length.
  9. Front
    RMSNorm versus layer norm?
    Back
    RMSNorm divides by sqrt(eps + mean(x^2)) and does not subtract the mean. Both ignore a global rescale; only layer norm ignores adding a constant (x + 5 left layer norm unchanged and changed RMSNorm). The paper says re-centring is dispensable and reports 7% to 64% less running time on its models.
  10. Front
    Label-smoothed target, loss floor and optimal logit gap?
    Back
    q_k = (1 - eps) * [k = y] + eps / K: for K = 10 and eps = 0.1 that is 0.91 and 0.01. The gradient on the logits is p - q, so the best gap is ln(0.91 / 0.01) = 4.511, and the loss floor is the entropy of q, 0.5003, not 0. Loss values are not comparable across smoothing settings. The paper used eps = 0.1 and reported about 0.2 points of error.