-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing the analytics side-channel for curriculum learning. (#5586)
* Fixing the analytics side-channel for curriculum learning. * Made a more robust test. * Update the changelog. * Update com.unity.ml-agents/CHANGELOG.md Co-authored-by: Maryam Honari <honari.m94@gmail.com> Co-authored-by: Maryam Honari <honari.m94@gmail.com>
- Loading branch information
1 parent
3fe4e03
commit 92f1d1f
Showing
4 changed files
with
57 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
ml-agents/mlagents/trainers/tests/test_training_analytics_side_channel.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import yaml | ||
from mlagents.trainers.settings import RunOptions | ||
from mlagents.trainers.training_analytics_side_channel import ( | ||
TrainingAnalyticsSideChannel, | ||
) | ||
|
||
test_curriculum_config_yaml = """ | ||
environment_parameters: | ||
param_1: | ||
curriculum: | ||
- name: Lesson1 | ||
completion_criteria: | ||
measure: reward | ||
behavior: fake_behavior | ||
threshold: 30 | ||
min_lesson_length: 100 | ||
require_reset: true | ||
value: 1 | ||
- name: Lesson2 | ||
completion_criteria: | ||
measure: reward | ||
behavior: fake_behavior | ||
threshold: 60 | ||
min_lesson_length: 100 | ||
require_reset: false | ||
value: 2 | ||
- name: Lesson3 | ||
value: | ||
sampler_type: uniform | ||
sampler_parameters: | ||
min_value: 1 | ||
max_value: 3 | ||
""" | ||
|
||
|
||
def test_sanitize_run_options(): | ||
run_options = RunOptions.from_dict(yaml.safe_load(test_curriculum_config_yaml)) | ||
sanitized = TrainingAnalyticsSideChannel._sanitize_run_options(run_options) | ||
assert "param_1" not in sanitized["environment_parameters"] | ||
assert "fake_behavior" not in sanitized["environment_parameters"] | ||
assert ( | ||
TrainingAnalyticsSideChannel._hash("param_1") | ||
in sanitized["environment_parameters"] | ||
) | ||
level1 = TrainingAnalyticsSideChannel._hash("param_1") | ||
assert sanitized["environment_parameters"][level1]["curriculum"][0][ | ||
"completion_criteria" | ||
]["behavior"] == TrainingAnalyticsSideChannel._hash("fake_behavior") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters