Upload trained agent
Browse files- .gitattributes +2 -0
- README.md +82 -0
- config.json +37 -0
- load_example.py +11 -0
- model.safetensors +3 -0
- replay.mp4 +3 -0
- results.json +8 -0
- results.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
replay.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
results.png filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: pytorch
|
| 3 |
+
tags:
|
| 4 |
+
- reinforcement-learning
|
| 5 |
+
- atari
|
| 6 |
+
- phoenix
|
| 7 |
+
- ppo
|
| 8 |
+
- custom-implementation
|
| 9 |
+
model-index:
|
| 10 |
+
- name: ppo-ALE/Phoenix-v5
|
| 11 |
+
results:
|
| 12 |
+
- task:
|
| 13 |
+
type: reinforcement-learning
|
| 14 |
+
name: reinforcement-learning
|
| 15 |
+
dataset:
|
| 16 |
+
name: ALE/Phoenix-v5
|
| 17 |
+
type: ALE/Phoenix-v5
|
| 18 |
+
metrics:
|
| 19 |
+
- type: mean_reward
|
| 20 |
+
value: 4687.19 +/- 974.80
|
| 21 |
+
name: mean_reward
|
| 22 |
+
---
|
| 23 |
+
# PPO agent playing ALE/Phoenix-v5
|
| 24 |
+
|
| 25 |
+
A from-scratch PyTorch implementation (PPO) trained for 2,000,000 agent steps (8,000,000 frames).
|
| 26 |
+
|
| 27 |
+

