This repository has been archived by the owner on Aug 28, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patharguments.py
268 lines (205 loc) · 10.4 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
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
#!/usr/bin/env python3
# Copyright (c) Facebook, Inc. and its affiliates.
# This source code is licensed under the Creative Commons license found in the
# LICENSE file in the root directory of this source tree.
import argparse
def get_args():
parser = argparse.ArgumentParser(description="RL")
parser.add_argument("--algo", default="ppo", help="algorithm to use: ppo | supervised")
parser.add_argument("--lr", type=float, default=7e-4, help="learning rate (default: 7e-4)")
parser.add_argument("--eps", type=float, default=1e-5, help="Adam optimizer epsilon (default: 1e-5)")
parser.add_argument("--gamma", type=float, default=0.99, help="discount factor for rewards (default: 0.99)")
parser.add_argument("--use-gae", action="store_true", default=False, help="use generalized advantage estimation")
parser.add_argument("--tau", type=float, default=0.95, help="gae parameter (default: 0.95)")
parser.add_argument("--entropy-coef", type=float, default=0.01, help="entropy term coefficient (default: 0.01)")
parser.add_argument("--value-loss-coef", type=float, default=0.5, help="value loss coefficient (default: 0.5)")
parser.add_argument("--max-grad-norm", type=float, default=0.5, help="max norm of gradients (default: 0.5)")
parser.add_argument("--seed", type=int, default=1, help="random seed (default: 1)")
parser.add_argument(
"--num-processes", type=int, default=16, help="how many training CPU processes to use (default: 16)"
)
parser.add_argument(
"--num-forward-rollout-steps", type=int, default=8, help="number of forward steps in rollouts (default: 8)"
)
parser.add_argument(
"--max-episode-length", type=int, default=500, help="maximum number of steps in a single episode (default: 500)"
)
parser.add_argument("--ppo-epoch", type=int, default=4, help="number of ppo epochs (default: 4)")
parser.add_argument("--num-mini-batch", type=int, default=1, help="number of batches for ppo (default: 1)")
parser.add_argument("--clip-param", type=float, default=0.2, help="ppo clip parameter (default: 0.2)")
parser.add_argument(
"--log-interval", type=int, default=10, help="log interval, one log per n updates (default: 10)"
)
parser.add_argument(
"--save-interval", type=int, default=100, help="save interval, one save per n updates (default: 100)"
)
parser.add_argument(
"--num-env-steps", type=int, default=int(1e8), help="number of environment steps to train (default: 1e8)"
)
parser.add_argument("--no-cuda", action="store_true", default=False, help="disables CUDA training")
parser.add_argument(
"--use-linear-lr-decay", action="store_true", default=False, help="use a linear schedule on the learning rate"
)
parser.add_argument(
"--use-linear-clip-decay",
action="store_true",
default=False,
help="use a linear schedule on the ppo clipping parameter",
)
parser.add_argument("--no-tensorboard", action="store_true", default=False, help="disable tensorboard logging")
parser.add_argument(
"--clear-weights", action="store_true", default=False, help="do not load previous model weights if they exist"
)
parser.add_argument(
"--dataset-dir", type=str, default="data/datasets/pointnav/habitat_test_scenes/v1/train", help="path to dataset"
)
parser.add_argument(
"--use-multithreading",
action="store_true",
default=False,
help="use multithreading instead of multiprocessing (can be useful for debugging)",
)
parser.add_argument(
"--record-video", action="store_true", default=False, help="record the results of forward passes in a video"
)
parser.add_argument(
"--no-weight-update",
action="store_true",
default=False,
help="Do not do weight updates. Useful for looking at checkpoints/eval.",
)
parser.add_argument(
"--data-subset",
type=str,
default="train_small",
help="Picks which data subset to load: train | val | test | train_small",
required=True,
)
parser.add_argument(
"--dataset", type=str, default="mp3d", help="Picks which dataset to load: mp3d | gibson", required=True
)
parser.add_argument(
"--freeze-encoder-features", action="store_true", default=False, help="Does not update the encoder features."
)
parser.add_argument(
"--freeze-visual-decoder-features",
action="store_true",
default=False,
help="Does not update the visual decoder features. Gradients still flow through if the loss is enabled.",
)
parser.add_argument(
"--freeze-motion-decoder-features",
action="store_true",
default=False,
help="Does not update the motion decoder features. Gradients still flow through if the loss is enabled.",
)
parser.add_argument(
"--freeze-policy-decoder-features",
action="store_true",
default=False,
help="Does not update the policy decoder features. Gradients still flow through if the loss is enabled.",
)
parser.add_argument("--no-visual-loss", action="store_true", default=False, help="disable visual loss")
parser.add_argument("--no-motion-loss", action="store_true", default=False, help="disable motion loss")
parser.add_argument("--no-policy-loss", action="store_true", default=False, help="disable policy loss")
parser.add_argument("--log-prefix", type=str, default="output_files", required=True, help="path to logs, checkpoints, etc.")
parser.add_argument(
"--tensorboard-dirname", type=str, default="tensorboard", help="path under log-prefix for tensorboard logs."
)
parser.add_argument(
"--checkpoint-dirname", type=str, default="checkpoints", help="path under log-prefix for checkpoints."
)
parser.add_argument(
"--results-dirname", type=str, default="results", help="path under log-prefix for results logs."
)
parser.add_argument("--no-save-checkpoints", action="store_true", default=False, help="disable saving checkpoints")
parser.add_argument("--debug", action="store_true", default=False, help="Sets the debug flag.")
parser.add_argument(
"--eval-interval", type=int, default=None, help="eval interval, one eval per n updates (default: No eval)"
)
parser.add_argument(
"--end-to-end",
action="store_true",
default=False,
help="If true, gradients flow from RL back through the visual features.",
)
parser.add_argument("--encoder-network-type", type=str, required=True, help="Name of the encoder network type.")
parser.add_argument("--render-gpu-ids", type=str, required=True, help="ID(s) of the gpu(s) to use for rendering.")
parser.add_argument(
"--pytorch-gpu-ids",
type=str,
required=True,
help="ID(s) of the gpu(s) to use for pytorch. " "The first will be where the data unrolls are located.",
)
parser.add_argument(
"--task", type=str, required=True, help="Name of the task that is being used: pointnav | exploration | flee"
)
parser.add_argument(
"--num-train-scenes", type=int, default=-1, help="Number of scenes to use during training (if >0)."
)
parser.add_argument(
"--blind", action="store_true", default=False, help="Blind the network (no images fed in as input)."
)
parser.add_argument("--method-name", type=str, default="SplitNet", help="Name of the method that is being used.")
parser.add_argument(
"--saved-variable-prefix",
type=str,
default="",
help="Prefix on variable names that should be renamed. This should usually be left empty.",
)
parser.add_argument(
"--new-variable-prefix",
type=str,
default="",
help="New prefix on variables that will be renamed. This should usually be left empty.",
)
args = parser.parse_args()
args.tensorboard = not args.no_tensorboard
args.load_model = not args.clear_weights
args.num_envs = args.num_processes
args.save_checkpoints = not args.no_save_checkpoints
args.update_encoder_features = not args.freeze_encoder_features
args.update_visual_decoder_features = not args.freeze_visual_decoder_features
args.update_motion_decoder_features = not args.freeze_motion_decoder_features
args.update_policy_decoder_features = not args.freeze_policy_decoder_features
args.use_visual_loss = not args.no_visual_loss
args.use_motion_loss = not args.no_motion_loss
args.use_policy_loss = not args.no_policy_loss
assert not args.record_video or (
args.num_processes == 1
), "Video only supports one process. Otherwise the videos get too busy."
if not args.no_weight_update:
assert (
args.no_visual_loss or args.update_encoder_features
), "Must update encoder features if using visual loss. Otherwise what's the point?"
assert args.use_policy_loss or args.use_motion_loss or args.use_visual_loss, "Must enable at least one loss"
if args.use_visual_loss:
assert (
args.update_encoder_features or args.update_visual_decoder_features
), "Must update something affected by visual loss."
if args.use_motion_loss:
assert (
args.update_encoder_features and args.end_to_end
) or args.update_motion_decoder_features, "Must update something affected by motion loss."
if args.use_policy_loss:
assert (
args.update_encoder_features and args.end_to_end
) or args.update_policy_decoder_features, "Must update something affected by policy loss."
assert (
args.update_encoder_features
or args.update_motion_decoder_features
or args.update_policy_decoder_features
or args.update_visual_decoder_features
), "Must enable at least one set of weights to update"
if args.no_visual_loss:
assert args.freeze_visual_decoder_features
if args.no_motion_loss:
assert args.freeze_motion_decoder_features
if args.no_policy_loss:
assert args.freeze_policy_decoder_features
if args.update_encoder_features and args.use_policy_loss:
if not args.end_to_end:
print(
"Warning, no gradients will propagate to the encoder from the policy without the end-to-end flag."
)
return args