AI Computer Institute
Expert-curated CS & AI curriculum aligned to CBSE standards. A bharath.ai initiative. About Us

Neural Network Pruning: Reducing Model Size

📚 Model Compression⏱️ 26 min read🎓 Grade 11
✍️ AI Computer Institute Editorial Team Updated: August 2026 CBSE-aligned · Peer-reviewed · 26 min read
Content curated by subject matter experts with IIT/NIT backgrounds. All chapters are fact-checked against official CBSE/NCERT syllabi.

When Chandrayaan-3's lander began its final descent toward the lunar surface in August 2023, it had a few minutes to choose a landing spot, correct its trajectory, and touch down, all without a human in the loop. Radio signals take more than a second each way to reach Earth, so there was no time for a ground controller to look at a camera feed and radio back an answer. The lander's onboard vision system had to look at the terrain below, judge whether it was too rocky or too steeply sloped to land on, and adjust the descent itself, running entirely on a radiation-tolerant flight computer that is, by smartphone standards, small: a fraction of the memory, a fraction of the clock speed, and a strict power budget, because every watt drawn by the compute module is a watt not available for propulsion, communication, or the instruments the mission exists to fly. A hazard-detection network trained on a GPU cluster on the ground, with tens of millions of parameters, cannot simply be dropped onto that hardware and expected to run in real time. Something has to give, and that something is usually the network's size. The discipline of shrinking a trained network without discarding what it learned is called pruning.

Pruning is not unique to spacecraft. The same size-versus-capability tension shows up whenever a trained model has to run somewhere other than the data center it was trained in: a UPI fraud-detection model scoring a transaction inside the few hundred milliseconds a payment app can keep a user waiting, an offline speech-translation model bundled into a budget Android phone with no reliable data connection, a wake-word detector that has to run continuously on a smartwatch battery for a full day. In every case the constraint is the same: a network trained to be as accurate as possible, without much regard for its size, now has to fit a size, latency, or energy budget it was never asked to respect during training. Pruning is the family of techniques that closes that gap after training, by finding and removing the parts of the network contributing the least to its output.

What Pruning Actually Does

A trained network is a set of parameters, weights and biases, arranged into layers. A dense layer with an input of size m and an output of size n has an m×n weight matrix, meaning m×n multiply-add operations (MACs) every time that layer runs. Every one of those parameters was adjusted during training to reduce a loss function, but not equally: gradient descent pushes some weights to large magnitudes because the loss is highly sensitive to them, and leaves others hovering close to zero because changing them barely moves the loss at all. Pruning exploits this unevenness. It ranks the parameters, or groups of parameters, of a trained network by some estimate of how much each one matters, removes the ones that matter least, and then, usually, retrains the smaller network briefly so the surviving parameters compensate for the ones that are gone. The result is a network with fewer parameters, fewer operations, or both, trying to reproduce the accuracy of the original.

Why Not Just Train a Smaller Network From Scratch?

A reasonable question is why anyone bothers pruning a large network down to size instead of designing and training a small network from the start with the target parameter count. Empirically, small networks trained from scratch tend to reach lower accuracy than large networks pruned down to the same final size. Part of the reason is that a large, over-parameterized network has a much larger space of possible weight configurations to search during training, which appears to make it easier for gradient descent to find a good solution at all, even though most of that solution turns out to be redundant once found. In 2019, Jonathan Frankle and Michael Carbin published the Lottery Ticket Hypothesis: inside a large, randomly initialized network there exists a much smaller subnetwork which, if reset to its original random initial weights and trained in isolation, reaches accuracy comparable to the full network trained normally. They called this subnetwork a "winning ticket." The practical implication is that a large network's usefulness during training is partly about giving many small candidate subnetworks a chance to be the one that trains well, not about needing every one of those parameters at inference time. Pruning is, in effect, a search procedure for finding that winning ticket after the fact, rather than guessing its architecture in advance.

Magnitude-Based Pruning: The Weight-Level Approach

The simplest and most widely used importance criterion is weight magnitude, |w|. The intuition connects to something you have already seen in regularization. L2 weight decay adds a penalty proportional to the sum of squared weights to the loss function, pushing every weight a little closer to zero during training unless the gradient from the task loss keeps pulling it back out. A weight that survives training with a large magnitude despite that constant pull toward zero is, by construction, a weight the task loss needed to keep away from zero. A weight training was happy to leave near zero was, comparatively, not doing much work. Magnitude pruning takes this reasoning at face value: pick a target sparsity, the fraction of weights to remove, rank every weight in the network by |w|, and zero out the smallest fraction.

