Skip to content

Commit 616f636

Browse files
authored
Merge pull request #100 from automl/dev
Update main branch
2 parents dd5014d + 3729bdc commit 616f636

92 files changed

Lines changed: 754603 additions & 157 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,9 @@ python mighty/run_mighty.py --config-path=../examples --config-name=hypersweeper
234234
## Logging & Plotting
235235
We have an example notebook that shows you how to load and plot the default Mighty logs. Apart from these, you can also use Tensorboard or W&B for your plotting needs, though for these you should refer to their own documentations.
236236
You can run this notebook to produce new runs for plotting, use randomly generated example data or load your own data into it.
237-
For now these examples are focused on single-task learning instead of generalization or multi-task RL, but we plan on expanding them.
237+
238+
We also include an example on how to examine generalization behavior. This example can be run using the following command:
239+
```bash
240+
sh examples/run_generalization_protocol.sh
241+
```
242+
You can also simply inspect the existing runs in the associated [notebook](./plot_carl_generalization_example.ipynb). There you'll see a comparison of different training distributions on a larger test context distribution for two context features of CARLCartPole.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
runner: standard
2+
debug: false
3+
seed: 42
4+
output_dir: examples/carl_generalization_example
5+
wandb_project: null
6+
tensorboard_file: null
7+
experiment_name: carl_cartpole_generalization_mode_a/seed
8+
algorithm_kwargs:
9+
rescale_action: false
10+
tanh_squash: false
11+
rollout_buffer_class:
12+
_target_: mighty.mighty_replay.MightyRolloutBuffer
13+
rollout_buffer_kwargs:
14+
buffer_size: 2048
15+
gamma: 0.99
16+
gae_lambda: 0.95
17+
obs_shape: ???
18+
act_dim: ???
19+
n_envs: ???
20+
discrete_action: ???
21+
learning_rate: 0.0003
22+
batch_size: 2048
23+
gamma: 0.99
24+
ppo_clip: 0.2
25+
value_loss_coef: 0.5
26+
entropy_coef: 0.01
27+
max_grad_norm: 0.5
28+
hidden_sizes:
29+
- 256
30+
- 256
31+
activation: tanh
32+
n_gradient_steps: 1
33+
n_epochs: 10
34+
minibatch_size: 128
35+
kl_target: null
36+
use_value_clip: true
37+
policy_class: mighty.mighty_exploration.StochasticPolicy
38+
policy_kwargs:
39+
entropy_coefficient: 0.0
40+
eval_every_n_steps: 5000.0
41+
n_episodes_eval: 10
42+
checkpoint: null
43+
save_model_every_n_steps: 1000
44+
cluster: {}
45+
algorithm: PPO
46+
num_steps: 250000
47+
env: CARLCartPole
48+
env_kwargs:
49+
load_contexts: examples/carl_generalization_example/context_sets/train_contexts_a.json
50+
load_eval_contexts: examples/carl_generalization_example/context_sets/eval_contexts_a.json
51+
env_wrappers:
52+
- mighty.mighty_utils.wrappers.FlattenVecObs
53+
num_envs: 64
Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
hydra:
2+
run:
3+
dir: ${output_dir}/${experiment_name}_${seed}
4+
sweep:
5+
dir: ${output_dir}/${experiment_name}_${seed}
6+
subdir: ${hydra.job.num}
7+
launcher:
8+
_target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher
9+
sweeper:
10+
_target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper
11+
max_batch_size: null
12+
params: null
13+
help:
14+
app_name: Mighty-DACs
15+
header: '== ${hydra.help.app_name} ==
16+
17+
The Mighty cRL library you''ve been looking for!'
18+
footer: 'Powered by Hydra (https://hydra.cc)
19+
20+
Use --hydra-help to view Hydra specific help'
21+
template: "${hydra.help.header}\n\n== Configuration groups ==\nCompose your configuration\
22+
\ from those algorithms (algorithm=dqn)\n\n$APP_CONFIG_GROUPS\n\n== Common Hyperparameters\
23+
\ ==\n* debug: flag to toggle debug output (default: false)\n*\
24+
\ seed: Which seed to use (default: 0)\n* output_dir: \
25+
\ Where to store result data (default: /tmp)\n hydra specific\
26+
\ information will be in \"output_dir/year-month-day/timestamp/.hydra\"\n\n\
27+
* wandb_project: For wandb integration (default: null)\n* tensorboard_file:\
28+
\ For tensorboard integration (default: null)\n* experiment_name: The folder\
29+
\ in which the specific experiment data is to be stored.\n \
30+
\ I.e. the path will be \"output_dir/experiment_name\"\n\n* algorithm_kwargs:\
31+
\ A dictionary to specify hyperparameter settings to the algorithms.\n \
32+
\ Will be overwritten/populated with the choice of algorithm.\n\
33+
* num_steps: Maximum number of steps in the environment before episode\
34+
\ ends. (default: 1000000)\n* env: The environment string name\
35+
\ to use, e.g., MountainCarContinuous (default: CartPole-v1)\n \
36+
\ For gym environments please see https://www.gymlibrary.ml/ (simple\
37+
\ control environments are by\n default supported)\n \
38+
\ For DACBench environments please see https://github.com/automl/DACBench\n\
39+
\ For CARL environments please see https://github.com/automl/CARL\n\
40+
* env_kwargs: Dict to modify environment parameters. Note: Currently\
41+
\ only supported for CARL envs\n* env_warppers: List of wrapper classes\
42+
\ to apply to the environment. (default: [])\n\n* eval_every_n_steps: Training\
43+
\ steps interval after which the agent is evaluated on a separate eval_env,\
44+
\ i.e., a \n second copy of the training env (default:\
45+
\ 1000)\n* n_episodes_eval: Training episodes interval after which the agent\
46+
\ is evlauted on a separate eval_env, i.e., a \n second\
47+
\ copy of the training environment (default: null)\n* checkpoint: Path\
48+
\ to load a checkpointed model from. This allows to contnue training. If unset\
49+
\ a new model is\n trained from scratch (default: null)\n\
50+
\n== Config ==\nAny key=value argument can be overridden (use dots for.nested=overrides),\
51+
\ for example:\npython mighty/run_mighty.py 'algorithm=ppo' 'env=MountainCarContinuous'\
52+
\ 'num_steps=1000' 'algorithm_kwargs.learning_rate=0.1'\nor\npython mighty/run_mighty.py\
53+
\ 'algorithm=dqn' 'env=SigmoidBenchmark' 'num_steps=100000'\n\nThis is the configuration\
54+
\ that was generated for this run:\n-------\n$CONFIG\n-------\n\n${hydra.help.footer}"
55+
hydra_help:
56+
template: 'Hydra (${hydra.runtime.version})
57+
58+
See https://hydra.cc for more info.
59+
60+
61+
== Flags ==
62+
63+
$FLAGS_HELP
64+
65+
66+
== Configuration groups ==
67+
68+
Compose your configuration from those groups (For example, append hydra/job_logging=disabled
69+
to command line)
70+
71+
72+
$HYDRA_CONFIG_GROUPS
73+
74+
75+
Use ''--cfg hydra'' to Show the Hydra config.
76+
77+
'
78+
hydra_help: ???
79+
hydra_logging:
80+
version: 1
81+
formatters:
82+
colorlog:
83+
(): colorlog.ColoredFormatter
84+
format: '[%(cyan)s%(asctime)s%(reset)s][%(purple)sHYDRA%(reset)s] %(message)s'
85+
handlers:
86+
console:
87+
class: logging.StreamHandler
88+
formatter: colorlog
89+
stream: ext://sys.stdout
90+
root:
91+
level: INFO
92+
handlers:
93+
- console
94+
disable_existing_loggers: false
95+
job_logging:
96+
version: 1
97+
formatters:
98+
simple:
99+
format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s'
100+
colorlog:
101+
(): colorlog.ColoredFormatter
102+
format: '[%(cyan)s%(asctime)s%(reset)s][%(blue)s%(name)s%(reset)s][%(log_color)s%(levelname)s%(reset)s]
103+
- %(message)s'
104+
log_colors:
105+
DEBUG: purple
106+
INFO: green
107+
WARNING: yellow
108+
ERROR: red
109+
CRITICAL: red
110+
handlers:
111+
console:
112+
class: logging.StreamHandler
113+
formatter: colorlog
114+
stream: ext://sys.stdout
115+
file:
116+
class: logging.FileHandler
117+
formatter: simple
118+
filename: ${hydra.job.name}.log
119+
root:
120+
level: INFO
121+
handlers:
122+
- console
123+
- file
124+
disable_existing_loggers: false
125+
env: {}
126+
mode: RUN
127+
searchpath: []
128+
callbacks: {}
129+
output_subdir: .hydra
130+
overrides:
131+
hydra:
132+
- hydra.mode=RUN
133+
task:
134+
- algorithm=ppo
135+
- env=CARLCartPole
136+
- seed=42
137+
- num_steps=250000
138+
- env_wrappers=[mighty.mighty_utils.wrappers.FlattenVecObs]
139+
- algorithm_kwargs.rollout_buffer_kwargs.buffer_size=2048
140+
- +env_kwargs.load_contexts=examples/carl_generalization_example/context_sets/train_contexts_a.json
141+
- +env_kwargs.load_eval_contexts=examples/carl_generalization_example/context_sets/eval_contexts_a.json
142+
- output_dir=examples/carl_generalization_example
143+
- experiment_name=carl_cartpole_generalization_mode_a/seed
144+
job:
145+
name: run_mighty
146+
chdir: null
147+
override_dirname: +env_kwargs.load_contexts=examples/carl_generalization_example/context_sets/train_contexts_a.json,+env_kwargs.load_eval_contexts=examples/carl_generalization_example/context_sets/eval_contexts_a.json,algorithm=ppo,algorithm_kwargs.rollout_buffer_kwargs.buffer_size=2048,env=CARLCartPole,env_wrappers=[mighty.mighty_utils.wrappers.FlattenVecObs],experiment_name=carl_cartpole_generalization_mode_a/seed,num_steps=250000,output_dir=examples/carl_generalization_example,seed=42
148+
id: ???
149+
num: ???
150+
config_name: base
151+
env_set: {}
152+
env_copy: []
153+
config:
154+
override_dirname:
155+
kv_sep: '='
156+
item_sep: ','
157+
exclude_keys: []
158+
runtime:
159+
version: 1.3.2
160+
version_base: '1.3'
161+
cwd: /Users/theeimer/Documents/git/Mighty-DACS
162+
config_sources:
163+
- path: hydra.conf
164+
schema: pkg
165+
provider: hydra
166+
- path: /Users/theeimer/Documents/git/Mighty-DACS/mighty/configs
167+
schema: file
168+
provider: main
169+
- path: hydra_plugins.hydra_colorlog.conf
170+
schema: pkg
171+
provider: hydra-colorlog
172+
- path: ''
173+
schema: structured
174+
provider: schema
175+
output_dir: /Users/theeimer/Documents/git/Mighty-DACS/examples/carl_generalization_example/carl_cartpole_generalization_mode_a/seed_42
176+
choices:
177+
environment: pufferlib_ocean/bandit
178+
algorithm: ppo
179+
cluster: local
180+
hydra/env: default
181+
hydra/callbacks: null
182+
hydra/job_logging: colorlog
183+
hydra/hydra_logging: colorlog
184+
hydra/hydra_help: default
185+
hydra/help: mighty_help
186+
hydra/sweeper: basic
187+
hydra/launcher: basic
188+
hydra/output: default
189+
verbose: false
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
- algorithm=ppo
2+
- env=CARLCartPole
3+
- seed=42
4+
- num_steps=250000
5+
- env_wrappers=[mighty.mighty_utils.wrappers.FlattenVecObs]
6+
- algorithm_kwargs.rollout_buffer_kwargs.buffer_size=2048
7+
- +env_kwargs.load_contexts=examples/carl_generalization_example/context_sets/train_contexts_a.json
8+
- +env_kwargs.load_eval_contexts=examples/carl_generalization_example/context_sets/eval_contexts_a.json
9+
- output_dir=examples/carl_generalization_example
10+
- experiment_name=carl_cartpole_generalization_mode_a/seed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
,step,seed,eval_episodes,mean_eval_step_reward,mean_eval_reward,instances
2+
0,5000,42,[1.],[1.],14.0,1
3+
1,10000,42,[1.],[1.],17.0,2
4+
2,15000,42,[1.],[1.],22.0,3
5+
3,20000,42,[1.],[1.],16.0,4
6+
4,25000,42,[1.],[1.],10.0,5
7+
5,30000,42,[1.],[1.],16.0,6
8+
6,35000,42,[1.],[1.],18.0,7
9+
7,40000,42,[1.],[1.],16.0,8
10+
8,45000,42,[1.],[1.],11.0,9
11+
9,50000,42,[1.],[1.],22.0,10
12+
10,55000,42,[1.],[1.],18.0,11
13+
11,60000,42,[1.],[1.],12.0,12
14+
12,65000,42,[1.],[1.],11.0,13
15+
13,70000,42,[1.],[1.],15.0,14
16+
14,75000,42,[1.],[1.],26.0,15
17+
15,80000,42,[1.],[1.],11.0,16
18+
16,85000,42,[1.],[1.],19.0,17
19+
17,90000,42,[1.],[1.],58.0,18
20+
18,95000,42,[1.],[1.],151.0,19
21+
19,100000,42,[1.],[1.],122.0,20
22+
20,105000,42,[1.],[1.],109.0,21
23+
21,110000,42,[1.],[1.],128.0,22
24+
22,115000,42,[1.],[1.],493.0,23
25+
23,120000,42,[1.],[1.],194.0,24
26+
24,125000,42,[1.],[1.],500.0,25
27+
25,130000,42,[1.],[1.],236.0,26
28+
26,135000,42,[1.],[1.],367.0,27
29+
27,140000,42,[1.],[1.],300.0,28
30+
28,145000,42,[1.],[1.],328.0,29
31+
29,150000,42,[1.],[1.],86.0,30
32+
30,155000,42,[1.],[1.],108.0,31
33+
31,160000,42,[1.],[1.],500.0,32
34+
32,165000,42,[1.],[1.],100.0,33
35+
33,170000,42,[1.],[1.],23.0,34
36+
34,175000,42,[1.],[1.],79.0,35
37+
35,180000,42,[1.],[1.],500.0,36
38+
36,185000,42,[1.],[1.],88.0,37
39+
37,190000,42,[1.],[1.],51.0,38
40+
38,195000,42,[1.],[1.],39.0,39
41+
39,200000,42,[1.],[1.],169.0,40
42+
40,205000,42,[1.],[1.],165.0,41
43+
41,210000,42,[1.],[1.],50.0,42
44+
42,215000,42,[1.],[1.],226.0,43
45+
43,220000,42,[1.],[1.],500.0,44
46+
44,225000,42,[1.],[1.],79.0,45
47+
45,230000,42,[1.],[1.],63.0,46
48+
46,235000,42,[1.],[1.],123.0,47
49+
47,240000,42,[1.],[1.],243.0,48
50+
48,245000,42,[1.],[1.],444.0,49
51+
49,250000,42,[1.],[1.],500.0,50
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
,step,hp/lr,hp/pi_epsilon,hp/batch_size,hp/learning_starts,meta_modules
2+
0,0,0.0003,0.1,2048,1,[]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"0": {"gravity": 8.1236203565421, "masscart": 1.0, "masspole": 0.1, "length": 0.3623978081345, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "1": {"gravity": 9.8521429192297, "masscart": 1.0, "masspole": 0.1, "length": 0.3232334448673, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "2": {"gravity": 9.1959818254342, "masscart": 1.0, "masspole": 0.1, "length": 0.64647045831, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "3": {"gravity": 8.7959754525911, "masscart": 1.0, "masspole": 0.1, "length": 0.5404460046973, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "4": {"gravity": 7.4680559213273, "masscart": 1.0, "masspole": 0.1, "length": 0.5832290311184, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "5": {"gravity": 7.0617534828874, "masscart": 1.0, "masspole": 0.1, "length": 0.3733618039414, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "6": {"gravity": 9.909729556486, "masscart": 1.0, "masspole": 0.1, "length": 0.4216968971838, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "7": {"gravity": 9.4973279224013, "masscart": 1.0, "masspole": 0.1, "length": 0.5099025726529, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "8": {"gravity": 7.6370173320348, "masscart": 1.0, "masspole": 0.1, "length": 0.4727780074568, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}, "9": {"gravity": 7.5454749016213, "masscart": 1.0, "masspole": 0.1, "length": 0.4164916560792, "force_mag": 10.0, "tau": 0.02, "initial_state_lower": -0.1, "initial_state_upper": 0.1}}

0 commit comments

Comments
 (0)