-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_model.py
38 lines (34 loc) · 1.66 KB
/
run_model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""
训练并评估单一模型的脚本
"""
import argparse
from libcity.pipeline import run_model
from libcity.utils import str2bool, add_general_args
if __name__ == '__main__':
parser = argparse.ArgumentParser()
# 增加指定的参数
parser.add_argument('--task', type=str,
default='traffic_state_pred', help='the name of task')
parser.add_argument('--model', type=str,
default='GRU', help='the name of model')
parser.add_argument('--dataset', type=str,
default='METR_LA', help='the name of dataset')
parser.add_argument('--config_file', type=str,
default=None, help='the file name of config file')
parser.add_argument('--saved_model', type=str2bool,
default=True, help='whether save the trained model')
parser.add_argument('--train', type=str2bool, default=True,
help='whether re-train model if the model is trained before')
parser.add_argument('--exp_id', type=str, default=None, help='id of experiment')
parser.add_argument('--seed', type=int, default=0, help='random seed')
# 增加其他可选的参数
add_general_args(parser)
# 解析参数
args = parser.parse_args()
dict_args = vars(args)
other_args = {key: val for key, val in dict_args.items() if key not in [
'task', 'model', 'dataset', 'config_file', 'saved_model', 'train'] and
val is not None}
run_model(task=args.task, model_name=args.model, dataset_name=args.dataset,
config_file=args.config_file, saved_model=args.saved_model,
train=args.train, other_args=other_args)