-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4690a80
commit d28519d
Showing
9 changed files
with
292 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
# | ||
|
||
from pathlib import Path | ||
|
||
from benchmarl.hydra_config import reload_experiment_from_file | ||
|
||
if __name__ == "__main__": | ||
|
||
# Let's assume that we have run an experiment with | ||
# `python benchmarl/run.py task=vmas/balance algorithm=mappo experiment.max_n_iters=2 experiment.on_policy_collected_frames_per_batch=100 experiment.checkpoint_interval=100` | ||
# and we have obtained | ||
# "outputs/2024-09-09/20-39-31/mappo_balance_mlp__cd977b69_24_09_09-20_39_31/checkpoints/checkpoint_100.pt"" | ||
|
||
# Now we tell it where to restore from | ||
current_folder = Path(__file__).parent.absolute() | ||
restore_file = ( | ||
current_folder | ||
/ "outputs/2024-09-09/20-39-31/mappo_balance_mlp__cd977b69_24_09_09-20_39_31/checkpoints/checkpoint_100.pt" | ||
) | ||
|
||
experiment = reload_experiment_from_file(str(restore_file)) | ||
experiment.evaluate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
# | ||
# | ||
|
||
# Assume we have run the experiment with | ||
# python benchmarl/run.py task=vmas/balance algorithm=mappo experiment.max_n_iters=2 experiment.on_policy_collected_frames_per_batch=100 experiment.checkpoint_interval=100 | ||
# Evaluate it at the given checkpoint | ||
python benchmarl/evaluate.py ../outputs/2024-09-09/20-39-31/mappo_balance_mlp__cd977b69_24_09_09-20_39_31/checkpoints/checkpoint_100.pt |
81 changes: 81 additions & 0 deletions
81
examples/evaluate/outputs/2024-09-09/20-39-31/.hydra/config.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
experiment: | ||
sampling_device: cpu | ||
train_device: cpu | ||
buffer_device: cpu | ||
share_policy_params: true | ||
prefer_continuous_actions: true | ||
collect_with_grad: false | ||
gamma: 0.9 | ||
lr: 5.0e-05 | ||
adam_eps: 1.0e-06 | ||
clip_grad_norm: true | ||
clip_grad_val: 5.0 | ||
soft_target_update: true | ||
polyak_tau: 0.005 | ||
hard_target_update_frequency: 5 | ||
exploration_eps_init: 0.8 | ||
exploration_eps_end: 0.01 | ||
exploration_anneal_frames: null | ||
max_n_iters: 3 | ||
max_n_frames: 3000000 | ||
on_policy_collected_frames_per_batch: 100 | ||
on_policy_n_envs_per_worker: 10 | ||
on_policy_n_minibatch_iters: 45 | ||
on_policy_minibatch_size: 400 | ||
off_policy_collected_frames_per_batch: 6000 | ||
off_policy_n_envs_per_worker: 10 | ||
off_policy_n_optimizer_steps: 1000 | ||
off_policy_train_batch_size: 128 | ||
off_policy_memory_size: 1000000 | ||
off_policy_init_random_frames: 0 | ||
evaluation: true | ||
render: true | ||
evaluation_interval: 120000 | ||
evaluation_episodes: 10 | ||
evaluation_deterministic_actions: true | ||
loggers: | ||
- csv | ||
project_name: benchmarl | ||
create_json: true | ||
save_folder: null | ||
restore_file: null | ||
restore_map_location: null | ||
checkpoint_interval: 100 | ||
checkpoint_at_end: false | ||
keep_checkpoints_num: 3 | ||
algorithm: | ||
share_param_critic: true | ||
clip_epsilon: 0.2 | ||
entropy_coef: 0.0 | ||
critic_coef: 1.0 | ||
loss_critic_type: l2 | ||
lmbda: 0.9 | ||
scale_mapping: biased_softplus_1.0 | ||
use_tanh_normal: true | ||
minibatch_advantage: false | ||
task: | ||
max_steps: 100 | ||
n_agents: 4 | ||
random_package_pos_on_line: true | ||
package_mass: 5.0 | ||
model: | ||
name: mlp | ||
num_cells: | ||
- 256 | ||
- 256 | ||
layer_class: torch.nn.Linear | ||
activation_class: torch.nn.Tanh | ||
activation_kwargs: null | ||
norm_class: null | ||
norm_kwargs: null | ||
critic_model: | ||
name: mlp | ||
num_cells: | ||
- 256 | ||
- 256 | ||
layer_class: torch.nn.Linear | ||
activation_class: torch.nn.Tanh | ||
activation_kwargs: null | ||
norm_class: null | ||
norm_kwargs: null | ||
seed: 0 |
164 changes: 164 additions & 0 deletions
164
examples/evaluate/outputs/2024-09-09/20-39-31/.hydra/hydra.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
hydra: | ||
run: | ||
dir: outputs/${now:%Y-%m-%d}/${now:%H-%M-%S} | ||
sweep: | ||
dir: multirun/${now:%Y-%m-%d}/${now:%H-%M-%S} | ||
subdir: ${hydra.job.num} | ||
launcher: | ||
_target_: hydra._internal.core_plugins.basic_launcher.BasicLauncher | ||
sweeper: | ||
_target_: hydra._internal.core_plugins.basic_sweeper.BasicSweeper | ||
max_batch_size: null | ||
params: null | ||
help: | ||
app_name: ${hydra.job.name} | ||
header: '${hydra.help.app_name} is powered by Hydra. | ||
' | ||
footer: 'Powered by Hydra (https://hydra.cc) | ||
Use --hydra-help to view Hydra specific help | ||
' | ||
template: '${hydra.help.header} | ||
== Configuration groups == | ||
Compose your configuration from those groups (group=option) | ||
$APP_CONFIG_GROUPS | ||
== Config == | ||
Override anything in the config (foo.bar=value) | ||
$CONFIG | ||
${hydra.help.footer} | ||
' | ||
hydra_help: | ||
template: 'Hydra (${hydra.runtime.version}) | ||
See https://hydra.cc for more info. | ||
== Flags == | ||
$FLAGS_HELP | ||
== Configuration groups == | ||
Compose your configuration from those groups (For example, append hydra/job_logging=disabled | ||
to command line) | ||
$HYDRA_CONFIG_GROUPS | ||
Use ''--cfg hydra'' to Show the Hydra config. | ||
' | ||
hydra_help: ??? | ||
hydra_logging: | ||
version: 1 | ||
formatters: | ||
simple: | ||
format: '[%(asctime)s][HYDRA] %(message)s' | ||
handlers: | ||
console: | ||
class: logging.StreamHandler | ||
formatter: simple | ||
stream: ext://sys.stdout | ||
root: | ||
level: INFO | ||
handlers: | ||
- console | ||
loggers: | ||
logging_example: | ||
level: DEBUG | ||
disable_existing_loggers: false | ||
job_logging: | ||
version: 1 | ||
formatters: | ||
simple: | ||
format: '[%(asctime)s][%(name)s][%(levelname)s] - %(message)s' | ||
handlers: | ||
console: | ||
class: logging.StreamHandler | ||
formatter: simple | ||
stream: ext://sys.stdout | ||
file: | ||
class: logging.FileHandler | ||
formatter: simple | ||
filename: ${hydra.runtime.output_dir}/${hydra.job.name}.log | ||
root: | ||
level: INFO | ||
handlers: | ||
- console | ||
- file | ||
disable_existing_loggers: false | ||
env: {} | ||
mode: RUN | ||
searchpath: [] | ||
callbacks: {} | ||
output_subdir: .hydra | ||
overrides: | ||
hydra: | ||
- hydra.mode=RUN | ||
task: | ||
- task=vmas/balance | ||
- algorithm=mappo | ||
- experiment.max_n_iters=3 | ||
- experiment.on_policy_collected_frames_per_batch=100 | ||
- experiment.checkpoint_interval=100 | ||
job: | ||
name: run | ||
chdir: null | ||
override_dirname: algorithm=mappo,experiment.checkpoint_interval=100,experiment.max_n_iters=3,experiment.on_policy_collected_frames_per_batch=100,task=vmas/balance | ||
id: ??? | ||
num: ??? | ||
config_name: config | ||
env_set: {} | ||
env_copy: [] | ||
config: | ||
override_dirname: | ||
kv_sep: '=' | ||
item_sep: ',' | ||
exclude_keys: [] | ||
runtime: | ||
version: 1.3.2 | ||
version_base: '1.3' | ||
cwd: /Users/Matteo/PycharmProjects/BenchMARL/examples/evaluate | ||
config_sources: | ||
- path: hydra.conf | ||
schema: pkg | ||
provider: hydra | ||
- path: /Users/Matteo/PycharmProjects/BenchMARL/benchmarl/conf | ||
schema: file | ||
provider: main | ||
- path: '' | ||
schema: structured | ||
provider: schema | ||
output_dir: /Users/Matteo/PycharmProjects/BenchMARL/examples/evaluate/outputs/2024-09-09/20-39-31 | ||
choices: | ||
model@critic_model: layers/mlp | ||
model: layers/mlp | ||
task: vmas/balance | ||
algorithm: mappo | ||
experiment: base_experiment | ||
hydra/env: default | ||
hydra/callbacks: null | ||
hydra/job_logging: default | ||
hydra/hydra_logging: default | ||
hydra/hydra_help: default | ||
hydra/help: default | ||
hydra/sweeper: basic | ||
hydra/launcher: basic | ||
hydra/output: default | ||
verbose: false |
5 changes: 5 additions & 0 deletions
5
examples/evaluate/outputs/2024-09-09/20-39-31/.hydra/overrides.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
- task=vmas/balance | ||
- algorithm=mappo | ||
- experiment.max_n_iters=3 | ||
- experiment.on_policy_collected_frames_per_batch=100 | ||
- experiment.checkpoint_interval=100 |
Binary file added
BIN
+984 KB
...9-09/20-39-31/mappo_balance_mlp__cd977b69_24_09_09-20_39_31/checkpoints/checkpoint_100.pt
Binary file not shown.
Binary file added
BIN
+984 KB
...9-09/20-39-31/mappo_balance_mlp__cd977b69_24_09_09-20_39_31/checkpoints/checkpoint_200.pt
Binary file not shown.