MCPcopy Create free account
hub / github.com/pytorch/tutorials / hook_forward

Function hook_forward

intermediate_source/visualizing_gradients_tutorial.py:144–148  ·  view source on GitHub ↗
(module_name, grads, hook_backward)

Source from the content-addressed store, hash-verified

142# so that we can pass arguments.
143
144def hook_forward(module_name, grads, hook_backward):
145 def hook(module, args, output):
146 """Forward pass hook which attaches backward pass hooks to intermediate tensors"""
147 output.register_hook(hook_backward(module_name, grads))
148 return hook
149
150def hook_backward(module_name, grads):
151 def hook(grad):

Callers 1

get_all_layersFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected