angorapy

Build embodied brain models with ease.

https://github.com/ccnmaastricht/angorapy

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: pubmed.ncbi, ncbi.nlm.nih.gov, frontiersin.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (18.5%) to scientific vocabulary

Keywords

computational-neuroscience deep-learning keras neuroscience sensorimotor-modeling

Scientific Fields

Mathematics Computer Science - 37% confidence
Last synced: 10 months ago · JSON representation ·

Repository

Build embodied brain models with ease.

Basic Info
  • Host: GitHub
  • Owner: ccnmaastricht
  • License: gpl-3.0
  • Language: Python
  • Default Branch: master
  • Homepage: http://angorapy.org
  • Size: 156 MB
Statistics
  • Stars: 20
  • Watchers: 3
  • Forks: 1
  • Open Issues: 3
  • Releases: 8
Topics
computational-neuroscience deep-learning keras neuroscience sensorimotor-modeling
Created almost 7 years ago · Last pushed over 1 year ago
Metadata Files
Readme License Citation

README.md

Monthly Downloads Total Downloads Static Badge



Build Embodied Brain Models with Ease


AngoraPy is an open source modeling library for buidling goal-driven embodied brain models. It provides an easy-to-us API to build and train deep neural network models of the brain on various, customizable, sensorimotor tasks, using reinforcement learning. AngoraPy employs state-of-the-art machine learning techniques, optimized for distributed computation scaling from local workstations to high-performance computing clusters. We aim to hide as much of this under the hood of an intuitive, high-level API but preserve the option for customizing most aspects of the pipeline.

:sparkles: Features

angorapy-features

📥 Installation

Prerequisites

AngoraPy requires Python 3.6 or higher. It is recommended to use a virtual environment to install AngoraPy and its dependencies. Additionally, some prerequisites are required.

On Ubuntu, these can be installed by running

sudo apt-get install swig

Additionally, to run AngoraPy with its native distribution, you need MPI installed. On Ubuntu, this can be done by running

sudo apt-get install libopenmpi-dev

However, any other MPI implementation should work as well.

Installing AngoraPy

Binaries

AngoraPy is available as a binary package on PyPI. To install it, run

pip install angorapy

in your terminal.

If you would like to install a specific version, you can specify it by appending ==<version> to the command above. For example, to install version 0.9.0, run

pip install angorapy==0.10.8

Source Installation

To install AngoraPy from source, clone the repository and run pip install -e . in the root directory.

Test Your Installation

You can test your installation by running the following command in your terminal:

python -m angorapy.train CartPole-v1

To test your MPI installation, run

mpirun -np <numthreads> --use-hwthread-cpus python -m angorapy.train LunarLanderContinuous-v2

where <numthreads> is the number of threads you want to (and can) use.

Docker

Alternatively, you can install AngoraPy and all its dependencies in a docker container using the Dockerfile provided in this repository (/docker/Dockerfile). To this end, download the repository and build the docker image from the /docker directory:

bash sudo docker build -t angorapy:master https://github.com/ccnmaastricht/angorapy.git#master -f - < Dockerfile

To install different versions, replace #master in the source by the tag/branch of the respective version you want to install.

🚀 Getting Started

➡️ Tutorial Section on Getting Started

The scripts train.py, evaluate.py and observe.py provide ready-made scripts for training and evaluating an agent in any environment. With pretrain.py, it is possible to pretrain the visual component. benchmark.py provides functionality for training a batch of agents possibly using different configs for comparison of strategies.

Training an Agent

The train.py commandline interface provides a convenient entry-point for running all sorts of experiments using the builtin models and environments in angorapy. You can train an agent on any environment with optional hyperparameters. Additionally, a monitor will be automatically linked to the training of the agent. For more detail consult the README on monitoring.

Base usage of train.py is as follows:

python -m angorapy.train ENV --architecture MODEL

For instance, training LunarLanderContinuous-v2 using the deeper architecture is possible by running:

python -m angorapy.train LunarLanderContinuous-v2 --architecture deeper

For more advanced options like custom hyperparameters, consult

