Reinforcement Learning
ml-agents
TensorBoard
ONNX
deep-reinforcement-learning
deep-rl-course
Pyramids
ML-Agents-Pyramids
Eval Results (legacy)
Instructions to use rabitrabi/ppo-Pyramids with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ml-agents
How to use rabitrabi/ppo-Pyramids with ml-agents:
mlagents-load-from-hf --repo-id="rabitrabi/ppo-Pyramids" --local-dir="./downloads"
- Notebooks
- Google Colab
- Kaggle
Publish trained Pyramids policy and 32-episode evaluation
Browse files- Pyramids-initial.yaml +32 -0
- Pyramids.onnx +1 -1
- Pyramids.yaml +2 -1
- Pyramids/Pyramids-130976.onnx +3 -0
- Pyramids/Pyramids-130976.pt +3 -0
- Pyramids/Pyramids-327634.onnx +3 -0
- Pyramids/Pyramids-327634.pt +3 -0
- Pyramids/Pyramids-393172.onnx +3 -0
- Pyramids/Pyramids-393172.pt +3 -0
- Pyramids/Pyramids-458717.onnx +3 -0
- Pyramids/Pyramids-458717.pt +3 -0
- Pyramids/Pyramids-524226.onnx +3 -0
- Pyramids/Pyramids-524226.pt +3 -0
- Pyramids/Pyramids-524354.onnx +3 -0
- Pyramids/Pyramids-524354.pt +3 -0
- Pyramids/checkpoint.pt +1 -1
- Pyramids/events.out.tfevents.1796028869.rabia-LOQ-15IAX9E.3435329.0 +3 -0
- README.md +4 -3
- config.json +5 -5
- configuration.yaml +5 -5
- evaluate.py +17 -4
- evaluation-deterministic.json +43 -0
- evaluation.json +2 -1
- run_logs/training_status.json +43 -7
- validation.json +181 -0
Pyramids-initial.yaml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
behaviors:
|
| 2 |
+
Pyramids:
|
| 3 |
+
trainer_type: ppo
|
| 4 |
+
hyperparameters:
|
| 5 |
+
batch_size: 128
|
| 6 |
+
buffer_size: 2048
|
| 7 |
+
learning_rate: 0.0003
|
| 8 |
+
beta: 0.01
|
| 9 |
+
epsilon: 0.2
|
| 10 |
+
lambd: 0.95
|
| 11 |
+
num_epoch: 3
|
| 12 |
+
learning_rate_schedule: linear
|
| 13 |
+
network_settings:
|
| 14 |
+
normalize: false
|
| 15 |
+
hidden_units: 128
|
| 16 |
+
num_layers: 2
|
| 17 |
+
vis_encode_type: simple
|
| 18 |
+
reward_signals:
|
| 19 |
+
extrinsic:
|
| 20 |
+
gamma: 0.99
|
| 21 |
+
strength: 1.0
|
| 22 |
+
rnd:
|
| 23 |
+
gamma: 0.99
|
| 24 |
+
strength: 0.01
|
| 25 |
+
network_settings:
|
| 26 |
+
hidden_units: 64
|
| 27 |
+
num_layers: 3
|
| 28 |
+
learning_rate: 0.0001
|
| 29 |
+
keep_checkpoints: 5
|
| 30 |
+
max_steps: 65536
|
| 31 |
+
time_horizon: 128
|
| 32 |
+
summary_freq: 4096
|
Pyramids.onnx
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 162254
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:822127f8de9d21df40c3997370802cb895dcb17697a3b329fbb9930bd5bce9aa
|
| 3 |
size 162254
|
Pyramids.yaml
CHANGED
|
@@ -27,6 +27,7 @@ behaviors:
|
|
| 27 |
num_layers: 3
|
| 28 |
learning_rate: 0.0001
|
| 29 |
keep_checkpoints: 5
|
| 30 |
-
max_steps:
|
|
|
|
| 31 |
time_horizon: 128
|
| 32 |
summary_freq: 4096
|
|
|
|
| 27 |
num_layers: 3
|
| 28 |
learning_rate: 0.0001
|
| 29 |
keep_checkpoints: 5
|
| 30 |
+
max_steps: 524288
|
| 31 |
+
checkpoint_interval: 65536
|
| 32 |
time_horizon: 128
|
| 33 |
summary_freq: 4096
|
Pyramids/Pyramids-130976.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:822127f8de9d21df40c3997370802cb895dcb17697a3b329fbb9930bd5bce9aa
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-130976.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e4555c7ab1059a5cb426200efb378f2e85bc7bf1f7312233862e8d0c835724a3
|
| 3 |
+
size 1120941
|
Pyramids/Pyramids-327634.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:837a00cd8bbb7c0f16fd55e119266db5be78acc7832fbac7f97b5b52fc8714b6
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-327634.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b08196e780b72548fa8b1f07b553edeabf350426c4dae0a14ac42172912d182b
|
| 3 |
+
size 1120941
|
Pyramids/Pyramids-393172.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:2be4fe2039e18f53fff3ee945e83e48d9241065d31db6e6e6b768dc88e5ecc38
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-393172.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:db56af8b75feadc9958c2a6d2f1bd13b6177ed6ad14766a8fd9fef5ed1730064
|
| 3 |
+
size 1120941
|
Pyramids/Pyramids-458717.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bd93dcfcb021d3c56cc8d0a5dd8af650e23f1222713fbdf46697afff931fd5e8
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-458717.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:098437b9f68664c07b74b8d7819053de06ebf7d70d7050fe40a1618b8cd2726d
|
| 3 |
+
size 1120941
|
Pyramids/Pyramids-524226.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19f5a602edbd479419fc8235d077cabc3a7ff7c139298582784923637fdb00a4
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-524226.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:45aa74d49c9c38725980901d934715b81b626ee87b845bb195a0a9596e962adc
|
| 3 |
+
size 1120941
|
Pyramids/Pyramids-524354.onnx
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:19f5a602edbd479419fc8235d077cabc3a7ff7c139298582784923637fdb00a4
|
| 3 |
+
size 162254
|
Pyramids/Pyramids-524354.pt
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:776f0907ad5729123aebe22a30b0f404562c4c103bf0b4b37a80fb224bc7f60a
|
| 3 |
+
size 1120941
|
Pyramids/checkpoint.pt
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 1120546
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:514f2167f65f7d308d5283cb7d8c70f0893d5375fdee0b4bb73644e413a5bf56
|
| 3 |
size 1120546
|
Pyramids/events.out.tfevents.1796028869.rabia-LOQ-15IAX9E.3435329.0
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d0c3efe2d8a9e30b700fc630e335c17bfb0205563771104f5620ae14ffc62b8e
|
| 3 |
+
size 436636
|
README.md
CHANGED
|
@@ -25,17 +25,18 @@ model-index:
|
|
| 25 |
|
| 26 |
# PPO on Pyramids
|
| 27 |
|
| 28 |
-
This Unity ML-Agents 1.1.0 policy was trained from scratch on CPU for the Hugging Face Deep Reinforcement Learning Course with a
|
| 29 |
|
| 30 |
## Evaluation
|
| 31 |
|
| 32 |
-
The exported ONNX policy sampled actions in a fresh Unity session with seed 2026. Across the first 32 completed episodes, the mean return was **-1.000** and the population standard deviation was **0.000**. Training used the random network distillation curiosity bonus. Evaluation measures the original environment rewards. Individual returns are in `evaluation.json`.
|
| 33 |
|
| 34 |
## Reproduce
|
| 35 |
|
| 36 |
Use Python 3.10.12, Unity ML-Agents 1.1.0, CPU PyTorch 2.2.2, ONNX 1.15.0 and ONNX Runtime 1.18.1. Download the Linux simulator linked in [course unit 5](https://huggingface.co/learn/deep-rl-course/en/unit5/hands-on).
|
| 37 |
|
| 38 |
```bash
|
| 39 |
-
mlagents-learn Pyramids.yaml --env=/path/to/Pyramids --run-id=Pyramids --no-graphics --seed=42 --time-scale=64 --torch-device=cpu
|
|
|
|
| 40 |
python evaluate.py Pyramids /path/to/Pyramids 6360 --seed=2026 --episodes=32
|
| 41 |
```
|
|
|
|
| 25 |
|
| 26 |
# PPO on Pyramids
|
| 27 |
|
| 28 |
+
This Unity ML-Agents 1.1.0 policy was trained from scratch on CPU for the Hugging Face Deep Reinforcement Learning Course with a 524,288-step budget. The first 65,841 steps used seed 42 and the resumed run used seed 43. Four checkpoints were compared by sampled-policy mean return at validation seed 2025. The top-level ONNX file is the selected 130,976-step checkpoint.
|
| 29 |
|
| 30 |
## Evaluation
|
| 31 |
|
| 32 |
+
The exported ONNX policy sampled actions in a fresh Unity session with seed 2026. Across the first 32 completed episodes, the mean return was **-1.000** and the population standard deviation was **0.000**. Training used the random network distillation curiosity bonus. Evaluation measures the original environment rewards. The sampled policy collected gold in 0 of 32 episodes. The deterministic policy collected gold in 0 of 32 episodes and scored -1.000 ± 0.000. Individual returns are in `evaluation.json`.
|
| 33 |
|
| 34 |
## Reproduce
|
| 35 |
|
| 36 |
Use Python 3.10.12, Unity ML-Agents 1.1.0, CPU PyTorch 2.2.2, ONNX 1.15.0 and ONNX Runtime 1.18.1. Download the Linux simulator linked in [course unit 5](https://huggingface.co/learn/deep-rl-course/en/unit5/hands-on).
|
| 37 |
|
| 38 |
```bash
|
| 39 |
+
mlagents-learn Pyramids-initial.yaml --env=/path/to/Pyramids --run-id=Pyramids --no-graphics --seed=42 --time-scale=64 --torch-device=cpu
|
| 40 |
+
mlagents-learn Pyramids.yaml --env=/path/to/Pyramids --run-id=Pyramids --no-graphics --resume --seed=43 --time-scale=64 --torch-device=cpu
|
| 41 |
python evaluate.py Pyramids /path/to/Pyramids 6360 --seed=2026 --episodes=32
|
| 42 |
```
|
config.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
| 16 |
"beta_schedule": "linear",
|
| 17 |
"epsilon_schedule": "linear"
|
| 18 |
},
|
| 19 |
-
"checkpoint_interval":
|
| 20 |
"network_settings": {
|
| 21 |
"normalize": false,
|
| 22 |
"hidden_units": 128,
|
|
@@ -59,7 +59,7 @@
|
|
| 59 |
"init_path": null,
|
| 60 |
"keep_checkpoints": 5,
|
| 61 |
"even_checkpoints": false,
|
| 62 |
-
"max_steps":
|
| 63 |
"time_horizon": 128,
|
| 64 |
"summary_freq": 4096,
|
| 65 |
"threaded": false,
|
|
@@ -71,13 +71,13 @@
|
|
| 71 |
"env_path": "envs/Pyramids/Pyramids",
|
| 72 |
"env_args": [
|
| 73 |
"-job-worker-count",
|
| 74 |
-
"
|
| 75 |
],
|
| 76 |
"base_port": 6330,
|
| 77 |
"num_envs": 1,
|
| 78 |
"num_areas": 1,
|
| 79 |
"timeout_wait": 60,
|
| 80 |
-
"seed":
|
| 81 |
"max_lifetime_restarts": 10,
|
| 82 |
"restarts_rate_limit_n": 1,
|
| 83 |
"restarts_rate_limit_period_s": 60
|
|
@@ -97,7 +97,7 @@
|
|
| 97 |
"run_id": "Pyramids",
|
| 98 |
"initialize_from": null,
|
| 99 |
"load_model": false,
|
| 100 |
-
"resume":
|
| 101 |
"force": false,
|
| 102 |
"train_model": false,
|
| 103 |
"inference": false,
|
|
|
|
| 16 |
"beta_schedule": "linear",
|
| 17 |
"epsilon_schedule": "linear"
|
| 18 |
},
|
| 19 |
+
"checkpoint_interval": 65536,
|
| 20 |
"network_settings": {
|
| 21 |
"normalize": false,
|
| 22 |
"hidden_units": 128,
|
|
|
|
| 59 |
"init_path": null,
|
| 60 |
"keep_checkpoints": 5,
|
| 61 |
"even_checkpoints": false,
|
| 62 |
+
"max_steps": 524288,
|
| 63 |
"time_horizon": 128,
|
| 64 |
"summary_freq": 4096,
|
| 65 |
"threaded": false,
|
|
|
|
| 71 |
"env_path": "envs/Pyramids/Pyramids",
|
| 72 |
"env_args": [
|
| 73 |
"-job-worker-count",
|
| 74 |
+
"2"
|
| 75 |
],
|
| 76 |
"base_port": 6330,
|
| 77 |
"num_envs": 1,
|
| 78 |
"num_areas": 1,
|
| 79 |
"timeout_wait": 60,
|
| 80 |
+
"seed": 43,
|
| 81 |
"max_lifetime_restarts": 10,
|
| 82 |
"restarts_rate_limit_n": 1,
|
| 83 |
"restarts_rate_limit_period_s": 60
|
|
|
|
| 97 |
"run_id": "Pyramids",
|
| 98 |
"initialize_from": null,
|
| 99 |
"load_model": false,
|
| 100 |
+
"resume": true,
|
| 101 |
"force": false,
|
| 102 |
"train_model": false,
|
| 103 |
"inference": false,
|
configuration.yaml
CHANGED
|
@@ -14,7 +14,7 @@ behaviors:
|
|
| 14 |
learning_rate_schedule: linear
|
| 15 |
beta_schedule: linear
|
| 16 |
epsilon_schedule: linear
|
| 17 |
-
checkpoint_interval:
|
| 18 |
network_settings:
|
| 19 |
normalize: false
|
| 20 |
hidden_units: 128
|
|
@@ -51,7 +51,7 @@ behaviors:
|
|
| 51 |
init_path: null
|
| 52 |
keep_checkpoints: 5
|
| 53 |
even_checkpoints: false
|
| 54 |
-
max_steps:
|
| 55 |
time_horizon: 128
|
| 56 |
summary_freq: 4096
|
| 57 |
threaded: false
|
|
@@ -61,12 +61,12 @@ env_settings:
|
|
| 61 |
env_path: envs/Pyramids/Pyramids
|
| 62 |
env_args:
|
| 63 |
- -job-worker-count
|
| 64 |
-
- '
|
| 65 |
base_port: 6330
|
| 66 |
num_envs: 1
|
| 67 |
num_areas: 1
|
| 68 |
timeout_wait: 60
|
| 69 |
-
seed:
|
| 70 |
max_lifetime_restarts: 10
|
| 71 |
restarts_rate_limit_n: 1
|
| 72 |
restarts_rate_limit_period_s: 60
|
|
@@ -84,7 +84,7 @@ checkpoint_settings:
|
|
| 84 |
run_id: Pyramids
|
| 85 |
initialize_from: null
|
| 86 |
load_model: false
|
| 87 |
-
resume:
|
| 88 |
force: false
|
| 89 |
train_model: false
|
| 90 |
inference: false
|
|
|
|
| 14 |
learning_rate_schedule: linear
|
| 15 |
beta_schedule: linear
|
| 16 |
epsilon_schedule: linear
|
| 17 |
+
checkpoint_interval: 65536
|
| 18 |
network_settings:
|
| 19 |
normalize: false
|
| 20 |
hidden_units: 128
|
|
|
|
| 51 |
init_path: null
|
| 52 |
keep_checkpoints: 5
|
| 53 |
even_checkpoints: false
|
| 54 |
+
max_steps: 524288
|
| 55 |
time_horizon: 128
|
| 56 |
summary_freq: 4096
|
| 57 |
threaded: false
|
|
|
|
| 61 |
env_path: envs/Pyramids/Pyramids
|
| 62 |
env_args:
|
| 63 |
- -job-worker-count
|
| 64 |
+
- '2'
|
| 65 |
base_port: 6330
|
| 66 |
num_envs: 1
|
| 67 |
num_areas: 1
|
| 68 |
timeout_wait: 60
|
| 69 |
+
seed: 43
|
| 70 |
max_lifetime_restarts: 10
|
| 71 |
restarts_rate_limit_n: 1
|
| 72 |
restarts_rate_limit_period_s: 60
|
|
|
|
| 84 |
run_id: Pyramids
|
| 85 |
initialize_from: null
|
| 86 |
load_model: false
|
| 87 |
+
resume: true
|
| 88 |
force: false
|
| 89 |
train_model: false
|
| 90 |
inference: false
|
evaluate.py
CHANGED
|
@@ -11,7 +11,7 @@ from mlagents_envs.environment import UnityEnvironment
|
|
| 11 |
from mlagents_envs.side_channel.engine_configuration_channel import EngineConfigurationChannel
|
| 12 |
|
| 13 |
|
| 14 |
-
def policy_actions(session, decisions, spec):
|
| 15 |
batch = len(decisions)
|
| 16 |
inputs = {}
|
| 17 |
for inp in session.get_inputs():
|
|
@@ -30,6 +30,8 @@ def policy_actions(session, decisions, spec):
|
|
| 30 |
("continuous_actions", actions.add_continuous),
|
| 31 |
("discrete_actions", actions.add_discrete),
|
| 32 |
):
|
|
|
|
|
|
|
| 33 |
if name in {out.name for out in session.get_outputs()}:
|
| 34 |
setter(session.run([name], inputs)[0])
|
| 35 |
return actions
|
|
@@ -44,11 +46,14 @@ def evaluate(args):
|
|
| 44 |
opts.intra_op_num_threads = 1
|
| 45 |
opts.inter_op_num_threads = 1
|
| 46 |
model_path = Path("results") / args.name / (args.name + ".onnx")
|
|
|
|
|
|
|
| 47 |
if not model_path.exists():
|
| 48 |
model_path = Path(__file__).resolve().parent / (args.name + ".onnx")
|
| 49 |
session = ort.InferenceSession(str(model_path), opts, providers=["CPUExecutionProvider"])
|
| 50 |
totals = defaultdict(float)
|
| 51 |
returns = []
|
|
|
|
| 52 |
soccer = args.name == "SoccerTwos"
|
| 53 |
env = UnityEnvironment(file_name=args.env, seed=args.seed, base_port=args.port,
|
| 54 |
no_graphics=True, side_channels=[engine],
|
|
@@ -73,8 +78,10 @@ def evaluate(args):
|
|
| 73 |
totals[uid] += float(reward)
|
| 74 |
if ended:
|
| 75 |
returns.append(totals.pop(uid))
|
|
|
|
|
|
|
| 76 |
if len(decisions):
|
| 77 |
-
env.set_actions(behavior, policy_actions(session, decisions, spec.action_spec))
|
| 78 |
if len(returns) >= args.episodes:
|
| 79 |
break
|
| 80 |
env.step()
|
|
@@ -84,13 +91,16 @@ def evaluate(args):
|
|
| 84 |
env.close()
|
| 85 |
returns = returns[:args.episodes]
|
| 86 |
report = dict(environment=args.name, seed=args.seed, episodes=len(returns),
|
| 87 |
-
stochastic_policy=
|
| 88 |
std=float(np.std(returns)), returns=returns)
|
|
|
|
|
|
|
| 89 |
if soccer:
|
| 90 |
report.update(opponent="uniform random actions", evaluated_team=0,
|
| 91 |
metric="per-match shared team return")
|
| 92 |
print(json.dumps(report))
|
| 93 |
-
(model_path.parent / "evaluation.json"
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
if __name__ == "__main__":
|
|
@@ -98,6 +108,9 @@ if __name__ == "__main__":
|
|
| 98 |
parser.add_argument("name")
|
| 99 |
parser.add_argument("env")
|
| 100 |
parser.add_argument("port", type=int)
|
|
|
|
|
|
|
|
|
|
| 101 |
parser.add_argument("--episodes", type=int, default=32)
|
| 102 |
parser.add_argument("--seed", type=int, default=2026)
|
| 103 |
evaluate(parser.parse_args())
|
|
|
|
| 11 |
from mlagents_envs.side_channel.engine_configuration_channel import EngineConfigurationChannel
|
| 12 |
|
| 13 |
|
| 14 |
+
def policy_actions(session, decisions, spec, deterministic=False):
|
| 15 |
batch = len(decisions)
|
| 16 |
inputs = {}
|
| 17 |
for inp in session.get_inputs():
|
|
|
|
| 30 |
("continuous_actions", actions.add_continuous),
|
| 31 |
("discrete_actions", actions.add_discrete),
|
| 32 |
):
|
| 33 |
+
if deterministic:
|
| 34 |
+
name = "deterministic_" + name
|
| 35 |
if name in {out.name for out in session.get_outputs()}:
|
| 36 |
setter(session.run([name], inputs)[0])
|
| 37 |
return actions
|
|
|
|
| 46 |
opts.intra_op_num_threads = 1
|
| 47 |
opts.inter_op_num_threads = 1
|
| 48 |
model_path = Path("results") / args.name / (args.name + ".onnx")
|
| 49 |
+
if args.model_path:
|
| 50 |
+
model_path = Path(args.model_path)
|
| 51 |
if not model_path.exists():
|
| 52 |
model_path = Path(__file__).resolve().parent / (args.name + ".onnx")
|
| 53 |
session = ort.InferenceSession(str(model_path), opts, providers=["CPUExecutionProvider"])
|
| 54 |
totals = defaultdict(float)
|
| 55 |
returns = []
|
| 56 |
+
gold = []
|
| 57 |
soccer = args.name == "SoccerTwos"
|
| 58 |
env = UnityEnvironment(file_name=args.env, seed=args.seed, base_port=args.port,
|
| 59 |
no_graphics=True, side_channels=[engine],
|
|
|
|
| 78 |
totals[uid] += float(reward)
|
| 79 |
if ended:
|
| 80 |
returns.append(totals.pop(uid))
|
| 81 |
+
if args.name == 'Pyramids':
|
| 82 |
+
gold.append(bool(not steps.interrupted[row] and reward > 0))
|
| 83 |
if len(decisions):
|
| 84 |
+
env.set_actions(behavior, policy_actions(session, decisions, spec.action_spec, args.deterministic))
|
| 85 |
if len(returns) >= args.episodes:
|
| 86 |
break
|
| 87 |
env.step()
|
|
|
|
| 91 |
env.close()
|
| 92 |
returns = returns[:args.episodes]
|
| 93 |
report = dict(environment=args.name, seed=args.seed, episodes=len(returns),
|
| 94 |
+
stochastic_policy=not args.deterministic, mean=float(np.mean(returns)),
|
| 95 |
std=float(np.std(returns)), returns=returns)
|
| 96 |
+
if gold:
|
| 97 |
+
report['gold_pickups'] = sum(gold[:args.episodes])
|
| 98 |
if soccer:
|
| 99 |
report.update(opponent="uniform random actions", evaluated_team=0,
|
| 100 |
metric="per-match shared team return")
|
| 101 |
print(json.dumps(report))
|
| 102 |
+
output_path = Path(args.output) if args.output else model_path.parent / "evaluation.json"
|
| 103 |
+
output_path.write_text(json.dumps(report, indent=2) + "\n")
|
| 104 |
|
| 105 |
|
| 106 |
if __name__ == "__main__":
|
|
|
|
| 108 |
parser.add_argument("name")
|
| 109 |
parser.add_argument("env")
|
| 110 |
parser.add_argument("port", type=int)
|
| 111 |
+
parser.add_argument("--model-path")
|
| 112 |
+
parser.add_argument("--output")
|
| 113 |
+
parser.add_argument("--deterministic", action="store_true")
|
| 114 |
parser.add_argument("--episodes", type=int, default=32)
|
| 115 |
parser.add_argument("--seed", type=int, default=2026)
|
| 116 |
evaluate(parser.parse_args())
|
evaluation-deterministic.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"environment": "Pyramids",
|
| 3 |
+
"seed": 2026,
|
| 4 |
+
"episodes": 32,
|
| 5 |
+
"stochastic_policy": false,
|
| 6 |
+
"mean": -0.9999999310821295,
|
| 7 |
+
"std": 0.0,
|
| 8 |
+
"returns": [
|
| 9 |
+
-0.9999999310821295,
|
| 10 |
+
-0.9999999310821295,
|
| 11 |
+
-0.9999999310821295,
|
| 12 |
+
-0.9999999310821295,
|
| 13 |
+
-0.9999999310821295,
|
| 14 |
+
-0.9999999310821295,
|
| 15 |
+
-0.9999999310821295,
|
| 16 |
+
-0.9999999310821295,
|
| 17 |
+
-0.9999999310821295,
|
| 18 |
+
-0.9999999310821295,
|
| 19 |
+
-0.9999999310821295,
|
| 20 |
+
-0.9999999310821295,
|
| 21 |
+
-0.9999999310821295,
|
| 22 |
+
-0.9999999310821295,
|
| 23 |
+
-0.9999999310821295,
|
| 24 |
+
-0.9999999310821295,
|
| 25 |
+
-0.9999999310821295,
|
| 26 |
+
-0.9999999310821295,
|
| 27 |
+
-0.9999999310821295,
|
| 28 |
+
-0.9999999310821295,
|
| 29 |
+
-0.9999999310821295,
|
| 30 |
+
-0.9999999310821295,
|
| 31 |
+
-0.9999999310821295,
|
| 32 |
+
-0.9999999310821295,
|
| 33 |
+
-0.9999999310821295,
|
| 34 |
+
-0.9999999310821295,
|
| 35 |
+
-0.9999999310821295,
|
| 36 |
+
-0.9999999310821295,
|
| 37 |
+
-0.9999999310821295,
|
| 38 |
+
-0.9999999310821295,
|
| 39 |
+
-0.9999999310821295,
|
| 40 |
+
-0.9999999310821295
|
| 41 |
+
],
|
| 42 |
+
"gold_pickups": 0
|
| 43 |
+
}
|
evaluation.json
CHANGED
|
@@ -38,5 +38,6 @@
|
|
| 38 |
-0.9999999310821295,
|
| 39 |
-0.9999999310821295,
|
| 40 |
-0.9999999310821295
|
| 41 |
-
]
|
|
|
|
| 42 |
}
|
|
|
|
| 38 |
-0.9999999310821295,
|
| 39 |
-0.9999999310821295,
|
| 40 |
-0.9999999310821295
|
| 41 |
+
],
|
| 42 |
+
"gold_pickups": 0
|
| 43 |
}
|
run_logs/training_status.json
CHANGED
|
@@ -2,22 +2,58 @@
|
|
| 2 |
"Pyramids": {
|
| 3 |
"checkpoints": [
|
| 4 |
{
|
| 5 |
-
"steps":
|
| 6 |
-
"file_path": "results/Pyramids/Pyramids/Pyramids-
|
| 7 |
"reward": null,
|
| 8 |
-
"creation_time":
|
| 9 |
"auxillary_file_paths": [
|
| 10 |
-
"results/Pyramids/Pyramids/Pyramids-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
]
|
| 12 |
}
|
| 13 |
],
|
| 14 |
"final_checkpoint": {
|
| 15 |
-
"steps":
|
| 16 |
"file_path": "results/Pyramids/Pyramids.onnx",
|
| 17 |
"reward": null,
|
| 18 |
-
"creation_time":
|
| 19 |
"auxillary_file_paths": [
|
| 20 |
-
"results/Pyramids/Pyramids/Pyramids-
|
| 21 |
]
|
| 22 |
}
|
| 23 |
},
|
|
|
|
| 2 |
"Pyramids": {
|
| 3 |
"checkpoints": [
|
| 4 |
{
|
| 5 |
+
"steps": 327634,
|
| 6 |
+
"file_path": "results/Pyramids/Pyramids/Pyramids-327634.onnx",
|
| 7 |
"reward": null,
|
| 8 |
+
"creation_time": 1796029194.9683628,
|
| 9 |
"auxillary_file_paths": [
|
| 10 |
+
"results/Pyramids/Pyramids/Pyramids-327634.pt"
|
| 11 |
+
]
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"steps": 393172,
|
| 15 |
+
"file_path": "results/Pyramids/Pyramids/Pyramids-393172.onnx",
|
| 16 |
+
"reward": -0.9996000528335571,
|
| 17 |
+
"creation_time": 1796029274.6643064,
|
| 18 |
+
"auxillary_file_paths": [
|
| 19 |
+
"results/Pyramids/Pyramids/Pyramids-393172.pt"
|
| 20 |
+
]
|
| 21 |
+
},
|
| 22 |
+
{
|
| 23 |
+
"steps": 458717,
|
| 24 |
+
"file_path": "results/Pyramids/Pyramids/Pyramids-458717.onnx",
|
| 25 |
+
"reward": -0.09466671943664551,
|
| 26 |
+
"creation_time": 1796029351.182556,
|
| 27 |
+
"auxillary_file_paths": [
|
| 28 |
+
"results/Pyramids/Pyramids/Pyramids-458717.pt"
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
{
|
| 32 |
+
"steps": 524226,
|
| 33 |
+
"file_path": "results/Pyramids/Pyramids/Pyramids-524226.onnx",
|
| 34 |
+
"reward": null,
|
| 35 |
+
"creation_time": 1796029439.7382226,
|
| 36 |
+
"auxillary_file_paths": [
|
| 37 |
+
"results/Pyramids/Pyramids/Pyramids-524226.pt"
|
| 38 |
+
]
|
| 39 |
+
},
|
| 40 |
+
{
|
| 41 |
+
"steps": 524354,
|
| 42 |
+
"file_path": "results/Pyramids/Pyramids/Pyramids-524354.onnx",
|
| 43 |
+
"reward": null,
|
| 44 |
+
"creation_time": 1796029439.7698808,
|
| 45 |
+
"auxillary_file_paths": [
|
| 46 |
+
"results/Pyramids/Pyramids/Pyramids-524354.pt"
|
| 47 |
]
|
| 48 |
}
|
| 49 |
],
|
| 50 |
"final_checkpoint": {
|
| 51 |
+
"steps": 524354,
|
| 52 |
"file_path": "results/Pyramids/Pyramids.onnx",
|
| 53 |
"reward": null,
|
| 54 |
+
"creation_time": 1796029439.7698808,
|
| 55 |
"auxillary_file_paths": [
|
| 56 |
+
"results/Pyramids/Pyramids/Pyramids-524354.pt"
|
| 57 |
]
|
| 58 |
}
|
| 59 |
},
|
validation.json
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"selected_training_step": 130976,
|
| 3 |
+
"measurements": [
|
| 4 |
+
{
|
| 5 |
+
"training_step": 130976,
|
| 6 |
+
"environment": "Pyramids",
|
| 7 |
+
"seed": 2025,
|
| 8 |
+
"episodes": 32,
|
| 9 |
+
"stochastic_policy": true,
|
| 10 |
+
"mean": -0.5317186875149673,
|
| 11 |
+
"std": 0.9766286976487613,
|
| 12 |
+
"returns": [
|
| 13 |
+
1.7570000167470425,
|
| 14 |
+
1.5460000312887132,
|
| 15 |
+
1.3870000422466546,
|
| 16 |
+
-0.9999999310821295,
|
| 17 |
+
-0.9999999310821295,
|
| 18 |
+
-0.9999999310821295,
|
| 19 |
+
-0.9999999310821295,
|
| 20 |
+
-0.9999999310821295,
|
| 21 |
+
-0.9999999310821295,
|
| 22 |
+
-0.9999999310821295,
|
| 23 |
+
-0.9999999310821295,
|
| 24 |
+
-0.9999999310821295,
|
| 25 |
+
-0.9999999310821295,
|
| 26 |
+
-0.9999999310821295,
|
| 27 |
+
-0.9999999310821295,
|
| 28 |
+
-0.9999999310821295,
|
| 29 |
+
-0.9999999311257852,
|
| 30 |
+
-0.9999999311257852,
|
| 31 |
+
1.544000031426549,
|
| 32 |
+
-0.9999999311257852,
|
| 33 |
+
1.3800000427290797,
|
| 34 |
+
1.3710000433493406,
|
| 35 |
+
-0.9999999310821295,
|
| 36 |
+
-0.9999999310821295,
|
| 37 |
+
-0.9999999310821295,
|
| 38 |
+
-0.9999999310821295,
|
| 39 |
+
-0.9999999310821295,
|
| 40 |
+
-0.9999999310821295,
|
| 41 |
+
-0.9999999310821295,
|
| 42 |
+
-0.9999999310821295,
|
| 43 |
+
-0.9999999310821295,
|
| 44 |
+
-0.9999999310821295
|
| 45 |
+
],
|
| 46 |
+
"gold_pickups": 6
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"training_step": 262141,
|
| 50 |
+
"environment": "Pyramids",
|
| 51 |
+
"seed": 2025,
|
| 52 |
+
"episodes": 32,
|
| 53 |
+
"stochastic_policy": true,
|
| 54 |
+
"mean": -0.9363124311639694,
|
| 55 |
+
"std": 0.3545969924020713,
|
| 56 |
+
"returns": [
|
| 57 |
+
-0.9999999310821295,
|
| 58 |
+
-0.9999999310821295,
|
| 59 |
+
-0.9999999310821295,
|
| 60 |
+
-0.9999999310821295,
|
| 61 |
+
-0.9999999310821295,
|
| 62 |
+
-0.9999999310821295,
|
| 63 |
+
-0.9999999310821295,
|
| 64 |
+
-0.9999999310821295,
|
| 65 |
+
-0.9999999310821295,
|
| 66 |
+
-0.9999999310821295,
|
| 67 |
+
-0.9999999310821295,
|
| 68 |
+
-0.9999999310821295,
|
| 69 |
+
-0.9999999310821295,
|
| 70 |
+
-0.9999999310821295,
|
| 71 |
+
-0.9999999310821295,
|
| 72 |
+
-0.9999999310821295,
|
| 73 |
+
1.0380000662989914,
|
| 74 |
+
-0.9999999310821295,
|
| 75 |
+
-0.9999999310821295,
|
| 76 |
+
-0.9999999310821295,
|
| 77 |
+
-0.9999999310821295,
|
| 78 |
+
-0.9999999310821295,
|
| 79 |
+
-0.9999999310821295,
|
| 80 |
+
-0.9999999310821295,
|
| 81 |
+
-0.9999999310821295,
|
| 82 |
+
-0.9999999310821295,
|
| 83 |
+
-0.9999999310821295,
|
| 84 |
+
-0.9999999310821295,
|
| 85 |
+
-0.9999999310821295,
|
| 86 |
+
-0.9999999310821295,
|
| 87 |
+
-0.9999999310821295,
|
| 88 |
+
-0.9999999310821295
|
| 89 |
+
],
|
| 90 |
+
"gold_pickups": 1
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"training_step": 393172,
|
| 94 |
+
"environment": "Pyramids",
|
| 95 |
+
"seed": 2025,
|
| 96 |
+
"episodes": 32,
|
| 97 |
+
"stochastic_policy": true,
|
| 98 |
+
"mean": -0.7994061819872513,
|
| 99 |
+
"std": 0.6242568983292798,
|
| 100 |
+
"returns": [
|
| 101 |
+
1.2080000545829535,
|
| 102 |
+
1.0150000678841025,
|
| 103 |
+
-0.9999999310821295,
|
| 104 |
+
-0.9999999310821295,
|
| 105 |
+
-0.9999999310821295,
|
| 106 |
+
-0.9999999310821295,
|
| 107 |
+
-0.9999999310821295,
|
| 108 |
+
-0.9999999310821295,
|
| 109 |
+
-0.9999999310821295,
|
| 110 |
+
-0.9999999310821295,
|
| 111 |
+
-0.9999999310821295,
|
| 112 |
+
-0.9999999310821295,
|
| 113 |
+
-0.9999999310821295,
|
| 114 |
+
-0.9999999310821295,
|
| 115 |
+
-0.9999999310821295,
|
| 116 |
+
-0.9999999310821295,
|
| 117 |
+
-0.9999999311257852,
|
| 118 |
+
1.196000055409968,
|
| 119 |
+
-0.9999999311257852,
|
| 120 |
+
-0.9999999310821295,
|
| 121 |
+
-0.9999999310821295,
|
| 122 |
+
-0.9999999310821295,
|
| 123 |
+
-0.9999999310821295,
|
| 124 |
+
-0.9999999310821295,
|
| 125 |
+
-0.9999999310821295,
|
| 126 |
+
-0.9999999310821295,
|
| 127 |
+
-0.9999999310821295,
|
| 128 |
+
-0.9999999310821295,
|
| 129 |
+
-0.9999999310821295,
|
| 130 |
+
-0.9999999310821295,
|
| 131 |
+
-0.9999999310821295,
|
| 132 |
+
-0.9999999310821295
|
| 133 |
+
],
|
| 134 |
+
"gold_pickups": 3
|
| 135 |
+
},
|
| 136 |
+
{
|
| 137 |
+
"training_step": 524354,
|
| 138 |
+
"environment": "Pyramids",
|
| 139 |
+
"seed": 2025,
|
| 140 |
+
"episodes": 32,
|
| 141 |
+
"stochastic_policy": true,
|
| 142 |
+
"mean": -0.7975311821137439,
|
| 143 |
+
"std": 0.6298706672175708,
|
| 144 |
+
"returns": [
|
| 145 |
+
-0.9999999310821295,
|
| 146 |
+
-0.9999999310821295,
|
| 147 |
+
-0.9999999310821295,
|
| 148 |
+
-0.9999999310821295,
|
| 149 |
+
-0.9999999310821295,
|
| 150 |
+
-0.9999999310821295,
|
| 151 |
+
-0.9999999310821295,
|
| 152 |
+
-0.9999999310821295,
|
| 153 |
+
-0.9999999310821295,
|
| 154 |
+
-0.9999999310821295,
|
| 155 |
+
-0.9999999310821295,
|
| 156 |
+
-0.9999999310821295,
|
| 157 |
+
-0.9999999310821295,
|
| 158 |
+
-0.9999999310821295,
|
| 159 |
+
-0.9999999310821295,
|
| 160 |
+
-0.9999999310821295,
|
| 161 |
+
1.2520000515505672,
|
| 162 |
+
1.1460000588558614,
|
| 163 |
+
1.081000063335523,
|
| 164 |
+
-0.9999999310821295,
|
| 165 |
+
-0.9999999310821295,
|
| 166 |
+
-0.9999999310821295,
|
| 167 |
+
-0.9999999310821295,
|
| 168 |
+
-0.9999999310821295,
|
| 169 |
+
-0.9999999310821295,
|
| 170 |
+
-0.9999999310821295,
|
| 171 |
+
-0.9999999310821295,
|
| 172 |
+
-0.9999999310821295,
|
| 173 |
+
-0.9999999310821295,
|
| 174 |
+
-0.9999999310821295,
|
| 175 |
+
-0.9999999310821295,
|
| 176 |
+
-0.9999999310821295
|
| 177 |
+
],
|
| 178 |
+
"gold_pickups": 3
|
| 179 |
+
}
|
| 180 |
+
]
|
| 181 |
+
}
|