Model Efficiency & Scaling1989intermediate11 min read

Optimal Brain Damage

الضرر الدماغي الأمثل

LeCun, Y. · Denker, J. S. · Solla, S. A. — NeurIPS

The problem

Neural networks in the late 1980s were growing larger, but more parameters meant higher risk of and slower . Simply removing the smallest weights (magnitude ) often deleted parameters that were small but critical. There was no principled way to decide which weights to remove without expensive trial-and-error retraining.

The contribution

Optimal Brain Damage introduced a measure based on the diagonal of the matrix — the second derivatives of the with respect to each . Instead of asking "how big is this weight?" (magnitude), OBD asks "how much would the loss increase if I deleted this weight?" The answer is approximated as s_k = h_kk · w_k² / 2, combining curvature (h_kk) with weight value (w_k). Weights with low saliency are pruned, the network is retrained, and the cycle repeats. On a handwritten digit recognition network, OBD removed over 50% of parameters with no loss in accuracy — and sometimes improved .

The impact

OBD was the first principled pruning method and the conceptual ancestor of modern compression. Its idea — use curvature to measure importance — directly inspired Optimal Brain Surgeon, and its DNA runs through Deep Compression, the Lottery Ticket Hypothesis, GPTQ, and SparseGPT. Today's trillion-parameter models make pruning more relevant than ever, and every modern method traces its lineage to this 1989 paper.

Imagine you have built an elaborate circuit board with thousands of wires. Many of them carry critical signals; some carry almost nothing. You want to simplify the board — fewer wires means cheaper manufacturing, less heat, and fewer chances for to cause errors.

The naïve approach: clip the thinnest wires (magnitude pruning). But a thin wire carrying a high-frequency timing signal is more important than a thick wire carrying a redundant ground path.

OBD's approach: before clipping any wire, measure how much the circuit's output would degrade if that wire were removed. This measurement uses the curvature of the error surface — how sensitive the output is to small changes in each wire. Wires where the output barely budges get clipped first.

The dilemma: large networks overfit, small ones underfit

By the late 1980s, neural networks were achieving strong results on real-world tasks like handwritten digit recognition. But practitioners faced a fundamental tension: a network with too many parameters memorizes the data and generalizes poorly (overfitting), while a network with too few parameters cannot capture the underlying patterns ().

The ideal solution is to find the right-sized network — one with just enough parameters to model the data, and no more. But how do you find that sweet spot? You could train many networks of different sizes and compare them, but that is prohibitively expensive. LeCun, Denker, and Solla proposed a far more elegant approach: start with a network that is too large, then surgically remove the parameters that contribute the least.

Open in Lab
Drag the slider to explore the tradeoff: too many parameters (overfitting) vs too few (underfitting). OBD finds the sweet spot by pruning excess parameters.
The demo wakes as you arrive…

Why "small weight = unimportant" is wrong

The most obvious pruning strategy is magnitude pruning: rank all weights by their absolute value and delete the smallest ones. The intuition is simple — a weight near zero contributes little to the output, so removing it should not matter much.

But this intuition is dangerously incomplete. Consider a weight that is small in value but sits on a steep slope of the loss surface. Removing it causes the loss to increase sharply — like removing a small but critical bolt from a bridge. Conversely, a weight that is large but sits in a flat valley of the loss surface can be removed with minimal effect — like removing a heavy but redundant support beam.

The key insight of OBD is that what matters is not the weight's value, but how sensitive the loss is to changes in that weight. This sensitivity is captured by the — the curvature of the loss surface.

Open in Lab
Compare magnitude pruning (left) vs saliency pruning (right). A small weight on a steep curvature is more important than a large weight on a flat surface.
The demo wakes as you arrive…

Saliency: measuring a parameter's true importance

OBD defines the saliency of a parameter as the predicted increase in the loss function when that parameter is set to zero. To compute this without actually deleting each weight and retraining, OBD uses a second-order Taylor expansion of the loss function around the trained weights.

The Taylor expansion of the change in loss δE\delta E when the parameter vector is perturbed by δu\delta u is:

δE=∑igiδui+12∑ihiiδui2+12∑i≠jhijδuiδuj+O(∥δu∥3)\delta E = \sum_i g_i \delta u_i + \frac{1}{2}\sum_i h_{ii} \delta u_i^2 + \frac{1}{2}\sum_{i \neq j} h_{ij} \delta u_i \delta u_j + O(\|\delta u\|^3)

where gi=∂E∂uig_i = \frac{\partial E}{\partial u_i} is the and hij=∂2E∂ui∂ujh_{ij} = \frac{\partial^2 E}{\partial u_i \partial u_j} are the entries of the Hessian matrix.

