Skip to content

Commit

Permalink
[🐛 🔨 ]Adding the ELO to the GlobalTrainingStatus (#5202)
Browse files Browse the repository at this point in the history
* 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>
(cherry picked from commit 9c3dc45)
  • Loading branch information
vincentpierre authored and Ervin Teng committed Apr 8, 2021
1 parent 65c1550 commit 7fae873
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ml-agents/mlagents/trainers/ghost/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
BehaviorIdentifiers,
create_name_behavior_id,
)
from mlagents.trainers.training_status import GlobalTrainingStatus, StatusType


logger = get_logger(__name__)
Expand Down Expand Up @@ -128,8 +129,11 @@ def __init__(
self.last_swap: int = 0
self.last_team_change: int = 0

# Chosen because it is the initial ELO in Chess
self.initial_elo: float = self_play_parameters.initial_elo
self.initial_elo = GlobalTrainingStatus.get_parameter_state(
self.brain_name, StatusType.ELO
)
if self.initial_elo is None:
self.initial_elo = self_play_parameters.initial_elo
self.policy_elos: List[float] = [self.initial_elo] * (
self.window + 1
) # for learning policy
Expand Down Expand Up @@ -323,6 +327,9 @@ def save_model(self) -> None:
"""
Forwarding call to wrapped trainers save_model.
"""
GlobalTrainingStatus.set_parameter_state(
self.brain_name, StatusType.ELO, self.current_elo
)
self.trainer.save_model()

def create_policy(
Expand Down
1 change: 1 addition & 0 deletions ml-agents/mlagents/trainers/training_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class StatusType(Enum):
STATS_METADATA = "metadata"
CHECKPOINTS = "checkpoints"
FINAL_CHECKPOINT = "final_checkpoint"
ELO = "elo"


@attr.s(auto_attribs=True)
Expand Down

0 comments on commit 7fae873

Please sign in to comment.