forked from gmum/few-shot-hypernets-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
warmup.py
23 lines (23 loc) · 1.03 KB
/
warmup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# We also support warmup from pretrained baseline feature, but we never used it in our paper
# elif params.warmup:
# baseline_checkpoint_dir = (
# f"{configs.save_dir}/checkpoints/{params.dataset}/{params.model}_baseline"
# )
# if params.train_aug:
# baseline_checkpoint_dir += "_aug"
# warmup_resume_file = get_resume_file(baseline_checkpoint_dir)
# tmp = torch.load(warmup_resume_file)
# if tmp is not None:
# state = tmp["state"]
# state_keys = list(state.keys())
# for _i, key in enumerate(state_keys):
# if "feature." in key:
# newkey = key.replace(
# "feature.", ""
# ) # an architecture model has attribute 'feature', load architecture feature to backbone by casting name from 'feature.trunk.xx' to 'trunk.xx'
# state[newkey] = state.pop(key)
# else:
# state.pop(key)
# model.feature.load_state_dict(state)
# else:
# raise ValueError("No warm_up file")