Skip to content

add to_string for samplers #4484

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

Merged
merged 4 commits into from
Oct 7, 2020
Merged

add to_string for samplers #4484

merged 4 commits into from
Oct 7, 2020

Conversation

andrewcoh
Copy link
Contributor

Proposed change(s)

This increases the verbosity of the curriculum lesson changes by adding to_strings to the sampler classes. The lesson updates would now output the sampler stats in addition to the lesson and parameter name to the console. See below for sample.

Screen Shot 2020-09-14 at 2 58 41 PM

This was done to address a request here #4464

Useful links (Github issues, JIRA tickets, ML-Agents forum threads etc.)

Types of change(s)

  • Bug fix
  • New feature
  • Code refactor
  • Breaking change
  • Documentation update
  • Other (please describe)

Checklist

  • Added tests that prove my fix is effective or that my feature works
  • Updated the changelog (if applicable)
  • Updated the documentation (if applicable)
  • Updated the migration guide (if applicable)

Other comments

@@ -144,11 +145,16 @@ def update_lessons(
self._smoothed_values[param_name] = new_smoothing
if must_increment:
GlobalTrainingStatus.set_parameter_state(
param_name, StatusType.LESSON_NUM, lesson_num + 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lesson_num + 1 occurred in 2-3 places

"""
Helper method to output sampler stats to console.
"""
return f"Float: value={self.value}"
Copy link
Contributor

@chriselion chriselion Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another approach would be to use __repr__, and make the string sufficient to reconstruct the object:

If at all possible, this should look like a valid Python expression that could be used to recreate an object with the same value (given an appropriate environment).

So in this case it would be something like return f"ConstantSettings(value={self.value})"

Co-authored-by: Chris Elion <[email protected]>
Copy link
Contributor

@chriselion chriselion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, can you just add a quick unit test?

@andrewcoh andrewcoh merged commit ed3689c into master Oct 7, 2020
@delete-merged-branch delete-merged-branch bot deleted the develop-verbose-lesson-switch branch October 7, 2020 23:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants