• 文件 >
  • torch.nn >
  • torch.nn.modules.module.register_module_module_registration_hook
快捷方式

torch.nn.modules.module.register_module_module_registration_hook

torch.nn.modules.module.register_module_module_registration_hook(hook)[原始碼][原始碼]

註冊一個所有模組通用的模組註冊鉤子。

警告

這會向 nn.Module 模組新增全域性狀態

每次呼叫 register_module() 時都會呼叫該鉤子。它應具有以下簽名

hook(module, name, submodule) -> None or new submodule

該鉤子可以修改輸入或在鉤子中返回單個修改後的值。

返回

一個控制代碼,透過呼叫 handle.remove() 可以移除新增的鉤子

返回型別

torch.utils.hooks.RemovableHandle

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取適合初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題的解答

檢視資源