albanD:

Parameter


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.
Thanks again!