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

Function hook_backward

intermediate_source/visualizing_gradients_tutorial.py:150–154  ·  view source on GitHub ↗
(module_name, grads)

Source from the content-addressed store, hash-verified

148 return hook
149
150def hook_backward(module_name, grads):
151 def hook(grad):
152 """Backward pass hook which appends gradients"""
153 grads.append((module_name, grad))
154 return hook
155
156def get_all_layers(model, hook_forward, hook_backward):
157 """Register forward pass hook (which registers a backward hook) to model outputs

Callers 1

hookFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected