Thank you @albanD or your response. I added the term torch.no_grad, since after the convolutional layer there is a module named Relu that passing the input through this layer throws below error:

RuntimeError: a leaf Variable that requires grad has been used in an in-place operation.

How can I register a hook on the output of each convolutional layer without facing such error when the outputs are passing through Relu function.
Thank you very much for your time and consideration.