MCPcopy Create free account
hub / github.com/PeizeSun/SparseR-CNN / register_hooks

Method register_hooks

detectron2/engine/train_loop.py:100–116  ·  view source on GitHub ↗

Register hooks to the trainer. The hooks are executed in the order they are registered. Args: hooks (list[Optional[HookBase]]): list of hooks

(self, hooks)

Source from the content-addressed store, hash-verified

98 self._hooks = []
99
100 def register_hooks(self, hooks):
101 """
102 Register hooks to the trainer. The hooks are executed in the order
103 they are registered.
104
105 Args:
106 hooks (list[Optional[HookBase]]): list of hooks
107 """
108 hooks = [h for h in hooks if h is not None]
109 for h in hooks:
110 assert isinstance(h, HookBase)
111 # To avoid circular reference, hooks and trainer cannot own each other.
112 # This normally does not matter, but will cause memory leak if the
113 # involved objects contain __del__:
114 # See http://engineering.hearsaysocial.com/2013/06/16/circular-references-in-python/
115 h.trainer = weakref.proxy(self)
116 self._hooks.extend(hooks)
117
118 def train(self, start_iter: int, max_iter: int):
119 """

Callers 3

benchmark.pyFile · 0.80
mainFunction · 0.80
__init__Method · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected