評價此頁

torch.nn.utils.prune.remove#

torch.nn.utils.prune.remove(module, name)[原始碼]#

從模組中移除剪枝重引數化,並從前向鉤子中移除剪枝方法。

名為 name 的已剪枝引數將永久保持剪枝狀態,名為 name+'_orig' 的引數將從引數列表中移除。類似地,名為 name+'_mask' 的緩衝區也將從緩衝區中移除。

注意

修剪本身**不會**被撤銷或恢復!

引數
  • module (nn.Module) – module containing the tensor to prune

  • name (str) – 在 module 中執行剪枝操作的引數名稱。

示例

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