sk=12hkk uk2s_k = \frac{1}{2} h_{kk} \, u_k^2
The OBD saliency formula — the core of the method — Saliency estimates how much damage would be caused by removing a particular weight from the network. A weight is considered important when changing or deleting it would significantly increase the loss, and unimportant when the network's performance would barely change. OBD uses this estimate to rank weights and remove the least important ones first, reducing model size while preserving accuracy.

Think of each weight as a ball sitting on a curved surface. The saliency formula asks two things: how far is the ball from the bottom of the valley? (the weight value uku_k) and how steep are the valley walls? (the curvature hkkh_{kk}). A ball far up a steep slope will cause a big drop if removed — high saliency. A ball barely off the valley floor, or on a flat plain, barely matters — low saliency.

Open in Lab
Adjust the weight value and curvature sliders to see how saliency changes. The red region shows the predicted loss increase if this weight is deleted.
The demo wakes as you arrive…

Computing second derivatives efficiently

The Hessian matrix for a network with NN parameters has N2N^2 entries — for a 2600-parameter network, that is over 6.5 million numbers. Computing the full Hessian is impractical. But OBD only needs the diagonal entries hkkh_{kk}, which can be computed with a procedure almost identical to standard .

The key observation is that second derivatives propagate backward through the network just like first derivatives. Starting from the , where the second of the loss with respect to the pre-activation is known, we can recursively compute the second derivative at each using the chain rule — the same machinery that computes gradients, applied one level deeper.

The cost of computing the diagonal Hessian is roughly the same as computing the gradient — one additional backward pass. This made OBD practical even on the hardware of 1989.

∂2E∂wij2=zj2⋅∂2E∂ai2\frac{\partial^2 E}{\partial w_{ij}^2} = z_j^2 \cdot \frac{\partial^2 E}{\partial a_i^2}
Diagonal Hessian for a single connection — This equation provides a way to estimate how sensitive the loss is to a particular connection in the network. Connections that have a large impact on the loss are considered more important, while those with little impact can often be removed with minimal effect on performance. OBD relies on these sensitivity estimates to identify redundant parameters and prune the network efficiently.
∂2E∂ai2=f′(ai)2∑kwki2∂2E∂ak2+f′′(ai)∑kwki∂E∂ak\frac{\partial^2 E}{\partial a_i^2} = f'(a_i)^2 \sum_k w_{ki}^2 \frac{\partial^2 E}{\partial a_k^2} + f''(a_i) \sum_k w_{ki} \frac{\partial E}{\partial a_k}
Backward recursion for the second derivative — The second derivative at a hidden unit depends on: (1) the squared derivative of the activation function times the second derivatives at the next layer, and (2) a correction involving the second derivative of the activation function itself. The Levenberg-Marquardt approximation drops the second term, guaranteeing positive curvature estimates.

The OBD recipe: train, measure, prune, repeat

Open in Lab
Click each step to see what happens during the OBD pruning cycle.
The demo wakes as you arrive…

The OBD procedure alternates between training and pruning in a cycle:

Step 1 — Train the network to on the training data, using standard backpropagation.

Step 2 — Compute the diagonal second derivatives hkkh_{kk} for every parameter, using the backward pass described above.

Step 3 — Compute the saliency sk=hkkuk2/2s_k = h_{kk} u_k^2 / 2 for each parameter.

Step 4 — Sort all parameters by saliency and delete the lowest-saliency ones (set them to zero and freeze them).

Step 5 — Retrain the pruned network and repeat from Step 2.

"Deleting" a parameter means setting it to zero and freezing it — it can never come back. Each cycle removes a batch of low-saliency parameters. The process stops when further pruning would significantly degrade performance.

Experiments: pruning a real digit recognizer

LeCun et al. tested OBD on their handwritten digit recognition network — a constrained, sparsely connected architecture with about 105,000 connections controlled by 2,578 free parameters, trained on ~9,300 examples of segmented zip-code digits.

The results were striking. OBD could remove over 60% of parameters (from 2,578 down to ~1,000) with essentially no degradation in test accuracy — and sometimes the pruned network actually generalized better than the original. When used interactively, OBD revealed that an entire layer of the network was largely redundant, enabling the authors to redesign the architecture and halve the parameter count.

Crucially, OBD significantly outperformed magnitude-based pruning. At the same compression ratio, magnitude pruning caused much larger increases in the . Random deletion was so destructive that its results could not even be plotted on the same scale.

Open in Lab
Compare OBD vs magnitude pruning as parameters are removed. OBD maintains lower error at every compression level.
The demo wakes as you arrive…

Assumptions and limitations

OBD's elegance rests on its three simplifying assumptions, but each introduces limitations:

