-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #465 from instadeepai/develop
Feature / Release 0.1.2
- Loading branch information
Showing
34 changed files
with
1,360 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
name: Investigation | ||
about: Outline the structure for an investigation. This would commonly be used to measure the impact of various design/implementation choices. | ||
title: '[INVESTIGATION]' | ||
labels: investigation | ||
assignees: '' | ||
|
||
--- | ||
|
||
### What do you want to investigate? | ||
A brief description of what you would like to investigate. Do you have a hypothesis? | ||
|
||
### Definition of done | ||
A precise outline for the investigation to be considered complete. | ||
|
||
### [***Optional***] Results | ||
<!-- This is added after the investigation is complete. --> | ||
Results from experiments/derivations. This could be linked to a benchmarking issue. | ||
|
||
### What was the conclusion of your investigation? | ||
<!-- This is added after the investigation is complete. --> | ||
- What are the findings from the investigation? | ||
- Was your hypothesis correct? | ||
|
||
### [***Optional***] Discussion/Future Investigations | ||
<!-- This is added after the investigation is complete. --> | ||
This could be a link to a Github [discussions page](https://github.com/instadeepai/Mava/discussions). | ||
|
||
<!-- Base checklist. Don’t hesitate to adapt it to your use-case. --> |
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
108 changes: 108 additions & 0 deletions
108
examples/tf/petting_zoo/butterfly/cooperative_pong/feedforward/decentralised/run_mappo.py
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,108 @@ | ||
# python3 | ||
# Copyright 2021 InstaDeep Ltd. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""Example running MAPPO on Cooperative Atari Pong.""" | ||
|
||
import functools | ||
from datetime import datetime | ||
from typing import Any | ||
|
||
import launchpad as lp | ||
import numpy as np | ||
from absl import app, flags | ||
from acme.tf.networks import AtariTorso | ||
from supersuit import dtype_v0 | ||
|
||
from mava.systems.tf import mappo | ||
from mava.utils import lp_utils | ||
from mava.utils.environments import pettingzoo_utils | ||
from mava.utils.loggers import logger_utils | ||
|
||
FLAGS = flags.FLAGS | ||
flags.DEFINE_string( | ||
"env_class", | ||
"butterfly", | ||
"Pettingzoo environment class, e.g. atari (str).", | ||
) | ||
flags.DEFINE_string( | ||
"env_name", | ||
"cooperative_pong_v3", | ||
"Pettingzoo environment name, e.g. pong (str).", | ||
) | ||
|
||
flags.DEFINE_string( | ||
"mava_id", | ||
str(datetime.now()), | ||
"Experiment identifier that can be used to continue experiments.", | ||
) | ||
flags.DEFINE_string("base_dir", "~/mava", "Base dir to store experiments.") | ||
|
||
|
||
def main(_: Any) -> None: | ||
"""Run example.""" | ||
|
||
# Environment | ||
environment_factory = functools.partial( | ||
pettingzoo_utils.make_environment, | ||
env_class=FLAGS.env_class, | ||
env_name=FLAGS.env_name, | ||
env_preprocess_wrappers=[(dtype_v0, {"dtype": np.float32})], | ||
) | ||
|
||
# Networks. | ||
network_factory = lp_utils.partial_kwargs( | ||
mappo.make_default_networks, observation_network=AtariTorso() | ||
) | ||
|
||
# Checkpointer appends "Checkpoints" to checkpoint_dir | ||
checkpoint_dir = f"{FLAGS.base_dir}/{FLAGS.mava_id}" | ||
|
||
# Log every [log_every] seconds. | ||
log_every = 10 | ||
logger_factory = functools.partial( | ||
logger_utils.make_logger, | ||
directory=FLAGS.base_dir, | ||
to_terminal=True, | ||
to_tensorboard=True, | ||
time_stamp=FLAGS.mava_id, | ||
time_delta=log_every, | ||
) | ||
|
||
# Distributed program | ||
program = mappo.MAPPO( | ||
environment_factory=environment_factory, | ||
network_factory=network_factory, | ||
logger_factory=logger_factory, | ||
num_executors=1, | ||
checkpoint_subpath=checkpoint_dir, | ||
num_epochs=5, | ||
batch_size=32, | ||
).build() | ||
|
||
# Ensure only trainer runs on gpu, while other processes run on cpu. | ||
local_resources = lp_utils.to_device( | ||
program_nodes=program.groups.keys(), nodes_on_gpu=["trainer"] | ||
) | ||
|
||
# Launch. | ||
lp.launch( | ||
program, | ||
lp.LaunchType.LOCAL_MULTI_PROCESSING, | ||
terminal="current_terminal", | ||
local_resources=local_resources, | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(main) |
File renamed without changes.
Oops, something went wrong.