This is a real approximation, not an exact importance measure, and its weakness is that it looks only at the weight, never at what that weight is multiplied by. A weight of 0.05 attached to an input that is routinely large contributes more to a neuron's output than a weight of 0.8 attached to an input that is routinely close to zero. Magnitude pruning implicitly assumes every input to a layer sits on a comparable scale, reasonable after batch normalization but not guaranteed elsewhere. The worked example below deliberately surfaces this limitation.

Worked Example: Pruning a Four-Neuron Layer by 50%

Consider a small dense layer with 3 input features and 4 output neurons, no bias, followed by ReLU. Its weight matrix W, one row per neuron, is:

n1: [ 0.80, -0.10,  0.05]
n2: [-0.60,  0.02,  0.90]
n3: [ 0.03, -0.70,  0.01]
n4: [ 0.40, -0.06, -0.30]

This layer has 4×3 = 12 weights. For input x = [1, -1, 2], the pre-activation output of each neuron is its weight row dotted with x:

n1 = 0.80(1) + -0.10(-1) + 0.05(2)  = 0.80 + 0.10 + 0.10 = 1.00
n2 = -0.60(1) + 0.02(-1) + 0.90(2) = -0.60 - 0.02 + 1.80 = 1.18
n3 = 0.03(1) + -0.70(-1) + 0.01(2) = 0.03 + 0.70 + 0.02 = 0.75
n4 = 0.40(1) + -0.06(-1) + -0.30(2) = 0.40 + 0.06 - 0.60 = -0.14

