Skip to content

SM_HPS is worth mentioning #522

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 6 commits into from
Dec 24, 2018
Merged

SM_HPS is worth mentioning #522

merged 6 commits into from
Dec 24, 2018

Conversation

yifeim
Copy link
Contributor

@yifeim yifeim commented Dec 2, 2018

Just found a SM_HPS environmental variable that dumps the original hyperparameters as a json string. This helps preserve types and is definitely worth mentioning!

Issue #, if available:

Description of changes:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have updated the changelog with a description of my changes (if appropriate)
  • I have updated any necessary documentation (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Just found a SM_HPS environmental variable that dumps the original hyperparameters as a json string. This helps preserve types and is definitely worth mentioning!
@codecov-io
Copy link

codecov-io commented Dec 2, 2018

Codecov Report

Merging #522 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #522   +/-   ##
=======================================
  Coverage   92.78%   92.78%           
=======================================
  Files          71       71           
  Lines        5366     5366           
=======================================
  Hits         4979     4979           
  Misses        387      387

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f32a441...7f925fe. Read the comment docs.

@@ -76,6 +78,9 @@ For example, a training script might start with the following:
parser.add_argument('--batch-size', type=int, default=100)
parser.add_argument('--learning-rate', type=float, default=0.1)

# an alternative way to load hyperparameters via SM_HPS environmental variable.
parser.add_argument('--sm-hps', type=json.loads, default=os.environ['SM_HPS'])
Copy link
Contributor

Choose a reason for hiding this comment

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

parser.add_argument('--sm-hps', type=dict, default=json.loads(os.environ['SM_HPS']))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Question: I thought type=json.loads because it is an actual json string. Would type=dict handle situations like nested dictionaries or lists?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, misread your comment. Let me do some background check again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@icywang86rui I don't actually know this usage. What is the input format to work with type=dict?

I found that type=dict gave me errors, similar to this post: https://stackoverflow.com/questions/7625786/type-dict-in-argparse-add-argument

Copy link
Contributor

Choose a reason for hiding this comment

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

when type=dict gave you errors, it was even with json.loads(os.environ['SM_HPS']) as the default? The Stack Overflow question seems to be about if you feed only a string to the parser when it's expecting a dict.

@yifeim
Copy link
Contributor Author

yifeim commented Dec 21, 2018 via email

@laurenyu
Copy link
Contributor

@yifeim yeah that was my thought too when reading the Stack Overflow question you linked to, but it seems weird that argparse would have a dict option if it's not possible.

anyway, I think I'm fine with this PR - can you add a changelog entry?

@laurenyu laurenyu dismissed icywang86rui’s stale review December 24, 2018 20:49

see correspondence in this PR

Copy link
Contributor

@laurenyu laurenyu left a comment

Choose a reason for hiding this comment

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

going to make a separate PR lumping together a few different changelog changes, so approving this PR as is.

@laurenyu laurenyu merged commit ba70ca6 into aws:master Dec 24, 2018
@laurenyu laurenyu mentioned this pull request Dec 24, 2018
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants