Early Stopping & Parameter Sharing
Two cheap regularizers that cost no extra term in the loss. Early stopping treats training time itself as a hyperparameter (watch the validation curve, halt at its minimum, keep the best checkpoint), and for a quadratic objective it is provably equivalent to weight decay.
╌╌╌╌
The regularizers of the previous lessons add a term to the loss: an penalty, a dropout mask. This lesson covers two that add no term and still constrain the hypothesis space. Early stopping controls capacity through the optimization trajectory: it limits how far the weights travel from their initialization. Parameter sharing controls it through the parameterization itself: it forces distinct weights to take a single shared value. Both shrink the effective number of free parameters without ever appearing in .
Early stopping
Train a high-capacity network long enough and the training loss falls monotonically while the validation loss traces a U: down as the model learns real structure, then back up as it begins to fit noise. The gap between the two curves is the generalization gap, and it widens precisely in the regime where training continues to pay off but validation does not.
The recipe is to treat the number of training steps as a hyperparameter and tune it on the validation set: evaluate validation loss every epoch, remember the parameters that achieved the lowest value seen, and return those rather than the final ones.1
Because the validation curve is noisy, we do not halt at the first uptick. The patience parameter specifies how many consecutive non-improving evaluations to tolerate before stopping, a guard against quitting on a transient bump.
The full procedure keeps a running best checkpoint and a counter of stale evaluations.
- 1initialize randomly
- 2best checkpoint so far
- 3best validation loss so far
- 4evaluations since last improvement
- 5repeat
- 6train one epoch onstandard gradient steps
- 7validate
- 8if thenimproved
- 9
- 10
- 11
- 12elsestale
- 13
- 14until
- 15returnthe best checkpoint, not the last
Two practical points fall out of the algorithm. First, early stopping is nearly free: the only overhead is one validation pass per epoch and a copy of the best weights. Second, it composes with every other regularizer (it is a stopping rule, not a loss term) and is the one regularizer essentially every training run uses.2
The reason the validation curve turns upward is that effective capacity grows with training time. At initialization the weights are near the origin and the function the network computes is nearly constant; each gradient step lets the weights travel farther and the function it can express becomes richer. Training time therefore behaves like a continuous capacity knob. Early in training the extra capacity captures real structure and both losses fall; past the extra capacity goes toward memorizing the training set, and validation loss climbs while training loss keeps falling. Stopping at caps the effective capacity at the level that best matches the data.
| Property | Early stopping |
|---|---|
| Cost | one validation pass per epoch; one stored checkpoint |
| Extra loss term | none |
| Hyperparameters | patience , evaluation frequency |
| Returns | at validation minimum |
| Data cost | a held-out validation split (retrain on full data after, optionally) |
| Composes with | , dropout, augmentation — all of them |
A subtlety: early stopping spends a validation split that could otherwise be training data. One remedy is to record , then retrain from scratch on the union for steps; another is to keep training the existing model on the validation data until its loss falls below the level reached at . Both recover the held-out examples at the cost of a second training run.
Early stopping is regularization
Early stopping looks like a heuristic about wall-clock time, but for a quadratic objective it is exactly a norm penalty. The mechanism: gradient descent started at can only move so far in a finite number of steps, so halting early keeps near the origin: the same constraint weight decay imposes by penalizing .3
The correspondence is exact in its consequences for each eigendirection. Along a stiff direction (large ) the factor is small, so reaches in a few steps: these weights are learned early and unaffected by the penalty. Along a flat direction (small ) progress is slow; halting at step leaves short of , exactly the directions shrinks most.
The per-axis factor , read as a function of , shows the selectivity. A stiff axis has close to , so within a handful of steps and the factor saturates at : the coordinate is fully learned. A flat axis has , so still after steps and the factor stays near : the coordinate barely moves off the origin. The factor traces the same S-curve against — near for , near for — with the crossover set by instead of by .
| Early stopping | weight decay | |
|---|---|---|
| Control knob | number of steps | penalty |
| Effective strength | ||
| Stiff directions ( large) | learned fully | barely shrunk |
| Flat directions ( small) | left near origin | shrunk hard |
| Knob set by | validation curve | validation grid search |
| Cost | single training run | one run per |
Early stopping wins on cost: it discovers the effective penalty during a single training run by reading it off the validation curve, whereas tuning requires a separate run for each candidate value.
Parameter sharing
Early stopping shrinks weights toward a point. Parameter sharing instead ties weights to each other: it declares a set of weights to be one and the same free parameter, so the optimizer adjusts them in lockstep. Where an penalty expresses a soft preference that two weights be close (parameter tying, ), sharing is the hard constraint that they be identical.
The prior behind sharing is equivariance: if a feature detector is useful at one location in the input, it is useful at every location. Two architectures are built entirely on this idea.4
The gradient of a shared weight is a sum. Suppose a single free parameter is used at locations, appearing in the forward pass as copies . Treat the copies as independent for a moment and let be the local gradient at location . By the chain rule, the derivative of the loss with respect to the one shared value is the sum of the per-location contributions,
since for every copy. Backpropagation through a shared weight computes the ordinary local gradient at each location where the weight is used and accumulates them into one number. Every location contributes to the single shared value's update; a convolution kernel is updated by the summed signal from every patch it slid over, an RNN weight by the summed signal from every time step. This accumulation is why a shared parameter, seeing locations worth of gradient per example, is more sample-efficient than independent parameters that each see one.
Convolutions share across space
A convolutional layer applies one small filter at every spatial position. The same weights are reused across the whole image, so a filter that finds a vertical edge finds it everywhere: translation equivariance, baked into the parameterization.
Recurrence shares across time
A recurrent network applies one cell at every time step. Unrolled, the network looks deep, but every step reuses the same weight matrices: sharing across time, the sequence analogue of the CNN's sharing across space.
What sharing buys
The payoff is a collapse in the parameter count. A dense layer connecting every input to every output scales as the product of their sizes; a shared layer scales only as the size of the shared unit. For a single channel mapping an image with a filter, the contrast is stark.
| Layer | Free parameters | |
|---|---|---|
| Dense () | ||
| Convolution ( filter) | ||
| RNN step (hidden , input ) | — | |
| Unrolled RNN over steps | (shared, not ) | — |
Five orders of magnitude separate the dense layer from the convolution computing a comparable feature. The savings is not merely memory: fewer free parameters is directly lower capacity, hence the regularizing effect. The model cannot fit a position-specific quirk because it has no position-specific weights to fit it with.5
Weight tying, multi-task learning, and ensembles
Three further regularizers reuse parameters or models. Each constrains the hypothesis space by sharing.
Weight tying
A network may reuse one weight matrix in two roles. The tied autoencoder sets the decoder weights to the transpose of the encoder's, , halving the parameters and enforcing a clean encode/decode symmetry. In language models, input–output embedding tying shares the token-embedding matrix with the output projection that scores the vocabulary: the two are the same matrix, a large saving when the vocabulary is tens of thousands.
Multi-task learning
When several related tasks share a trunk of layers and branch only at task-specific heads, the shared parameters must serve every task at once. That shared pressure is a regularizer: a representation good for many tasks is less able to overfit the idiosyncrasies of any one of them.
Bagging and the implicit ensemble of dropout
Bagging (bootstrap aggregating) trains models on resampled datasets and averages their predictions. Independent errors partly cancel under averaging, so the ensemble's variance falls.
Dropout is bagging made implicit and cheap. Each forward pass samples a random sub-network by masking units; over training, exponentially many sub-networks are trained, all sharing the underlying weights. Test-time weight scaling approximates averaging their predictions: an ensemble of models with the parameter budget of one.
| Method | Models | Parameters | Members trained | Combination |
|---|---|---|---|---|
| Bagging | explicit, independent | one model | each on a bootstrap sample | average predictions |
| Dropout | implicit, weight-shared | one model | each on one minibatch | weight-scaling at test |
Bagging pays times the parameters and compute for genuinely independent members; dropout reuses one parameter set across an exponential family of sub-networks, trading independence for near-zero overhead — parameter sharing once more, now across the members of an ensemble.6
Early stopping in the overparameterized regime
The early-stopping-equals- result is classical (it traces to Bishop, 1995, and
the quadratic analysis Goodfellow §7.8 reproduces). What has changed is the setting
it operates in.
In the overparameterized regime, where
training error reaches zero and validation error can descend a second time past the
interpolation threshold, the validation curve is no longer a clean U, so the halt at the first minimum
rule can stop too early; modern practice relies on patience and,
increasingly, on training to a fixed compute budget rather than to a validation
minimum at all.
Parameter sharing, meanwhile, has only grown more central. Beyond the CNN and RNN cases above, cross-layer weight sharing in transformers (ALBERT, Lan et al., 2020) ties the parameters of every transformer block to one shared set, cutting a large model's parameter count by an order of magnitude with modest accuracy cost — the DEQ from deep equilibrium models is the extreme limit of this idea, a single shared block iterated to convergence. Input-output embedding tying (Press & Wolf, 2017; Inan et al., 2017) is now standard in language models for the vocabulary-scale saving described above, and the sample-efficiency argument for shared parameters — one weight, many gradient signals per example — explains why convolution and attention, both built on sharing, scale where dense layers cannot.
Takeaways
- Early stopping halts at the validation-loss minimum and returns the best checkpoint, guarded by a patience parameter; it adds no loss term and one validation pass per epoch.
- For a quadratic objective, steps of gradient descent from the origin equals regularization with : stopping early shrinks the flat (small-) directions exactly as a norm penalty does, but discovers the strength in a single run.
- Parameter sharing forces weights to be equal (the hard limit of soft parameter tying); it is the prior of translation/time equivariance behind CNNs (shared filters across space) and RNNs (shared cell across time), collapsing parameter counts by orders of magnitude.
- Weight tying (tied autoencoders, input–output embeddings), multi-task learning (shared trunk), and dropout (an implicit weight-shared ensemble, the cheap cousin of explicit bagging) all regularize by sharing parameters or models rather than by penalizing them.
Footnotes
- Goodfellow, Deep Learning, §7.8 — Early Stopping: training time as a hyperparameter, the patience-guarded best-checkpoint rule, and the strategies for recovering the held-out validation data afterward. ↩
- Chollet, Deep Learning with Python, §7.3.3 — Using Callbacks: the
EarlyStoppingandModelCheckpointcallbacks that monitor validation loss and restore the best weights. ↩ - Goodfellow, Deep Learning, §7.8 — Early Stopping as : for a quadratic objective, gradient steps from the origin equal weight decay with , shrinking the flat eigendirections. ↩
- Goodfellow, Deep Learning, §7.9 — Parameter Tying and Parameter Sharing: the equivariance prior, the hard equality constraint of sharing versus the soft tying penalty . ↩
- Goodfellow, Deep Learning, §9.2 — Convolution and Parameter Sharing: one filter reused across every spatial position collapses the parameter count to the filter size and bakes in translation equivariance. ↩
- Goodfellow, Deep Learning, §7.11 — Bagging and Other Ensemble Methods: averaging models cuts error variance by up to , and dropout is the implicit weight-shared limit of this idea. ↩
╌╌ END ╌╌