python -m angorapy.train -h

Evaluating and Observing an Agent

➡️ Tutorial Section on Agent Analysis

There are two more entry points for evaluating and observing an agent: evaluate and observe. General usage is as follows

python -m angorapy.evaluate ID
python -m angorapy.observe ID

Where ID is the agent's ID given when its created (train.py prints this outt, in custom scripts get it with agent.agent_id).

Writing a Training Script

To train agents with custom models, environments, etc. you write your own script. The following is a minimal example:

```python

from angorapy import maketask from angorapy.models import getmodelbuilder from angorapy.agent.ppoagent import PPOAgent

env = maketask("LunarLanderContinuous-v2") modelbuilder = getmodelbuilder("simple", "ffn") agent = PPOAgent(model_builder, env) agent.drill(100, 10, 512) ```

For more details, consult the examples.

Customizing the Models and Environments

➡️ Tutorial Section on Customization

🎓 Documentation

Detailed documentation of AngoraPy is provided in the READMEs of most subpackages. Additionally, we provide examples and tutorials that get you started with writing your own scripts using AngoraPy. For further readings on specific modules, consult the following READMEs:

If you are missing a documentation for a specific part of AngoraPy, feel free to open an issue and we will do our best to add it.

🔀 Distributed Computation

PPO is an asynchronous algorithm, allowing multiple parallel workers to generate experience independently. We allow parallel gathering and optimization through MPI. Agents will automatically distribute their workers evenly on the available CPU cores, while optimization is distributed over all available GPUs. If no GPUs are available, all CPUs share the task of optimizing.

Distribution is possible locally on your workstation and on HPC sites.

💻 Local Distributed Computing with MPI

To use MPI locally, you need to have a running MPI implementation, e.g. Open MPI 4 on Ubuntu. To execute train.py via MPI, run

bash mpirun -np 12 --use-hwthread-cpus python -m angorapy.train ...

where, in this example, 12 is the number of locally available CPU threads and --use-hwthread-cpus makes available threads (as opposed to only cores). Usage of train.py is as described previously.

:cloud: Distributed Training on SLURM-based HPC clusters

Please note that the following is optimized and tested on the specific cluster we use, but should extend to at least any SLURM based setup.

On any SLURM-based HPC cluster you may submit your job with sbatch usising the following script template:

```bash

!/bin/bash -l

SBATCH --job-name="angorapy"

SBATCH --account=xxx

SBATCH --time=24:00:00

SBATCH --nodes=32

SBATCH --ntasks-per-core=1

SBATCH --ntasks-per-node=12

SBATCH --cpus-per-task=1

SBATCH --partition=normal

SBATCH --constraint=gpu&startx

SBATCH --hint=nomultithread

export OMPNUMTHREADS=$SLURMCPUSPERTASK export CRAYCUDA_MPS=1

load virtual environment

source ${HOME}/robovenv/bin/activate

export DISPLAY=:0 srun python3 -u train.py ... ```

The number of parallel workers will equal the number of nodes times the number of CPUs per node (32 x 12 = 384 in the template above).

🔗 Citing AngoraPy

If you use AngoraPy for your research, please cite the technical paper

Weidler, T., Goebel, R., & Senden, M. (2023). AngoraPy: A Python toolkit for modeling anthropomorphic goal-driven sensorimotor systems. Frontiers in Neuroinformatics, 17. 10.3389/fninf.2023.1223687

Or using bibtex

bibtex @software{weidler_angorapy_2023, AUTHOR = {Weidler, Tonio and Goebel, Rainer and Senden, Mario }, TITLE = {AngoraPy: A Python toolkit for modeling anthropomorphic goal-driven sensorimotor systems}, JOURNAL = {Frontiers in Neuroinformatics}, VOLUME = {17}, YEAR = {2023}, DOI = {10.3389/fninf.2023.1223687}, ISSN = {1662-5196}, }

Funding

