When adding a hook to a layer, let’s say by nn.utils.spectral_norm(my_layer)
, how can I confirm that the hook in fact registered?
If I added more hooks, could I list them all somehow?
When adding a hook to a layer, let’s say by nn.utils.spectral_norm(my_layer)
, how can I confirm that the hook in fact registered?
If I added more hooks, could I list them all somehow?
I think you access this protected attribute of the layer
something like layer._forward_hooks
which holds an OrderedDict of all registered forward hooks.
an example:
similarly, you can see:
layer._backward_hooks
layer._forward_pre_hooks
Thanks, I will try this out!
This was surprisingly difficult to find in thr documentation/tutorials.