-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
152 lines (129 loc) · 4.66 KB
/
run.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
import argparse
import os
# os.environ["CUDA_LAUNCH_BLOCKING"]="1"
import glob
from mergedeep import Strategy
import numpy as np
from gaia.evaluate import process_results
from gaia import get_logger
import yaml
# from argparse import
logger = get_logger(__name__)
from gaia.training import (
main,
default_trainer_params,
default_dataset_params,
default_model_params,
)
from gaia.plot import plot_results
# "/ssddg1/gaia/cam4/cam4-famip-30m-timestep_4"
dataset_names = {
"cam4": "/ssddg1/gaia/cam4/cam4-famip-30m-timestep_4",
"spcam": "/ssddg1/gaia/spcam/spcamclbm-nx-16-20m-timestep_4",
}
mean_thres_defaults = {"cam4": 1e-13, "spcam": 1e-15}
def run():
parser = argparse.ArgumentParser()
parser.add_argument("--ignore_input_variables", default=None, type=str)
parser.add_argument("--memory_variables", default=None, type=str)
parser.add_argument(
"--dataset",
default="cam4",
type=str,
)
parser.add_argument("--gpu", default=2, type=int)
parser.add_argument("--model_type", default="baseline", type=str)
parser.add_argument("--mode", default="train,val,test", type=str)
parser.add_argument("--ckpt", default=None, type=str)
parser.add_argument("--hidden_size", default=512, type=int)
parser.add_argument("--lr", default=0.001, type=float)
parser.add_argument("--num_layers", default=7, type=int)
parser.add_argument("--batch_size", default=24 * 96 * 144, type=int) #24 * 96 * 144 96 * 144 // 2
parser.add_argument("--dropout", default=0.01, type=float)
parser.add_argument("--mean_thres", default=None, type=float)
parser.add_argument("--max_epochs", default=200, type=int)
parser.add_argument("--leaky_relu", default=0.15, type=float)
parser.add_argument("--bottleneck", default=32, type = int)
parser.add_argument("--pretrained", default=None, type = str)
args = parser.parse_args()
mean_thres_defaults = {"cam4": 1e-13, "spcam": 1e-15}
args.mean_thres = mean_thres_defaults[args.dataset]
args.dataset = dataset_names[args.dataset]
if args.model_type == "baseline":
model_config = {
"model_type": "fcn",
"num_layers": args.num_layers,
"hidden_size": args.hidden_size,
"dropout": args.dropout,
"leaky_relu": args.leaky_relu
# "num_output_layers": 6
}
elif args.model_type == "memory":
model_config = {
"model_type": "fcn_history",
"num_layers": args.num_layers,
"hidden_size": args.hidden_size,
"leaky_relu": args.leaky_relu
# "num_output_layers": 6
}
elif args.model_type == "conv1d":
model_config = {
"model_type": "conv1d",
"num_layers": 7,
"hidden_size": 128,
# "num_output_layers": 6
}
elif args.model_type == "resdnn":
model_config = {
"model_type": "resdnn",
"num_layers": args.num_layers,
"hidden_size": args.hidden_size,
"dropout": args.dropout,
"leaky_relu": args.leaky_relu
# "num_output_layers": 6
}
elif args.model_type == "encoderdecoder":
model_config = {
"model_type": "encoderdecoder",
"num_layers": args.num_layers,
"hidden_size": args.hidden_size,
"dropout": args.dropout,
"leaky_relu": args.leaky_relu,
"bottleneck_dim": args.bottleneck,
# "num_output_layers": 6
}
elif args.model_type == "transformer":
model_config = {
"model_type": "transformer",
"num_layers": args.num_layers,
"hidden_size": args.hidden_size,
}
else:
raise ValueError
main(
args.mode,
trainer_params=default_trainer_params(
gpus=[args.gpu], precision=16, max_epochs=args.max_epochs
),
dataset_params=default_dataset_params(
base=args.dataset, batch_size=args.batch_size, mean_thres=args.mean_thres
),
model_params=default_model_params(
memory_variables=args.memory_variables.split(",")
if args.memory_variables
else None,
ignore_input_variables=args.ignore_input_variables.split(",")
if args.ignore_input_variables
else None,
lr=args.lr,
use_output_scaling=False,
replace_std_with_range=False,
model_config=model_config,
ckpt=args.ckpt,
pretrained = args.pretrained,
lr_schedule = "cosine"
),
seed = True
)
if __name__ == "__main__":
run()