[Project Showcase] ML-Agents in Python through TorchRL
| |
Hi everyone, I wanted to share a project I’ve been working on: ML-Agents with TorchRL. This is my first project I’ve tried to make presentable so I would really appreciate feedback on it. https://reddit.com/link/1q15ykj/video/u8zvsyfi2rag1/player SummaryTrain Unity environments using TorchRL. This bypasses the default mlagents-learn CLI with torchrl templates that are powerful, modular, debuggable, and easy to customize. Motivation
TorchRL AlgorithmsThe nice thing about torchrl is that once you have the environments in the right format you can use their powerful modular parts to construct an algorithm. For example, one really convenient component for PPO is the MultiSyncDataCollector which uses multiprocessing to collect data in parallel:
This is then combined with many other modular parts like replay buffers, value estimators (GAE), and loss modules. This makes setting up an algorithm both very straightforward and highly customizable. Here’s an example of PPO. To introduce a new algorithm or variant just create another training template. Python WorkflowWorking in python is also really nice. For example I set up a simple experiment runner using hydra which takes in a config like configs/crawler_ppo.yaml. Configs look something like this:
It’s also integrated with a lot of common utility like tensorboard and huggingface (logs/checkpoints/models). Which makes it really nice to work with at a user level even if you don’t care about customizability. DiscussionI think having this torchrl trainer option can make unity more accessible for research or just be an overall direction to expand the trainer stack with more features. I’m going to continue working on this project and I would really appreciate discussion, feedback (I’m new to making these sort of things), and contributions. submitted by /u/TaskBeneficial380 |