(model, opt)
| 186 | return Outparam |
| 187 | |
| 188 | def fix_param(model, opt): |
| 189 | param_names = ['pos_embed', 'norm'] # config['optimizer']['no_weight_decay_param']['param_names'] |
| 190 | weight_decay = 0. # config['optimizer']['no_weight_decay_param']['weight_decay'] |
| 191 | is_on = True # config['optimizer']['no_weight_decay_param']['is_ON'] |
| 192 | STN_ON = True # config['model']['STN']['STN_ON'] |
| 193 | stn_lr = opt.base_lr # config['model']['STN']['stn_lr'] |
| 194 | |
| 195 | base_param = [] |
| 196 | stn_param = [] |
| 197 | no_weight_decay_param = [] |
| 198 | for (name, param) in model.named_parameters(): |
| 199 | is_no_weight = False |
| 200 | for param_name in param_names: |
| 201 | if param_name in name: |
| 202 | # print(param_name) |
| 203 | is_no_weight = True |
| 204 | break |
| 205 | if is_no_weight: |
| 206 | no_weight_decay_param.append(param) |
| 207 | elif 'stn' in name: |
| 208 | stn_param.append(param) |
| 209 | else: |
| 210 | base_param.append(param) |
| 211 | Outparam = [{'params': base_param}, {'params': stn_param}, {'params': no_weight_decay_param}] |
| 212 | |
| 213 | if STN_ON: |
| 214 | Outparam[1]['lr'] = stn_lr |
| 215 | if is_on: |
| 216 | Outparam[2]['weight_decay'] = weight_decay |
| 217 | return Outparam |
| 218 | |
| 219 | def lr_warm(base_lr, epoch, warm_epoch): |
| 220 | return (base_lr/warm_epoch)*(epoch+1) |
nothing calls this directly
no outgoing calls
no test coverage detected