Catalog PyPI
Back to packageRELEASE DETAILS

0.0.5

PyPI

actorch

Deep reinforcement learning framework for fast prototyping based on PyTorch

deeplearningpytorchreinforcement
Published12 Mar 2023
Direct dependencies25
Transitive dependenciesNot calculated

README

Version 0.0.5 documentation

logo

Python version: 3.6 | 3.7 | 3.8 | 3.9 | 3.10 License Code style: black Imports: isort pre-commit PyPI version

Welcome to actorch, a deep reinforcement learning framework for fast prototyping based on PyTorch. The following algorithms have been implemented so far:


💡 Key features

  • Support for OpenAI Gymnasium environments
  • Support for custom observation/action spaces
  • Support for custom multimodal input multimodal output models
  • Support for recurrent models (e.g. RNNs, LSTMs, GRUs, etc.)
  • Support for custom policy/value distributions
  • Support for custom preprocessing/postprocessing pipelines
  • Support for custom exploration strategies
  • Support for normalizing flows
  • Batched environments (both for training and evaluation)
  • Batched trajectory replay
  • Batched and distributional value estimation (e.g. batched and distributional Retrace and V-trace)
  • Data parallel and distributed data parallel multi-GPU training and evaluation
  • Automatic mixed precision training
  • Integration with Ray Tune for experiment execution and hyperparameter tuning at any scale
  • Effortless experiment definition through Python-based configuration files
  • Built-in visualization tool to plot performance metrics
  • Modular object-oriented design
  • Detailed API documentation

🛠️️ Installation

For Windows, make sure the latest Visual C++ runtime is installed.

Using Pip

First of all, install Python 3.6 or later. Open a terminal and run:

pip install actorch

Using Conda virtual environment

Clone or download and extract the repository, navigate to <path-to-repository>/bin and run the installation script (install.sh for Linux/macOS, install.bat for Windows). actorch and its dependencies (pinned to a specific version) will be installed in a Conda virtual environment named actorch-env.

NOTE: you can directly use actorch-env and the actorch package in the local project directory for development (see For development).

Using Docker (Linux/macOS only)

First of all, install Docker and NVIDIA Container Runtime. Clone or download and extract the repository, navigate to <path-to-repository>, open a terminal and run:

docker build -t <desired-image-name> .                  # Build image
docker run -it --runtime=nvidia <desired-image-name>    # Run container from image

actorch and its dependencies (pinned to a specific version) will be installed in the specified Docker image.

NOTE: you can directly use the actorch package in the local project directory inside a Docker container run from the specified Docker image for development (see For development).

From source

First of all, install Python 3.6 or later. Clone or download and extract the repository, navigate to <path-to-repository>, open a terminal and run:

pip install .

For development

First of all, install Python 3.6 or later and Git. Clone or download and extract the repository, navigate to <path-to-repository>, open a terminal and run:

pip install -e .[all]
pre-commit install -f

This will install the package in editable mode (any change to the package in the local project directory will automatically reflect on the environment-wide package installed in the site-packages directory of your environment) along with its development, test and optional dependencies. Additionally, it installs a git commit hook. Each time you commit, unit tests, static type checkers, code formatters and linters are run automatically. Run pre-commit run --all-files to check that the hook was successfully installed. For more details, see pre-commit's documentation.


▶️ Quickstart

In this example we will solve the OpenAI Gymnasium environment CartPole-v1 using REINFORCE. Copy the following configuration in a file named REINFORCE_CartPole-v1.py (with the same indentation):

import gymnasium as gym
from torch.optim import Adam

from actorch import *


