torch.nn.utils.prune.is_pruned¶
- torch.nn.utils.prune.is_pruned(module)[source]¶
Check if a module is pruned by looking for pruning pre-hooks.
Check whether
moduleis pruned by looking forforward_pre_hooksin its modules that inherit from theBasePruningMethod.- Parameters
module (nn.Module) – object that is either pruned or unpruned
- Returns
binary answer to whether
moduleis 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