(model: nn.Module, weight_decay=1e-5, no_weight_decay_list=())
| 95 | # from timm: https://github.com/huggingface/pytorch-image-models/blob/main/timm/optim/optim_factory.py |
| 96 | # Copyright 2019 Ross Wightman, Apache-2.0 License |
| 97 | def param_groups_weight_decay(model: nn.Module, weight_decay=1e-5, no_weight_decay_list=()): |
| 98 | no_weight_decay_list = set(no_weight_decay_list) |
| 99 | decay = [] |
| 100 | no_decay = [] |
| 101 | for name, param in model.named_parameters(): |
| 102 | if not param.requires_grad: |
| 103 | continue |
| 104 | |
| 105 | if param.ndim <= 1 or name.endswith(".bias") or name in no_weight_decay_list: |
| 106 | no_decay.append(param) |
| 107 | else: |
| 108 | decay.append(param) |
| 109 | |
| 110 | return [{"params": no_decay, "weight_decay": 0.0}, {"params": decay, "weight_decay": weight_decay}] |
| 111 | |
| 112 | |
| 113 | def log_config(cfg: DictConfig): |
no outgoing calls
no test coverage detected