experiment_params = ExperimentParams(
    run_or_experiment=REINFORCE,
    stop={"training_iteration": 50},
    resources_per_trial={"cpu": 1, "gpu": 0},
    checkpoint_freq=10,
    checkpoint_at_end=True,
    log_to_file=True,
    export_formats=["checkpoint", "model"],
    config=REINFORCE.Config(
        train_env_builder=lambda **config: ParallelBatchedEnv(
            lambda **kwargs: gym.make("CartPole-v1", **kwargs),
            config,
            num_workers=2,
        ),
        train_num_episodes_per_iter=5,
        eval_freq=10,
        eval_env_config={"render_mode": None},
        eval_num_episodes_per_iter=10,
        policy_network_model_builder=FCNet,
        policy_network_model_config={
            "torso_fc_configs": [{"out_features": 64, "bias": True}],
        },
        policy_network_optimizer_builder=Adam,
        policy_network_optimizer_config={"lr": 1e-1},
        discount=0.99,
        entropy_coeff=0.001,
        max_grad_l2_norm=0.5,
        seed=0,
        enable_amp=False,
        enable_reproducibility=True,
        log_sys_usage=True,
        suppress_warnings=True,
    ),
)

Open a terminal in the directory where you saved the configuration file and run (if you installed actorch in a virtual environment, you first need to activate it, e.g. conda activate actorch-env if you installed actorch using Conda):

pip install gymnasium[classic_control]  # Install dependencies for CartPole-v1
actorch run REINFORCE_CartPole-v1.py    # Run experiment

NOTE: training artifacts (e.g. checkpoints, metrics, etc.) are saved in nested subdirectories. This might cause issues on Windows, since the maximum path length is 260 characters. In that case, move the configuration file (or set local_dir) to an upper level directory (e.g. Desktop), shorten the configuration file name, and/or shorten the algorithm name (e.g. DistributedDataParallelREINFORCE.rename("DDPR")).

Wait for a few minutes until the training ends. The mean cumulative reward over the last 100 episodes should exceed 475, which means that the environment was successfully solved. You can now plot the performance metrics saved in the auto-generated TensorBoard (or CSV) log files using Plotly (or Matplotlib):

pip install actorch[vistool]  # Install dependencies for VisTool
cd experiments/REINFORCE_CartPole-v1/<auto-generated-experiment-name>
actorch vistool plotly tensorboard

You can find the generated plots in plots.

Congratulations, you ran your first experiment!

See examples for additional configuration file examples.

HINT: since a configuration file is a regular Python script, you can use all the features of the language (e.g. inheritance).



@ Citation

@misc{DellaLibera2022ACTorch,
  author = {Luca Della Libera},
  title = {{ACTorch}: a Deep Reinforcement Learning Framework for Fast Prototyping},
  year = {2022},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/lucadellalib/actorch}},
}

📧 Contact

luca.dellalib@gmail.com


Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 47

