Skip to content
StackDecode
AI & ML Atlas
Deep LearningtechniqueInteractive simulation

Pruning

Removes the least important weights or neurons to shrink a network.

The idea

Many weights in a trained network are close to zero and contribute little. Magnitude pruning deletes the smallest ones (unstructured), or whole channels and heads (structured, which gives real speed-ups). The network is usually fine-tuned afterwards to recover accuracy.

Watch it run

This is a real computation, not a drawing. Pause, step, change the settings, or try new random data.

  • positive
  • negative
  • pruned

A weight matrix: 64 numbers. Brightness is how large each weight is (blue positive, orange negative).

weights:
64
1/4

Magnitude pruning keeps the biggest weights. Push the slider high and watch the output error rise.

Step by step

  1. 1Train the network.
  2. 2Rank weights by importance, for example their absolute value.
  3. 3Remove the lowest-ranked fraction.
  4. 4Fine-tune; repeat gradually if needed.

Where it is used

Smaller, faster models for phones and servers.

Watch out for

Unstructured sparsity needs special hardware or libraries to run faster.

Related