Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[🐛 🔨 ]Adding the ELO to the GlobalTrainingStatus #5202

Merged
merged 2 commits into from
Mar 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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