Course contentsShow
← Machine Learning and Deep Learning
Lesson 2667 of 3,53858. Model Compression: Pruning and DistillationFree lesson

Structured vs Unstructured Pruning

Distinguishing between removing individual weights (unstructured) and entire channels/neurons (structured) for hardware efficiency.

Structured vs Unstructured Pruning

You'll learn: How structured and unstructured pruning differ in what they remove from a neural network and why that matters for real-world deployment.

Two Ways to Prune

When we prune neural networks, we can remove weights at two different levels of granularity:

Unstructured pruning removes individual weights scattered throughout the network. Imagine plucking random needles from a haystack—you set specific weights to zero based on their magnitude or importance, regardless of where they sit. This creates a sparse matrix with zeros peppered throughout.

Structured pruning removes entire organizational units: complete filters, channels, neurons, or attention heads. Think of it like removing entire bookshelves from a library rather than individual pages from random books. You eliminate whole rows, columns, or higher-dimensional slices from weight tensors.

Why the Distinction Matters

Unstructured pruning typically achieves higher compression and can preserve accuracy better because you're making fine-grained decisions about every single weight. However, the resulting sparse matrices are irregular and difficult for standard hardware (CPUs, GPUs) to accelerate. You need special sparse computation libraries or hardware to see actual speedups.

Structured pruning produces regular, dense matrices that are simply smaller. A pruned convolutional layer with half its channels removed runs faster on any hardware—no special support needed. The trade-off? You must remove entire groups of weights together, even if some weights in that group were important, so you typically need higher pruning rates to match unstructured pruning's accuracy.

Key Takeaway: Unstructured pruning removes individual weights for maximum flexibility but requires specialized hardware; structured pruning removes entire channels/neurons for guaranteed speedups on standard hardware, though often at the cost of more aggressive pruning to maintain accuracy.