Loading…
Glossary term
Removing weights or units that contribute little to a model to make it smaller.
Pruning removes weights, or whole units, that contribute little to a model's output, often the ones closest to zero. The pruned model is then usually fine-tuned to recover accuracy.
It can shrink a model substantially, though speed-ups depend on hardware support for sparse operations.
Prune 30% of a layer's weights
import torch.nn.utils.prune as prune
prune.l1_unstructured(layer, name="weight", amount=0.3)It is one of several ways to make models smaller and cheaper.