-
Notifications
You must be signed in to change notification settings - Fork 1
/
config.py
86 lines (68 loc) · 2.02 KB
/
config.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
from collections import namedtuple
from hydra.core.config_store import ConfigStore
from omegaconf import MISSING, DictConfig
Parsers = namedtuple("Parser", "main agent ppo rollouts")
from dataclasses import dataclass, field
from typing import Optional, Any, List
def flatten(cfg: DictConfig):
for k, v in cfg.items():
if isinstance(v, DictConfig):
for k_, v_ in flatten(v):
yield f"{k}_{k_}", v_
else:
yield k, v
@dataclass
class Eval:
interval: Optional[int] = MISSING
steps: Optional[int] = MISSING
@dataclass
class NoEval(Eval):
interval: Optional[int] = None
steps: Optional[int] = None
@dataclass
class YesEval(Eval):
interval: Optional[int] = int(1e5)
steps: Optional[int] = 500
@dataclass
class BaseConfig:
activation_name: str = "ReLU"
clip_param: float = 0.2
cuda_deterministic: bool = True
entropy_coef: float = 0.25
eval: Any = MISSING
gamma: float = 0.99
group: Optional[str] = None
hidden_size: int = 150
learning_rate: float = 0.0025
load_path: Optional[str] = None
log_interval: int = int(1e5)
max_grad_norm: float = 0.5
name: Optional[str] = None
normalize: bool = False
num_batch: int = 1
num_processes: int = 100
optimizer: str = "Adam"
ppo_epoch: int = 5
cuda: bool = True
use_wandb: bool = True
num_frames: Optional[int] = None
render: bool = False
render_eval: bool = False
save_interval: int = int(1e5)
seed: int = 0
synchronous: bool = False
tau: float = 0.95
train_steps: int = 25
use_gae: bool = False
value_loss_coef: float = 0.5
wandb_version: Optional[str] = None
_wandb: Optional[str] = None
defaults: List[Any] = field(default_factory=lambda: [dict(eval="yes")])
@dataclass
class Config(BaseConfig):
env: str = "CartPole-v0"
num_layers: int = 100
recurrent: bool = False
cs = ConfigStore.instance()
cs.store(group="eval", name="yes", node=YesEval)
cs.store(group="eval", name="no", node=NoEval)