Skip to content

Commit 9c3dc45

Browse files
[🐛 🔨 ]Adding the ELO to the GlobalTrainingStatus (#5202)
* Adding the ELO to the GlobalTrainingStatus * Update ml-agents/mlagents/trainers/ghost/trainer.py Co-authored-by: andrewcoh <54679309+andrewcoh@users.noreply.github.com> Co-authored-by: andrewcoh <54679309+andrewcoh@users.noreply.github.com>
1 parent 73ba867 commit 9c3dc45

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

ml-agents/mlagents/trainers/ghost/trainer.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
BehaviorIdentifiers,
1919
create_name_behavior_id,
2020
)
21+
from mlagents.trainers.training_status import GlobalTrainingStatus, StatusType
2122

2223

2324
logger = get_logger(__name__)
@@ -128,8 +129,11 @@ def __init__(
128129
self.last_swap: int = 0
129130
self.last_team_change: int = 0
130131

131-
# Chosen because it is the initial ELO in Chess
132-
self.initial_elo: float = self_play_parameters.initial_elo
132+
self.initial_elo = GlobalTrainingStatus.get_parameter_state(
133+
self.brain_name, StatusType.ELO
134+
)
135+
if self.initial_elo is None:
136+
self.initial_elo = self_play_parameters.initial_elo
133137
self.policy_elos: List[float] = [self.initial_elo] * (
134138
self.window + 1
135139
) # for learning policy
@@ -323,6 +327,9 @@ def save_model(self) -> None:
323327
"""
324328
Forwarding call to wrapped trainers save_model.
325329
"""
330+
GlobalTrainingStatus.set_parameter_state(
331+
self.brain_name, StatusType.ELO, self.current_elo
332+
)
326333
self.trainer.save_model()
327334

328335
def create_policy(

ml-agents/mlagents/trainers/training_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class StatusType(Enum):
2020
STATS_METADATA = "metadata"
2121
CHECKPOINTS = "checkpoints"
2222
FINAL_CHECKPOINT = "final_checkpoint"
23+
ELO = "elo"
2324

2425

2526
@attr.s(auto_attribs=True)

0 commit comments

Comments
 (0)