The diagonal approximation ignores interactions between weights. In reality, deleting one weight changes the optimal values of others. The follow-up paper Optimal Brain Surgeon (Hassibi & Stork, 1992) addressed this by using the full Hessian inverse, allowing remaining weights to compensate for the deleted one.

The extremal approximation assumes training has converged perfectly. In practice, gradient norms may not be exactly zero, especially with or noisy data.

The quadratic approximation breaks down when large weights are deleted — the loss surface is not parabolic far from the minimum. The paper's own experiments showed the prediction diverging from reality after ~30% of parameters were removed in a single pass.

Despite these limitations, OBD demonstrated that even an approximate second-order method dramatically outperforms magnitude-based heuristics.

Open in Lab
Watch how the quadratic prediction (dashed) diverges from the actual loss (solid) as more parameters are deleted in a single pass.
The demo wakes as you arrive…

Legacy: from 2,600 parameters to trillions

OBD's core question — which parameters can be safely removed? — is more relevant today than it was in 1989. Modern large language models have billions or trillions of parameters, making compression essential for deployment on edge devices, reducing inference costs, and lowering energy consumption.

The intellectual lineage from OBD to modern methods is direct. Deep Compression (Han et al., 2015) combined magnitude pruning with and Huffman coding to compress networks by 35–49×. The Lottery Ticket Hypothesis (Frankle & Carlin, 2019) showed that dense networks contain sparse subnetworks that can match the full network's accuracy when trained in isolation — echoing OBD's discovery that most parameters are redundant. GPTQ (Frantar et al., 2022) applied second-order information (in the spirit of OBD and OBS) to quantize large language models with minimal accuracy loss. And SparseGPT extended this to pruning LLMs to 50–60% in a single shot.

  1. 1989

    Optimal Brain Damage (this paper)

    LeCun, Denker & Solla introduce saliency-based pruning using diagonal Hessian information. First principled method for neural network compression.

  2. 1992

    Optimal Brain Surgeon

    Hassibi & Stork removed the diagonal assumption, using the full Hessian inverse. Remaining weights are updated to compensate for pruned ones, eliminating the need for iterative retraining.

  3. 2015

    Deep Compression (Han et al.)

    Combined pruning + quantization + Huffman coding. Compressed AlexNet by 35× and VGG-16 by 49× with no accuracy loss. Made neural networks deployable on mobile devices.

  4. 2019

    Lottery Ticket Hypothesis

    Frankle & Carlin showed that dense networks contain sparse subnetworks (winning tickets) that match full accuracy when trained from their initial weights. Echoes OBD's core finding that most parameters are redundant.

  5. 2022

    GPTQ

    Applied second-order information (OBS-style) to quantize large language models like GPT-175B to 3–4 bits per weight with minimal quality loss.

  6. 2023

    SparseGPT

    Extended second-order pruning to LLMs, achieving 50–60% sparsity in a single pass without retraining — scaling OBD's vision to billion-parameter models.

The fundamental principle OBD established — use curvature information to measure parameter importance, not just magnitude — remains the gold standard in network compression. Every time a modern LLM is quantized or pruned for deployment, it carries the intellectual DNA of this 1989 paper.

Pseudocode: computing saliency and pruningpython

Simplified to show the idea — not the real implementation.

import torch

def compute_saliency(model, loss_fn, data_loader):
    """Compute OBD saliency for every parameter."""
    # Step 1: Accumulate diagonal Hessian over the dataset
    diag_hessian = {n: torch.zeros_like(p) for n, p in model.named_parameters()}

    for x, y in data_loader:
        loss = loss_fn(model(x), y)
        grads = torch.autograd.grad(loss, model.parameters(), create_graph=True)
        for (name, param), g in zip(model.named_parameters(), grads):
            # Approximate diagonal Hessian via squared gradients
            diag_hessian[name] += g.detach() ** 2

    # Step 2: Saliency = 0.5 * h_kk * w_k^2
    saliency = {}
    for name, param in model.named_parameters():
        h_kk = diag_hessian[name] / len(data_loader)
        saliency[name] = 0.5 * h_kk * param.data ** 2

    return saliency


def prune_by_saliency(model, saliency, fraction=0.5):
    """Zero out the lowest-saliency weights."""
    all_scores = torch.cat([s.flatten() for s in saliency.values()])
    threshold = torch.quantile(all_scores, fraction)

    with torch.no_grad():
        for name, param in model.named_parameters():
            mask = saliency[name] >= threshold
            param.data *= mask.float()  # zero out low-saliency weights

CitationLeCun, Y., Denker, J. S., & Solla, S. A.. Optimal Brain Damage. NeurIPS, 1989.

Terms in this paper