Gradients of loss wrt intermediate layers in neural network

how do I print the gradients of loss wrt intermediate layers in neural network? Please answer this question

Hi,

You can add a hook on the Tensor you want that will be called when the gradients for it are computed. See the doc here.

thank you so much! I got it