After ReLU: [1.00, 1.18, 0.75, 0.00] (n4's -0.14 is clipped to zero).

Now prune 50% of the weights by magnitude: rank all 12 |w| values and zero out the 6 smallest. This is exactly a selection problem you already know how to solve efficiently, finding the k-th smallest of n values by full sorting costs O(n log n), but quickselect finds it in O(n) average time, which matters once n is millions of weights rather than 12. Here is a direct implementation using a full sort:

import numpy as np

def magnitude_prune(W, sparsity):
    k = int(W.size * sparsity)
    flat = np.sort(np.abs(W).flatten())
    threshold = flat[k - 1]
    mask = np.abs(W) > threshold
    return W * mask

Sorting the 12 magnitudes ascending gives 0.01, 0.02, 0.03, 0.05, 0.06, 0.10, 0.30, 0.40, 0.60, 0.70, 0.80, 0.90. With sparsity = 0.5, k = int(12 × 0.5) = 6, so threshold = flat[5] = 0.10, the sixth value. The mask keeps only weights with |w| strictly greater than 0.10, removing exactly the six smallest (0.01 through 0.10 inclusive) and keeping the six largest (0.30 through 0.90). Note the strict >: a weight sitting exactly at the threshold is pruned, not kept. That tie-breaking rule does not matter here since no two weights share a magnitude, but production pruning code has to decide it explicitly, or the achieved sparsity silently comes out one weight off.

The pruned matrix is:

n1: [0.80, 0,     0    ]
n2: [-0.60, 0,    0.90 ]
n3: [0,    -0.70, 0    ]
n4: [0.40,  0,    -0.30]

Running the same input x = [1, -1, 2] through the pruned layer: n1 = 0.80(1) = 0.80; n2 = -0.60(1) + 0.90(2) = 1.20; n3 = -0.70(-1) = 0.70; n4 = 0.40(1) + -0.30(2) = -0.20, clipped by ReLU to 0.

NeuronOriginal (post-ReLU)Pruned (post-ReLU)Absolute errorRelative error
n11.000.800.2020.0%
n21.181.200.021.7%
n30.750.700.056.7%
n40.000.000.00

Half of the connections are gone, yet the output is recognisably close to the original for every neuron whose activation survives ReLU. This is the empirical case for pruning: a substantial fraction of a trained network's parameters can be discarded for a modest, not catastrophic, change in output, and recovering that modest change is exactly what fine-tuning after pruning is for.

Misconception: "Pruning Automatically Makes Inference Faster"

A student who has just watched a network shrink from 12 stored weights to 6 usually assumes inference is now twice as fast. It is not, at least not on the hardware most people run inference on. The pruned matrix above is still stored and executed as a 4×3 matrix; the entries that were zeroed are still sitting there as literal 0.0 values unless something explicitly changes the data structure and the routine that processes it. A standard dense matrix multiply on a CPU or GPU has no concept of "skip this entry, it's zero": it walks the full m×n grid of multiply-adds regardless of what is stored there. Zero times x is still a multiplication instruction that gets issued and executed. So the honest accounting for the example above is that unstructured 50% magnitude pruning gives a real, unconditional 50% reduction in the memory needed to store the layer's weights, 6 float32 values instead of 12, meaningful when a model has to fit in a satellite's flash memory or a phone's storage budget, but a 0% reduction in the multiply-add operations actually executed at inference time on ordinary dense hardware, and therefore little to no latency improvement.

Turning unstructured sparsity into a real speedup needs either specialised sparse matrix kernels that skip zero entries, available on some newer GPU tensor cores at specific sparsity patterns and in some inference libraries for CPUs, or a coarser pruning strategy that changes the matrix's actual dimensions rather than just its content. That coarser strategy is structured pruning, and it is the one deployment engineers reach for whenever the target hardware has no sparse-aware kernel, which is still the common case.

Structured Pruning: Removing Whole Neurons and Filters

Structured pruning, in a convolutional network usually called filter or channel pruning, removes entire neurons or entire filters rather than individual weights. The importance criterion is applied per-neuron, most commonly the L1 norm of the neuron's full weight row, the sum of the absolute values of everything that neuron looks at. For the same layer:

n1: 0.80 + 0.10 + 0.05 = 0.95
n2: 0.60 + 0.02 + 0.90 = 1.52
n3: 0.03 + 0.70 + 0.01 = 0.74
n4: 0.40 + 0.06 + 0.30 = 0.76

n3 has the smallest L1 norm, so a structured pruner removing one of the four neurons removes n3 entirely, weights and all. The layer's output dimension shrinks from 4 to 3, and the weight matrix genuinely shrinks from 4×3 to 3×3: 9 stored weights instead of 12, a 25% reduction, realised as a 25% reduction in multiply-adds on completely ordinary dense hardware, no sparse kernel required. Running x = [1, -1, 2] through the surviving neurons n1, n2 and n4 reproduces exactly the same pre-activation values as the original dense network (1.00, 1.18, -0.14), because structured pruning never touches the weights of the neurons it keeps; it only deletes neurons wholesale. The only change is that n3's entry disappears from the output vector, and the next layer's weight matrix has to be resized to drop its corresponding input column.

This is the fundamental trade-off between the two granularities. Unstructured pruning is fine-grained: it can remove exactly the six weakest individual connections and leave every neuron otherwise intact, giving a smaller accuracy penalty for a given amount of memory saved, but the saving shows up only in storage unless the inference stack has sparse support. Structured pruning is coarse-grained: it has to remove an entire neuron even if that neuron had a few individually strong connections mixed in with weak ones (n3's largest single weight, 0.70, is larger than every weight n4 has, 0.40, 0.06, 0.30, yet all of n3 is gone because its row total was smallest), which tends to cost more accuracy per parameter removed, but every parameter removed converts directly into a smaller matrix and a real, hardware-independent speedup.

Iterative Pruning and the Lottery Ticket Hypothesis, Revisited

Pruning 50% of a layer in one shot, as above, is called one-shot pruning, and it is rarely how pruning is done on a real, many-million-parameter network. The larger the fraction removed in a single step, the more the remaining weights must compensate for connections that vanished all at once, and the harder it is for a brief fine-tuning pass to recover. Standard practice is iterative pruning: prune a small fraction, often 10 to 20 percent of what remains, fine-tune the smaller network for a few epochs so survivors adjust, then repeat until the target sparsity is reached. Rather than jumping straight to the final sparsity, many schedules ramp it up gradually, pruning aggressively in early rounds when the network has the most redundancy to spare and slowing near the target, so the network is never asked to absorb a large sudden loss of capacity in one step.

Frankle and Carbin's winning-ticket experiments used exactly this iterative structure, with one twist: after each pruning round, instead of continuing to train the surviving weights from wherever they currently sat, they reset the survivors back to their original values from before training even started, a step called weight rewinding, then retrained from there. The resulting sparse subnetwork, trained from its original initialisation, could match the accuracy of the full dense network trained normally, a stronger claim than saying a pruned-and-fine-tuned network is merely close to the original: it says the sparse structure discovered by pruning was already capable of learning the task on its own, and the rest of the dense network's parameters existed mainly to make that particular sparse structure findable by gradient descent in the first place.

Measuring a Pruning Result Honestly

A pruning result should be reported with at least four numbers together, since any one alone can mislead. Sparsity is the fraction of weights zeroed (50% above). Compression ratio is the reduction in stored parameters, original divided by pruned (2× for 50% unstructured sparsity, 12/9 ≈ 1.33× for the structured example). FLOPs reduction is the reduction in multiply-adds actually executed, which can be zero for unstructured pruning on ordinary hardware even at high sparsity, and generally tracks the compression ratio for structured pruning. Accuracy delta is the change in the metric that actually matters (top-1 accuracy, F1, word error rate), measured on a held-out test set after fine-tuning, never estimated from the training set. A pruning result quoted as "90% sparsity" with no accuracy delta and no FLOPs number attached is half a result.

Song Han, Huizi Mao and William Dally's 2015 "Deep Compression" paper is the one most often cited for how far this can go on large image-classification networks. Using iterative magnitude pruning alone, they reported reducing AlexNet's roughly 61 million parameters by about 9×, and the considerably larger VGG-16 by about 13×, in both cases with no measurable loss in ImageNet accuracy after fine-tuning. Their full pipeline then layered weight quantisation and Huffman coding on top of that pruning step, pushing overall storage compression to roughly 35× for AlexNet and roughly 49× for VGG-16; quantisation and coding shrink the number of bits used to represent each surviving weight, a different lever from pruning's decision to remove a weight entirely, but the pruning step was responsible for most of the parameter-count reduction in that combined pipeline.

Diagram: One Layer, Three States

The figure below tracks the same 4-neuron, 3-input layer through the dense baseline, 50% unstructured pruning, and structured pruning, with the parameter-count bar chart underneath making the memory-versus-compute distinction concrete.

Pruning one layer three ways A · Dense baseline B · Unstructured (50%) C · Structured (remove n3) x1 x2 x3 x1 x2 x3 x1 x2 x3 n1 n2 n3 n4 n1 n2 n3 n4 n1 n2 n4 n3 removed 12 / 12 weights kept 6 / 12 weights kept (50% sparsity) 9 / 12 weights kept (1 neuron removed) kept weight pruned weight removed neuron Stored parameters per layer (weight count) 12 Dense 6 Unstructured 9 Structured

The amber bar (unstructured) is shorter than the dense bar in stored weights, but on ordinary hardware its FLOPs bar would be exactly as tall as the dense one, unchanged. The green bar (structured) is the only one where a shorter parameter bar comes with a proportionally shorter compute cost too.

Active Recall

Q1. Using the pruned matrix from the worked example, compute the layer's output (post-ReLU) for a new input x = [2, 0, -1], for both the original dense network and the 50%-pruned network. Where do they differ, and why is the difference at n3 much larger in relative terms than the difference at n1?

Q2. Explain, in terms of how a dense matrix multiply executes on a GPU, why removing 50% of a matrix's individual entries by magnitude does not by itself cut inference latency in half.

Q3. State the misconception this chapter names about pruning and speed, and the one sentence that corrects it.

Q4. Magnitude pruning uses |w| as a proxy for a weight's importance. State the assumption this proxy relies on, and describe a situation (referencing Q1 if useful) where the proxy gives a misleading answer.

Q5. What does the Lottery Ticket Hypothesis claim, and what is "weight rewinding," and why does Frankle and Carbin's use of rewinding make their result a stronger claim than "a pruned, fine-tuned network is nearly as accurate as the original"?

Q6. A dense layer has 50,000 parameters and executes 100,000 FLOPs per forward pass. It is pruned to 80% sparsity. Compute the stored parameter count and the FLOPs actually executed on hardware with no sparse kernel support, for (a) unstructured pruning and (b) structured pruning that removes 80% of its filters.

Worked Answers

A1. Original weights, x = [2, 0, -1]: n1 = 0.80(2) + -0.10(0) + 0.05(-1) = 1.6 - 0.05 = 1.55; n2 = -0.60(2) + 0.02(0) + 0.90(-1) = -1.2 - 0.9 = -2.1 → ReLU 0; n3 = 0.03(2) + -0.70(0) + 0.01(-1) = 0.06 - 0.01 = 0.05; n4 = 0.40(2) + -0.06(0) + -0.30(-1) = 0.8 + 0.3 = 1.1. Original output: [1.55, 0, 0.05, 1.10]. Pruned weights, same x: n1 = 0.80(2) = 1.60; n2 = -0.60(2) + 0.90(-1) = -1.2 - 0.9 = -2.1 → ReLU 0; n3 = -0.70(0) = 0; n4 = 0.40(2) + -0.30(-1) = 0.8 + 0.3 = 1.1. Pruned output: [1.60, 0, 0, 1.10]. n1 differs by 0.05 (about 3%), n2 and n4 are identical, and n3 differs by 0.05 out of an original 0.05, a 100% relative error. n3's pruned weights multiplied by this particular x (whose x2 = 0) happen to zero out entirely, while n1's dominant surviving weight (0.80) still carries most of its original value. The lesson: how much a given pruning decision hurts depends on the specific input being processed, not on the weight magnitudes alone, which is exactly the scale-dependence magnitude pruning ignores. It is also why more advanced criteria (Taylor-expansion-based importance, movement pruning) look at weight and activation together rather than weight magnitude in isolation.

A2. A dense matrix multiply issues one multiply-add instruction per matrix entry regardless of its value; there is no branch that says "this entry is zero, skip it." Setting 50% of the entries to zero changes what is stored, not how many instructions the multiply routine executes, so the hardware still performs the full m×n multiply-adds. Only a sparse-aware kernel, one that stores just the nonzero entries and their positions and skips the rest during the multiply, converts stored sparsity into fewer executed operations.

A3. The misconception is that pruning automatically makes inference faster. The correction: unstructured pruning reduces the memory needed to store weights, but on hardware without sparse-aware kernels it leaves the number of multiply-add operations executed, and therefore the latency, essentially unchanged.

A4. Magnitude pruning assumes every input to the layer sits on a roughly comparable scale, so that a larger |w| really does mean a larger typical contribution to the output. In Q1, n3's weight of -0.70 (kept) multiplies x2, which happened to be 0 for that particular input, contributing nothing, while a "small" pruned weight elsewhere could have mattered a great deal had its corresponding input been large. The proxy is cheap and usually reasonable after normalization, but it can be misled whenever input scales are uneven or an input is frequently near zero for some features and large for others.

A5. The Lottery Ticket Hypothesis claims that a large, randomly initialized network contains a much smaller sparse subnetwork ("winning ticket") that, trained in isolation from its own original initial weights, reaches accuracy comparable to the full dense network trained normally. Weight rewinding is the step, used between rounds of iterative pruning, of resetting the surviving weights back to their pre-training initial values rather than continuing to train them from their current, partially-trained state. This makes the claim stronger than ordinary prune-and-fine-tune, because it shows the sparse structure itself, combined with its original starting point, was sufficient to learn the task well; the rest of the dense network's parameters were mainly scaffolding that made this particular sparse structure reachable by gradient descent, not parameters the final solution actually needed.

A6. (a) Unstructured, 80% sparsity: stored parameters = 20% of 50,000 = 10,000. FLOPs executed on hardware with no sparse kernel = unchanged = 100,000, because the dense multiply still processes every entry including the zeroed ones. (b) Structured, removing 80% of filters: both parameters and FLOPs scale down together with the matrix's actual dimensions, so stored parameters = 10,000 and FLOPs executed = 20% of 100,000 = 20,000, an 80% real reduction in both memory and compute.

Think About It

Think about this: How would you explain neural network pruning: reducing model size to a friend who has never seen a computer? What real-world analogy would you use? Imagine you had to build a system using these concepts — what would be your first step? Try this: before moving on, write down three things you learned and one question you still have.

Key Takeaways — Summary and Recap

Let us recap what we covered: the core ideas behind neural network pruning: reducing model size, how they connect to real-world applications, and why they matter for your journey in computer science. Remember these key points as you move forward. For competitive exam preparation (CBSE, JEE, BITSAT), focus on understanding the WHY behind each concept, not just the WHAT.

← BERT and Transformer Encoders: Masked Language ModelingQuantization: Running Models on Edge Devices →

Found this useful? Share it!

📱 WhatsApp 🐦 Twitter 💼 LinkedIn