I want to do the forward pass first, then repeating
register backward hook => backward propagation => clear gradient and remove hook=>register another backward hook …
to use several backward hook functions, those should not be registered simultaneously.
However, it seems the backward hook function is handled in calling forward function, not the backward (https://github.com/pytorch/pytorch/blob/master/torch/nn/modules/module.py#L484 16), so the backward hook registered after the forward pass doesn’t work.
Is there any possible trick for it?