This approach might work to register hooks for all modules.
-
If you are using out of place activations, the
output
will non-linearity will be applied on the input and will return the output you could clone into yourdict
. However, if you are usinginplace=True
, note that also the input will be manipulated in-place. -
Yes, you can pass any module (containing other submodules) and register the hook to this outer output.