Table of Contents
Shortcuts

# torch.nn.modules.module.register_module_module_registration_hook

torch.nn.modules.module.register_module_module_registration_hook(hook)

  Registers a module registration hook common to all modules.

  Warning

  This adds global state to the nn.Module module

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

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

  The hook can modify the input or return a single modified value in the hook.

  Returns:

    a handle that can be used to remove the added hook by calling `handle.remove()`

  Return type:

    `torch.utils.hooks.RemovableHandle`

## Docs

Access comprehensive developer documentation for PyTorch

View Docs

## Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

## Resources

Find development resources and get your questions answered

View Resources

To analyze traffic and optimize your experience, we serve cookies on this site. By clicking or navigating, you agree to allow our usage of cookies. As the current maintainers of this site, Facebook’s Cookies Policy applies. Learn more, including about available controls: Cookies Policy.