torch.nn.modules.module.register_module_parameter_registration_hook#
- torch.nn.modules.module.register_module_parameter_registration_hook(hook)[原始碼]#
為所有模組註冊一個通用的引數註冊鉤子。
警告
This adds global state to the nn.Module module
每次呼叫
register_parameter()時都會呼叫該鉤子。它應該具有以下簽名:hook(module, name, param) -> None or new parameter
The hook can modify the input or return a single modified value in the hook.
- 返回
一個控制代碼,可用於透過呼叫
handle.remove()來移除新增的鉤子- 返回型別
torch.utils.hooks.RemovableHandle