torch.nn.utils.prune.is_pruned
-
torch.nn.utils.prune.is_pruned(module)
[source] -
Check whether
module
is pruned by looking forforward_pre_hooks
in its modules that inherit from theBasePruningMethod
.- Parameters
-
module (nn.Module) – object that is either pruned or unpruned
- Returns
-
binary answer to whether
module
is pruned.
Examples
>>> 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
© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.nn.utils.prune.is_pruned.html