Shortcuts

torch.nn.utils.prune.is_pruned

torch.nn.utils.prune.is_pruned(module)[source]

Check whether module is pruned by looking for forward_pre_hooks in its modules that inherit from the BasePruningMethod.

Parameters:

module (nn.Module) – object that is either pruned or unpruned

Returns:

binary answer to whether module is pruned.

Examples

>>> from torch.nn.utils import prune
>>> m = nn.Linear(5, 7)
>>> print(prune.is_pruned(m))
False
>>> prune.random_unstructured(m, name='weight', amount=0.2)
>>> print(prune.is_pruned(m))
True

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources