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