W3cubDocs

/PyTorch 2.9

torch.nn.utils.prune.remove

torch.nn.utils.prune.remove(module, name) [source]

Remove the pruning reparameterization from a module and the pruning method from the forward hook.

The pruned parameter named name remains permanently pruned, and the parameter named name+'_orig' is removed from the parameter list. Similarly, the buffer named name+'_mask' is removed from the buffers.

Note

Pruning itself is NOT undone or reversed!

Parameters
  • module (nn.Module) – module containing the tensor to prune
  • name (str) – parameter name within module on which pruning will act.

Examples

>>> m = random_unstructured(nn.Linear(5, 7), name="weight", amount=0.2)
>>> m = remove(m, name="weight")

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.nn.utils.prune.remove.html