Native requirements
25 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
cloudpickle
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
cloudpickle (>=1.3.0)runtime
colorama
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
colorama (>=0.4.3)runtime
GPUtil
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
GPUtil (>=1.4.0)runtime
gymnasium
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
gymnasium (>=0.26.1)runtime
numpy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
numpy (>=1.19.5)runtime
psutil
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
psutil (>=5.7.0)runtime
PyYAML
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
PyYAML (>=5.3.1)runtime
ray
Environment
{
  "extras": "tune",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
ray[tune] (<2.*,>=1.13.0)runtime
scipy
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
scipy (>=1.4.1)runtime
tensorboard
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
tensorboard (>=2.6.0)runtime
torch
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
torch (>=1.12.0)runtime
pre-commit-hooks
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pre-commit-hooks (>=3.2.0) ; extra == 'all'runtime
flake8
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
flake8 (>=3.8.3) ; extra == 'all'runtime
PyYAML
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
PyYAML (>=5.3.1) ; extra == 'all'runtime
tqdm
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
tqdm (>=4.48.2) ; extra == 'all'runtime
twine
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
twine (>=3.3.0) ; extra == 'all'runtime
scipy
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
scipy (>=1.4.1) ; extra == 'all'runtime
flake8-bugbear
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
flake8-bugbear (>=20.1.4) ; extra == 'all'runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov (>=2.9.0) ; extra == 'all'runtime
numpy
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
numpy (>=1.19.5) ; extra == 'all'runtime
black
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
black (>=22.3.0) ; extra == 'all'runtime
tensorboard
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
tensorboard (>=2.6.0) ; extra == 'all'runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pytest (>=5.4.3) ; extra == 'all'runtime
mypy
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
mypy (>=0.812) ; extra == 'all'runtime
isort
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
isort (>=5.4.2) ; extra == 'all'runtime
cibuildwheel
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
cibuildwheel (>=2.3.1) ; extra == 'all'runtime
plotly
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
plotly (>=4.9.0) ; extra == 'all'runtime
matplotlib
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
matplotlib (>=3.2.1) ; extra == 'all'runtime
pre-commit
Environment
{
  "extras": "",
  "marker": "extra == 'all'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pre-commit (>=2.6.0) ; extra == 'all'runtime
black
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
black (>=22.3.0) ; extra == 'dev'runtime
cibuildwheel
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
cibuildwheel (>=2.3.1) ; extra == 'dev'runtime
flake8
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
flake8 (>=3.8.3) ; extra == 'dev'runtime
flake8-bugbear
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
flake8-bugbear (>=20.1.4) ; extra == 'dev'runtime
isort
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
isort (>=5.4.2) ; extra == 'dev'runtime
mypy
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
mypy (>=0.812) ; extra == 'dev'runtime
pre-commit
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pre-commit (>=2.6.0) ; extra == 'dev'runtime
pre-commit-hooks
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pre-commit-hooks (>=3.2.0) ; extra == 'dev'runtime
twine
Environment
{
  "extras": "",
  "marker": "extra == 'dev'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
twine (>=3.3.0) ; extra == 'dev'runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == 'test'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pytest (>=5.4.3) ; extra == 'test'runtime
pytest-cov
Environment
{
  "extras": "",
  "marker": "extra == 'test'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
pytest-cov (>=2.9.0) ; extra == 'test'runtime
matplotlib
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
matplotlib (>=3.2.1) ; extra == 'vistool'runtime
numpy
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
numpy (>=1.19.5) ; extra == 'vistool'runtime
plotly
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
plotly (>=4.9.0) ; extra == 'vistool'runtime
PyYAML
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
PyYAML (>=5.3.1) ; extra == 'vistool'runtime
scipy
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
scipy (>=1.4.1) ; extra == 'vistool'runtime
tensorboard
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
tensorboard (>=2.6.0) ; extra == 'vistool'runtime
tqdm
Environment
{
  "extras": "",
  "marker": "extra == 'vistool'",
  "requires_python": ">=3.6",
  "evaluation": "NOT_EVALUATED"
}
tqdm (>=4.48.2) ; extra == 'vistool'runtime

Distribution files

15 collected
actorch-0.0.5-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 284.16 KB · Python cp310

Source file
actorch-0.0.5-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 284.52 KB · Python cp310

Source file
actorch-0.0.5-cp36-cp36m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 283.68 KB · Python cp36

Source file
actorch-0.0.5-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 284.04 KB · Python cp36

Source file
actorch-0.0.5-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 283.7 KB · Python cp37

Source file
actorch-0.0.5-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 284.07 KB · Python cp37

Source file
actorch-0.0.5-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 284.09 KB · Python cp38

Source file
actorch-0.0.5-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 289.11 KB · Python cp38

Source file
actorch-0.0.5-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 284.05 KB · Python cp39

Source file
actorch-0.0.5-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 284.4 KB · Python cp39

Source file
actorch-0.0.5-pp37-pypy37_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 288.15 KB · Python pp37

Source file
actorch-0.0.5-pp37-pypy37_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 288.42 KB · Python pp37

Source file
actorch-0.0.5-pp38-pypy38_pp73-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl

bdist_wheel · 288.68 KB · Python pp38

Source file
actorch-0.0.5-pp38-pypy38_pp73-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl

bdist_wheel · 293.6 KB · Python pp38

Source file
actorch-0.0.5.tar.gz

sdist · 144.89 KB · Python source

Source file

Repository

PENDING
lucadellalib/actorch

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 18:39 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:833cd095b0081b87894131d181f895dc0bf7aec0bee27b82b435f34faaef6d31

Other collected versions

View all collected versions →