|
| 28 |
+
<video src="replay.mp4" controls></video>
|
| 29 |
+
|
| 30 |
+
## Evaluation
|
| 31 |
+
| metric | value |
|
| 32 |
+
|---|---|
|
| 33 |
+
| mean score (stochastic policy) | 4687.2 ± 974.8 over 32 episodes |
|
| 34 |
+
| mean score (greedy policy) | 4578.8 |
|
| 35 |
+
| environment | `ALE/Phoenix-v5` (sticky actions 0.25, sign-clipped rewards for training, raw score for evaluation) |
|
| 36 |
+
|
| 37 |
+
## Model
|
| 38 |
+
* Input: 4 stacked 84x84 grayscale frames. Network: `impala` CNN trunk (15 conv layers) + 2-layer actor and critic heads; 1,223,129 parameters.
|
| 39 |
+
* Actions: 8 discrete (NOOP, FIRE, RIGHT, LEFT, DOWN, RIGHTFIRE, LEFTFIRE, DOWNFIRE).
|
| 40 |
+
|
| 41 |
+
## Hyper-parameters
|
| 42 |
+
```json
|
| 43 |
+
{
|
| 44 |
+
"algo": "ppo",
|
| 45 |
+
"game": "phoenix",
|
| 46 |
+
"seed": 0,
|
| 47 |
+
"tag": "",
|
| 48 |
+
"total_steps": 2000000,
|
| 49 |
+
"num_envs": 16,
|
| 50 |
+
"sticky": 0.25,
|
| 51 |
+
"noop_max": 30,
|
| 52 |
+
"max_frames": 108000,
|
| 53 |
+
"clip_reward": true,
|
| 54 |
+
"arch": "impala",
|
| 55 |
+
"hidden": 256,
|
| 56 |
+
"lr": 0.00025,
|
| 57 |
+
"lr_anneal": true,
|
| 58 |
+
"adam_eps": 1e-05,
|
| 59 |
+
"max_grad_norm": 0.5,
|
| 60 |
+
"gamma": 0.99,
|
| 61 |
+
"gae_lambda": 0.95,
|
| 62 |
+
"n_steps": 128,
|
| 63 |
+
"ent_coef": 0.01,
|
| 64 |
+
"vf_coef": 0.5,
|
| 65 |
+
"norm_adv": true,
|
| 66 |
+
"clip_eps": 0.1,
|
| 67 |
+
"ppo_epochs": 4,
|
| 68 |
+
"minibatches": 4,
|
| 69 |
+
"clip_vloss": false,
|
| 70 |
+
"target_kl": null,
|
| 71 |
+
"baseline": "batch",
|
| 72 |
+
"max_episode_steps": 4000,
|
| 73 |
+
"chunk": 512,
|
| 74 |
+
"eval_every": 300000,
|
| 75 |
+
"eval_episodes": 8,
|
| 76 |
+
"ckpt_every": 500000,
|
| 77 |
+
"print_every_s": 20.0,
|
| 78 |
+
"device": "auto"
|
| 79 |
+
}
|
| 80 |
+
```
|
| 81 |
+
|
| 82 |
+
See `load_example.py` for loading. Weights are stored as `model.safetensors`.
|
config.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"algo": "ppo",
|
| 3 |
+
"game": "phoenix",
|
| 4 |
+
"seed": 0,
|
| 5 |
+
"tag": "",
|
| 6 |
+
"total_steps": 2000000,
|
| 7 |
+
"num_envs": 16,
|
| 8 |
+
"sticky": 0.25,
|
| 9 |
+
"noop_max": 30,
|
| 10 |
+
"max_frames": 108000,
|
| 11 |
+
"clip_reward": true,
|
| 12 |
+
"arch": "impala",
|
| 13 |
+
"hidden": 256,
|
| 14 |
+
"lr": 0.00025,
|
| 15 |
+
"lr_anneal": true,
|
| 16 |
+
"adam_eps": 1e-05,
|
| 17 |
+
"max_grad_norm": 0.5,
|
| 18 |
+
"gamma": 0.99,
|
| 19 |
+
"gae_lambda": 0.95,
|
| 20 |
+
"n_steps": 128,
|
| 21 |
+
"ent_coef": 0.01,
|
| 22 |
+
"vf_coef": 0.5,
|
| 23 |
+
"norm_adv": true,
|
| 24 |
+
"clip_eps": 0.1,
|
| 25 |
+
"ppo_epochs": 4,
|
| 26 |
+
"minibatches": 4,
|
| 27 |
+
"clip_vloss": false,
|
| 28 |
+
"target_kl": null,
|
| 29 |
+
"baseline": "batch",
|
| 30 |
+
"max_episode_steps": 4000,
|
| 31 |
+
"chunk": 512,
|
| 32 |
+
"eval_every": 300000,
|
| 33 |
+
"eval_episodes": 8,
|
| 34 |
+
"ckpt_every": 500000,
|
| 35 |
+
"print_every_s": 20.0,
|
| 36 |
+
"device": "auto"
|
| 37 |
+
}
|
load_example.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# pip install ale-py gymnasium torch safetensors huggingface_hub
|
| 2 |
+
# You also need the phoenix_rl package that trained this model (it defines the network class).
|
| 3 |
+
import json, torch
|
| 4 |
+
from huggingface_hub import hf_hub_download
|
| 5 |
+
from safetensors.torch import load_file
|
| 6 |
+
from phoenix_rl.config import Cfg
|
| 7 |
+
from phoenix_rl.nets import ActorCritic
|
| 8 |
+
repo = "<your-username>/ppo-phoenix"
|
| 9 |
+
cfg = Cfg(**json.load(open(hf_hub_download(repo, "config.json"))))
|
| 10 |
+
net = ActorCritic(8, cfg.arch, cfg.hidden); net.load_state_dict(load_file(hf_hub_download(repo, "model.safetensors"))); net.eval()
|
| 11 |
+
# obs: uint8 tensor (B, 4, 84, 84); logits, value = net(obs); action = logits.argmax(-1)
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:40d3f6261058c198a87c25778f4acc915918c6ad2cd185b00e44820d98afb07c
|
| 3 |
+
size 4896076
|
replay.mp4
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a6e8dee4a356f73b656724b75f5ae043c5fb17d4ac6c3e14e3f8b2418d2c28e
|
| 3 |
+
size 768864
|
results.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"mean": 4687.1875,
|
| 3 |
+
"std": 974.8020131512603,
|
| 4 |
+
"n_episodes": 32,
|
| 5 |
+
"greedy_mean": 4578.75,
|
| 6 |
+
"seed": 0,
|
| 7 |
+
"train_steps": 2000896
|
| 8 |
+
}
|
results.png
ADDED
|
Git LFS Details
|