Question 7/13 v3 lecture 11

What are PyTorch hooks?


A "hook" is a function that can be registered on a Module or a Tensor. It will be called when a forward or a backward call is executed on a Module or when a gradient is calculated with regards to a Tensor. In the case of a forward hook, it will be passed the module it is registered on and the input and the output of the operation.