(model, arch, pre_state_dict)
| 49 | |
| 50 | |
| 51 | def load_pretrained_model(model, arch, pre_state_dict): |
| 52 | target_state_dict = model.state_dict() |
| 53 | |
| 54 | for name, param in pre_state_dict.items(): |
| 55 | if (arch=='resnet18') and ('linear' in name): continue |
| 56 | target_state_dict[name].copy_(param) |
| 57 | |
| 58 | |
| 59 | def regenerate_def_noise(def_noise, model, criterion, loader, defender, cpu): |