MCPcopy Create free account
hub / github.com/OpenGVLab/DragGAN / register_hook

Function register_hook

draggan/draggan.py:60–74  ·  view source on GitHub ↗
(G)

Source from the content-addressed store, hash-verified

58
59
60def register_hook(G):
61 # Create a new attribute called "activations" for the Generator class
62 # This will be a list of activations from each layer
63 G.__setattr__("activations", None)
64
65 # Forward hook to collect features
66 def hook(module, input, output):
67 G.activations = output
68
69 # Apply the hook to the 7th layer (256x256)
70 for i, (name, module) in enumerate(G.synthesis.named_children()):
71 if i == 6:
72 print("Registering hook for:", name)
73 module.register_forward_hook(hook)
74 return G
75
76
77def generate_W(

Callers 1

forward_GFunction · 0.85

Calls 1

__setattr__Method · 0.80

Tested by

no test coverage detected