forked from tesslerc/TD3-JAX
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
81 lines (75 loc) · 2.63 KB
/
Copy pathmain.py
File metadata and controls
81 lines (75 loc) · 2.63 KB
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
"""
Credits: https://github.com/sfujim/TD3
"""
import argparse
from pathlib import Path
from typing import Any
from trainer import Trainer
OptState = Any
def add_arguments(parser):
parser.add_argument(
"--batch-size", type=int, help="Batch size for both actor and critic",
)
parser.add_argument("--discount", type=float) # Discount factor
parser.add_argument(
"--env", dest="env_id", help="OpenAI gym environment name",
)
parser.add_argument(
"--eval-episodes", type=int, help="How many episodes of evaluation to perform"
)
parser.add_argument(
"--eval-freq", type=int, help="How often (time steps) we evaluate"
)
parser.add_argument(
"--initial-log-alpha", type=float, help="How often (time steps) we evaluate",
)
parser.add_argument("--lr", type=float) # Optimizer learning rates
parser.add_argument(
"--max-timesteps", type=int, help="Max time steps to run environment",
)
parser.add_argument(
"--policy-freq", type=int, help="Frequency of delayed policy updates"
)
parser.add_argument("--replay-size", type=int, help="Size of the replay buffer")
parser.add_argument("--seed", type=int, help="Sets Gym, PyTorch and Numpy seeds")
parser.add_argument(
"--start-timesteps", type=int, help="Time steps initial random policy is used",
)
parser.add_argument("--save-dir", type=Path, help="directory to save model")
parser.add_argument(
"config",
help="name of config file to load from configs/ directory or from configs.configs "
"dict",
)
parser.add_argument("--name", help="name of experiment (for tune)")
parser.add_argument(
"--num-samples",
"-n",
type=int,
help="Number of times to sample from the hyperparameter space. See tune docs for details: "
"https://docs.ray.io/en/latest/tune/api_docs/execution.html?highlight=run#ray.tune.run",
)
parser.add_argument(
"--tune",
dest="use_tune",
action="store_true",
help="Use tune for logging and hyperparameter search",
)
parser.add_argument(
"--cpus-per-trial",
"-c",
type=int,
default=6,
help="This parameters is used by tune to " "determine how many runs to launch.",
)
parser.add_argument(
"--gpus-per-trial",
"-g",
type=int,
default=1,
help="This parameters is used by tune to " "determine how many runs to launch.",
)
if __name__ == "__main__":
PARSER = argparse.ArgumentParser()
add_arguments(PARSER)
Trainer.main(**vars(PARSER.parse_args()))