MCPcopy
hub / github.com/microsoft/Swin-Transformer / get_pretrain_param_groups

Function get_pretrain_param_groups

optimizer.py:84–101  ·  view source on GitHub ↗
(model, skip_list=(), skip_keywords=())

Source from the content-addressed store, hash-verified

82
83
84def get_pretrain_param_groups(model, skip_list=(), skip_keywords=()):
85 has_decay = []
86 no_decay = []
87 has_decay_name = []
88 no_decay_name = []
89
90 for name, param in model.named_parameters():
91 if not param.requires_grad:
92 continue
93 if len(param.shape) == 1 or name.endswith(".bias") or (name in skip_list) or \
94 check_keywords_in_name(name, skip_keywords):
95 no_decay.append(param)
96 no_decay_name.append(name)
97 else:
98 has_decay.append(param)
99 has_decay_name.append(name)
100 return [{'params': has_decay},
101 {'params': no_decay, 'weight_decay': 0.}]
102
103
104def get_swin_layer(name, num_layers, depths):

Callers 1

build_optimizerFunction · 0.85

Calls 1

check_keywords_in_nameFunction · 0.85

Tested by

no test coverage detected