MCPcopy
hub / github.com/DingXiaoH/RepVGG / sgd_optimizer

Function sgd_optimizer

quantization/quant_qat_train.py:84–98  ·  view source on GitHub ↗
(model, lr, momentum, weight_decay)

Source from the content-addressed store, hash-verified

82
83
84def sgd_optimizer(model, lr, momentum, weight_decay):
85 params = []
86 for key, value in model.named_parameters():
87 if not value.requires_grad:
88 continue
89 apply_weight_decay = weight_decay
90 apply_lr = lr
91 if value.ndimension() < 2: #TODO note this
92 apply_weight_decay = 0
93 print('set weight decay=0 for {}'.format(key))
94 if 'bias' in key:
95 apply_lr = 2 * lr # Just a Caffe-style common practice. Made no difference.
96 params += [{'params': [value], 'lr': apply_lr, 'weight_decay': apply_weight_decay}]
97 optimizer = torch.optim.SGD(params, lr, momentum=momentum)
98 return optimizer
99
100def main():
101 args = parser.parse_args()

Callers 1

main_workerFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected