Shmuma/ptan
PyTorch Agent Net: reinforcement learning toolkit for pytorch
PTAN – PyTorch AgentNet
What it is – PTAN is a lightweight Python library that re‑implements the AgentNet framework for reinforcement‑learning (RL) agents using PyTorch. It provides helper classes (e.g., experience buffers, training loops) that were used in the Deep Reinforcement Learning Hands‑On book.
Key components
ExperienceSourceandExperienceSourceFirstLast– utilities for collecting trajectories from OpenAI‑Gym environments.- Integration with PyTorch Ignite for easy training loops.
- Optional TensorBoardX logging and OpenCV support for visualisation.
Supported environments – Any environment compatible with OpenAI Gym, including Atari games (gym[atari]).
Installation
# From PyPI (recommended)
pip install ptan
# Or directly from the repository
pip install git+https://github.com/Shmuma/ptan.git
# From source
python setup.py install
Dependencies (as listed in the README)
- PyTorch ≥ 1.1.0 (tested up to 1.7 on the
masterbranch) - PyTorch‑Ignite
- OpenAI Gym (plus the optional
atariextras) - opencv‑python
- tensorboardX (or
tensorboard-pytorchfor Anaconda users)
Versioning – The repository maintains separate branches for different major PyTorch versions:
master– latest tested PyTorch (currently 1.7)torch-1.3-book-ed2– code matching the second‑edition book, built for PyTorch 1.3torch-1.7– merged intomaster
Documentation – A Jupyter notebook introduction is provided at docs/intro.ipynb. For a deeper dive into the experience‑source utilities, see the issue comment linked in the README.
Typical workflow (high‑level, inferred from the README)
- Install the library and its dependencies.
- Create a Gym environment.
- Use
ExperienceSourceto generate batches of (state, action, reward, next_state) tuples. - Feed those batches to a PyTorch model inside an Ignite trainer.
- Log metrics with TensorBoardX.
Who it’s for – Developers and researchers who want a ready‑made scaffolding for building and training RL agents in PyTorch without writing boiler‑plate code.
Related
- Project
- Project
- Project
- Project