-
Notifications
You must be signed in to change notification settings - Fork 2
/
arguments.py
executable file
·229 lines (191 loc) · 7.53 KB
/
arguments.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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
import argparse
import torch
def get_args():
parser = argparse.ArgumentParser()
# the saving directory for train.py
parser.add_argument(
'--output_dir', type=str, default='trained_models/my_model')
# resume training from an existing checkpoint or not
parser.add_argument(
'--resume', default=False, action='store_true')
# if resume = True, load from the following checkpoint
parser.add_argument(
'--load-path', default='trained_models/my_model/checkpoints/75200.pt',
help='path of weights for resume training')
parser.add_argument(
'--overwrite',
default=True,
action='store_true',
help="whether to overwrite the output directory in training")
parser.add_argument(
'--num_threads',
type=int,
default=1,
help="number of threads used for intraop parallelism on CPU")
parser.add_argument(
'--cuda-deterministic',
action='store_true',
default=False,
help="sets flags for determinism when using CUDA (potentially slow!)")
# only works for gpu only (although you can make it work on cpu after some minor fixes)
parser.add_argument(
'--no-cuda',
action='store_true',
default=False,
help='disables CUDA training')
parser.add_argument(
'--seed', type=int, default=425, help='random seed (default: 1)')
parser.add_argument(
'--num-processes',
type=int,
default=16,
help='how many training processes to use (default: 16)')
# Number of parallel environments for collecting robot experience
parser.add_argument(
'--num-mini-batch',
type=int,
default=2,
help='number of batches for ppo (default: 32)')
parser.add_argument(
'--num-steps',
type=int,
default=30,
help='number of forward steps in A2C (default: 5)')
# Mahsa: PPO parameters
parser.add_argument(
'--ppo-epoch',
type=int,
default=5,
help='number of ppo epochs (default: 4)')
parser.add_argument(
'--clip-param',
type=float,
default=0.2,
help='ppo clip parameter (default: 0.2)')
parser.add_argument(
'--value-loss-coef',
type=float,
default=0.5,
help='value loss coefficient (default: 0.5)')
parser.add_argument(
'--entropy-coef',
type=float,
default=0.0,
help='entropy term coefficient (default: 0.01)')
parser.add_argument(
'--lr', type=float, default=4e-5, help='learning rate (default: 4e-5)')
parser.add_argument(
'--eps',
type=float,
default=1e-5,
help='RMSprop optimizer epsilon (default: 1e-5)')
parser.add_argument(
'--max-grad-norm',
type=float,
default=0.5,
help='max norm of gradients (default: 0.5)')
parser.add_argument(
'--gamma',
type=float,
default=0.99,
help='discount factor for rewards (default: 0.99)')
parser.add_argument(
'--num-env-steps',
type=int,
default=40e6,
help='number of environment steps to train (default: 40e6)')
parser.add_argument(
'--use-linear-lr-decay',
action='store_true',
default=True,
help='use a linear schedule on the learning rate')
parser.add_argument(
'--lr-decay-start-epoch',
type=int,
default=5000,
help='starting the learning rate atfer this amount of update')
parser.add_argument(
'--algo', default='ppo', help='algorithm to use: a2c | ppo | acktr')
# Sequence length
parser.add_argument('--seq_length', type=int, default=30,
help='Sequence length') # same as algo_args.num_steps!
# ===========================================================
# params of prediction model
# ===========================================================
parser.add_argument('--pred_length', type=int, default=6,
help='prediction length')
parser.add_argument('--obs_length', type=int, default=6,
help='Observed length of the trajectory')
parser.add_argument('--batch_size', type=int, default=1,
help='batch size of the dataset. Its 1 for inference')
# ===========================================================
# ===========================================================
# "PedSimPred-v0" when using prediction
# "PedSim-v0" when not using prediction
parser.add_argument(
'--env-name',
default='PedSimPred-v0',
help='name of the environment')
# use uncertainty-aware prediction or not
parser.add_argument('--uncertainty_aware', type=bool, default=True)
# sort all humans and squeeze them to the front or not
parser.add_argument('--sort_humans', type=bool, default=True)
# use self attn in human states or not
parser.add_argument('--use_self_attn', type=bool, default=True,
help='Attention size')
# use self attn in vehicle states or not
parser.add_argument('--use_self_attn_veh', type=bool, default=True,
help='Attention size')
parser.add_argument(
'--use-gae',
action='store_true',
default=True,
help='use generalized advantage estimation')
parser.add_argument(
'--gae-lambda',
type=float,
default=0.95,
help='gae lambda parameter (default: 0.95)')
parser.add_argument(
'--use-proper-time-limits',
action='store_true',
default=False,
help='compute returns taking into account time limits')
parser.add_argument(
'--save-interval',
type=int,
default=200,
help='save interval, one save per n updates (default: 100)')
parser.add_argument(
'--log-interval',
type=int,
default=10,
help='log interval, one log per n updates (default: 10)')
# for srnn only
# RNN size
parser.add_argument('--human_node_rnn_size', type=int, default=128,
help='Size of Human Node RNN hidden state')
parser.add_argument('--human_human_edge_rnn_size', type=int, default=256,
help='Size of Human Human Edge RNN hidden state')
# Input and output size
parser.add_argument('--human_node_input_size', type=int, default=3,
help='Dimension of the node features')
parser.add_argument('--human_human_edge_input_size', type=int, default=2,
help='Dimension of the edge features')
parser.add_argument('--human_node_output_size', type=int, default=256,
help='Dimension of the node output')
# Embedding size
parser.add_argument('--human_node_embedding_size', type=int, default=64,
help='Embedding size of node features')
parser.add_argument('--human_human_edge_embedding_size', type=int, default=64,
help='Embedding size of edge features')
# Attention vector dimension
parser.add_argument('--attention_size', type=int, default=64,
help='Attention size')
parser.add_argument('--consider-veh',
default=False,
action='store_true',
help='whether to consider robot-vehicle spatial egdes in the model or not')
args = parser.parse_args()
args.cuda = not args.no_cuda and torch.cuda.is_available()
return args