For this project, we work with the Crawler environment. A creature with 4 arms and 4 forearms.
Agent Reward Function (independent):
- +0.03 times body velocity in the goal direction.
- +0.01 times body direction alignment with goal direction.
Observation space size (per agent): 129
Action space size (per agent): 20
You need at least the following three packages:
-
deep-reinforcement-learning (DRLND)
The instructions to set up the DRLND repository can be found here. This repository contains material related to Udacity's Deep Reinforcement Learning Nanodegree program. -
ml-agents (ML-Agents Toolkit) To configure the ML-Agents Toolkit for Windows you need to complete the following steps:
2.1 Creating a new Conda environment:
conda create -n ml-agents python=3.62.2 Activating ml-agents by the following command:
activate ml-agents2.3 Latest versions of TensorFlow won't work, so you will need to make sure that you install version 1.7.1:
pip install tensorflow==1.7.1For details on installing the ML-Agents Toolkit, see the instructions here.
-
Unity environment Crawler
For this project, we not need to install Unity because the environment already built. For 20 agents, the environment
can be downloaded as follows:Windows (64-bit), click here
Windows (32-bit), click hereDownload this environment zip into p2_continuous-control/ folder, and unzip the file.
Standard policy gradient methods perform one gradient update per data sample.
In the original paper it was proposed a novel objective function that enables multiple epochs.
This is the loss function L_t(\theta), which is (approximately) maximized each iteration:
Parameters c1, c2 and epoch are essential hyperparameters in the PPO algorithm. In this agent, c1 = -0.5, c2 = 0.01.
policy_loss = -torch.min(obj, obj_clipped) - 0.01 * entropy_loss
value_loss = 0.5 * (sampled_returns - values).pow(2)
loss = policy_loss + value_loss
The update is performed in the function agent.step().
The environment was solved
-
in 676 episodes with score 500, see Crawler_PPO_676epis_500score.ipynb
-
in 550 episodes with score 650, see Crawler_PPO_550epis_650score.ipynb
-
in 532 episodes with score 800, see Crawler_PPO_532epis_800score.ipynb
-
in 678 episodes with score 1200, see Crawler_PPO_678epis_1200score.ipynb
For both neural networks, the actor and the critic, we save the trained weights into checkpoint files
with the extension pth. For all cases, the corresponding files are saved into the directory checkpoints.
Using notebook WatchAgent.ipynb we can load the trained weights and replay them.
- Pong, 8 parallel agents
- CarRacing, Single agent, Learning from pixels
- BipedalWalker, 16 parallel agents
Most of the code is based on Udacity's PPO code.





