MCPcopy Create free account
hub / github.com/SooLab/CGFormer / group_weight

Function group_weight

utils/misc.py:169–190  ·  view source on GitHub ↗
(weight_group, module, lr)

Source from the content-addressed store, hash-verified

167
168
169def group_weight(weight_group, module, lr):
170 group_decay = []
171 group_no_decay = []
172 for m in module.modules():
173 if isinstance(m, nn.Linear):
174 group_decay.append(m.weight)
175 if m.bias is not None:
176 group_no_decay.append(m.bias)
177 elif isinstance(m, nn.modules.conv._ConvNd):
178 group_decay.append(m.weight)
179 if m.bias is not None:
180 group_no_decay.append(m.bias)
181 elif isinstance(m, nn.modules.batchnorm._BatchNorm):
182 if m.weight is not None:
183 group_no_decay.append(m.weight)
184 if m.bias is not None:
185 group_no_decay.append(m.bias)
186 assert len(list(
187 module.parameters())) == len(group_decay) + len(group_no_decay)
188 weight_group.append(dict(params=group_decay, lr=lr))
189 weight_group.append(dict(params=group_no_decay, weight_decay=.0, lr=lr))
190 return weight_group
191
192
193def colorize(gray, palette):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected