Northeastern University · CS 7150 · Fall 2026

Losses and regularization

What a network is trained to minimize. First the loss itself: softmax, cross-entropy and KL, and why cross-entropy beats squared error, as in homework 1. Then the regularizers, which all change that objective: a penalty on the weights, noise injected while training, the noise of the minibatch itself, and the capacity of the network.

  1. Softmax

    Softmax

    Drag the logits and watch the probabilities, and the Jacobian ∂pi/∂zj as a live matrix (homework 1 question 1.3.1). Adding a constant to every logit changes nothing, each row of the Jacobian sums to zero, it all flattens when one class dominates, and a temperature slides softmax between argmax and uniform.

    Open the explainer →
  2. Cross-entropy, KL, entropy

    Cross-entropy, KL and entropy

    Homework 1’s questions 1.3.2–1.3.3 with n classes: drag the logits and the target (one-hot, label-smoothed, mixup, or free) and watch CE split into the target’s entropy plus the KL, with the gradient p − y drawn on every logit. Against a one-hot target the loss never reaches zero, so descent pushes the logits apart forever; label smoothing gives it a finite minimum.

    Open the explainer →
  3. Why cross-entropy

    Squared error vs. cross-entropy

    Why classifiers train better with cross-entropy than with the quadratic cost, as Glorot & Bengio remark, and homework 1 question 1.3.4 asks. Both are negative log-likelihoods (squared error is a Gaussian’s, and a KL between Gaussians); the difference is that squared error’s gradient keeps the sigmoid’s slope and vanishes when the output is confidently wrong, while cross-entropy’s log cancels it.

    Open the explainer →
  4. Weight decay

    Weight decay: L2 against L1

    Homework 2.1’s penalty makes every gradient step a shrink first. Read as a budget, L2 is a ball and L1 a diamond whose corners zero out weights. A penalty turns a wildly bumpy twelve-point fit smooth, and inside Adam the same penalty is not weight decay, which is why AdamW exists.

    Open the explainer →
  5. Dropout

    Dropout

    The lecture's two-input neuron with all four masks enumerated: their average is (1−p) times the full output, which is why test time scales by 1−p, or inverted dropout scales while training. Then the cat-feature example as 32 subnetworks, co-adapted against redundant, and two networks overfitting 40 noisy points live, one with dropout.

    Open the explainer →
  6. The regularization pattern

    Train with noise, test by averaging it out

    Early stopping on live train and validation curves; a picture flipped, cropped, jittered, cut out and mixed up; the same small network trained on one quarter of a ring, with and without random rotations, learning the symmetry only when shown it; and a table of how dropout, BatchNorm, augmentation, mixup and stochastic depth each add noise while training and average it away at test time.

    Open the explainer →
  7. Gradient noise

    Batch size, learning rate, and gradient noise

    A minibatch gradient is the full gradient plus noise that shrinks like 1/√B, and vanishes at B = N (HW2.1’s full batch). SGD settles into a cloud whose size is set by lr/B, which is why the linear scaling rule works, until lr passes 2/λmax. And enough noise carries SGD out of a sharp minimum into a wide one.

    Open the explainer →
  8. Capacity

    Width, and double descent

    Homework 2.1's shrinking experiment in miniature: seven networks of widths 2 to 128 train live on the same 60 points with some labels flipped, and the wide ones draw islands around the wrong labels. Then the rest of the story: least squares with more and more features, whose test error spikes where the features just match the points and falls again beyond it.

    Open the explainer →