This project was supported by the European Union's Horizon 2020 Framework Programme for Research and Innovation under the Specific Grant Agreement No. 945539 (Human Brain Project SGA3). It is further supported by an Open Science Fund from the Dutch Research Council (Nederlandse Organisatie voor Wetenschappelijk Onderzoek; NWO). We are grateful for their support.

Owner

  • Name: Cognitive Computational Neuroscience Group Maastricht
  • Login: ccnmaastricht
  • Kind: organization

Studying cognition from the perspective of A.I. and neural computation

Citation (CITATION.cff)

cff-version: 1.2.0
title: >-
  AngoraPy - Anthropomorphic Goal-Oriented Robotic Control for Neuroscientific Modeling
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
date-released: 2020-03-21
authors:
  - given-names: Tonio
    family-names: Weidler
    email: uni@tonioweidler.de
    affiliation: Maastricht University
    orcid: 'https://orcid.org/0000-0003-1608-5523'
  - given-names: Rainer
    family-names: Goebel
    affiliation: Maastricht University
  - given-names: Mario
    family-names: Senden
    affiliation: Maastricht University

GitHub Events

Total
  • Issues event: 1
  • Watch event: 2
  • Member event: 1
  • Push event: 10
  • Fork event: 1
  • Create event: 1
Last Year
  • Issues event: 1
  • Watch event: 2
  • Member event: 1
  • Push event: 10
  • Fork event: 1
  • Create event: 1

Issues and Pull Requests

Last synced: 10 months ago

All Time
  • Total issues: 6
  • Total pull requests: 22
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 2 months
  • Total issue authors: 3
  • Total pull request authors: 4
  • Average comments per issue: 2.33
  • Average comments per pull request: 0.59
  • Merged pull requests: 6
  • Bot issues: 0
  • Bot pull requests: 16
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • prstolpe (4)
  • MSenden (1)
  • kevinzakka (1)
Pull Request Authors
  • dependabot[bot] (16)
  • weidler (2)
  • prstolpe (2)
  • MSenden (1)
Top Labels
Issue Labels
bug (3) help wanted (1) question (1)
Pull Request Labels
dependencies (16)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 137 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 15
  • Total maintainers: 1
pypi.org: angorapy

Build Goal-driven Models of the Sensorimotor Cortex with Ease.

  • Versions: 15
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 137 Last month
Rankings
Dependent packages count: 10.0%
Stargazers count: 15.2%
Average: 18.5%
Dependent repos count: 21.7%
Forks count: 22.6%
Downloads: 22.8%
Maintainers (1)
Last synced: 10 months ago

Dependencies

requirements.txt pypi
  • Box2D *
  • Flask ==1.1.2
  • Flask-JSGlue *
  • Jinja2 ==3.0.0
  • argcomplete *
  • bokeh *
  • distance *
  • graphviz *
  • gym ==0.24.0
  • itsdangerous ==2.0.1
  • matplotlib *
  • mpi4py ==3.1.3
  • mujoco *
  • numpy ==1.19.5
  • nvidia-ml-py3 *
  • nvidia_smi *
  • pandas *
  • protobuf ==3.19.0
  • psutil *
  • pydot *
  • scikit-learn *
  • scipy *
  • seaborn *
  • simplejson *
  • sklearn *
  • tensorflow ==2.4.2
  • tensorflow_datasets *
  • tqdm *
  • werkzeug ==2.0.3
setup.py pypi
  • Box2D *
  • Flask *
  • Jinja2 ==3.0.0
  • argcomplete *
  • bokeh *
  • distance *
  • flask_jsglue *
  • gym ==0.24.0
  • itsdangerous ==2.0.1
  • matplotlib *
  • mpi4py ==3.1.3
  • mujoco *
  • numpy ==1.19.5
  • nvidia-ml-py3 *
  • pandas ==1.0.4
  • protobuf ==3.19.0
  • psutil *
  • scikit-learn ==0.24.1
  • scipy *
  • seaborn *
  • simplejson *
  • sklearn *
  • tensorflow ==2.4.2
  • tqdm *
  • webinterface *
  • werkzeug ==2.0.3
docker/gpu.requirements.txt pypi
pyproject.toml pypi