评价此页

torch.nn.modules.module.register_module_parameter_registration_hook#

torch.nn.modules.module.register_module_parameter_registration_hook(hook)[source]#

Register a parameter registration hook common to all modules.

警告

This adds global state to the nn.Module module

The hook will be called every time register_parameter() is invoked. It should have the following signature

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