• Docs >
  • torch.nn >
  • torch.nn.modules.module.register_module_parameter_registration_hook
Shortcuts

torch.nn.modules.module.register_module_parameter_registration_hook

torch.nn.modules.module.register_module_parameter_registration_hook(hook)[源代码]

注册一个适用于所有模块的参数注册钩子。

警告

这为 nn.Module 模块添加了全局状态

每次调用 register_parameter() 时,钩子都会被调用。 它应具有以下签名:

hook(module, name, param) -> None   参数

钩子可以修改输入或返回一个在钩子中修改后的值。

Returns

一个可以用于通过调用handle.remove()来移除添加的钩子的句柄

Return type

torch.utils.hooks.RemovableHandle

优云智算