-
Notifications
You must be signed in to change notification settings - Fork 1
/
utils.py
18 lines (14 loc) · 833 Bytes
/
utils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# ----------------------------------------------Import required Modules----------------------------------------------- #
import collections
# ----------------------------------------------Utility Functions----------------------------------------------------- #
def model_sort(model_file_paths):
'''
Sort saved model file paths.
:param model_file_paths: list of saved model file paths
:return: sorted list of saved model file paths
'''
epoch_list = [int(model_file_paths[i].split("_")[-1].split(".")[0]) for i in range(len(model_file_paths))]
model_file_paths_dict = {k: v for (k, v) in zip(epoch_list, model_file_paths)}
model_file_paths_dict = collections.OrderedDict(sorted(model_file_paths_dict.items()))
model_file_paths_ = list(model_file_paths_dict.values())
return model_file_paths_