clean code
This commit is contained in:
4
utils.py
4
utils.py
@@ -36,8 +36,7 @@ def load_checkpoint(checkpoint_path, model, optimizer=None, skip_optimizer=False
|
|||||||
new_state_dict = {}
|
new_state_dict = {}
|
||||||
for k, v in state_dict.items():
|
for k, v in state_dict.items():
|
||||||
try:
|
try:
|
||||||
#assert "emb_g" not in k
|
# assert "emb_g" not in k
|
||||||
# print("load", k)
|
|
||||||
new_state_dict[k] = saved_state_dict[k]
|
new_state_dict[k] = saved_state_dict[k]
|
||||||
assert saved_state_dict[k].shape == v.shape, (saved_state_dict[k].shape, v.shape)
|
assert saved_state_dict[k].shape == v.shape, (saved_state_dict[k].shape, v.shape)
|
||||||
except:
|
except:
|
||||||
@@ -80,7 +79,6 @@ def latest_checkpoint_path(dir_path, regex="G_*.pth"):
|
|||||||
f_list = glob.glob(os.path.join(dir_path, regex))
|
f_list = glob.glob(os.path.join(dir_path, regex))
|
||||||
f_list.sort(key=lambda f: int("".join(filter(str.isdigit, f))))
|
f_list.sort(key=lambda f: int("".join(filter(str.isdigit, f))))
|
||||||
x = f_list[-1]
|
x = f_list[-1]
|
||||||
print(x)
|
|
||||||
return x
|
return x
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user