(model, skip_list=(), skip_keywords=())
| 82 | |
| 83 | |
| 84 | def 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 | |
| 104 | def get_swin_layer(name, num_layers, depths): |
no test coverage detected