I wonder if there is any way that can directly report parameters gradient after each layer’s backward computation. Through the hook function on tensor or module, we are only able to get the intermediate results of the current layer but not the parameters’ gradient.
Thanks for the prompt reply. I register the hook on the weights (e.g., module.weight.register_hook()). However, I got nothing when trying to print weight.grad in this hook function. I think this is because the hook function is called before .grad field is populated as you mentioned. I wonder if the computed gradient is the input of this tensor hook operation.