Skip to content

Add Script Mode example #83

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 2 commits into from
Oct 9, 2018
Merged

Add Script Mode example #83

merged 2 commits into from
Oct 9, 2018

Conversation

mvsusp
Copy link
Contributor

@mvsusp mvsusp commented Oct 7, 2018

Description of changes:
Example on how to use the Script Mode container.

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

"source": [
"# Using the Script Mode to train any TensorFlow script from GitHub in SageMaker\n",
"\n",
"In this tutorial, we will show how is simple to train a TensorFlow script in SageMaker using the new Script Mode Tensorflow Container.\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

how simple it is

Choose a reason for hiding this comment

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

"we show"

present tense, when possible, is easier to read and translate

"\n",
"In this tutorial, we will show how is simple to train a TensorFlow script in SageMaker using the new Script Mode Tensorflow Container.\n",
"\n",
"The example the we choosed is [Multi-layer Recurrent Neural Networks (LSTM, RNN) for character-level language models in Python using Tensorflow](https://github.com/sherjilozair/char-rnn-tensorflow) but this same technique can be use to other scripts/repos including [TensorFlow Model Zoo](https://github.com/tensorflow/models) and [TensorFlow benchmark scripts](https://github.com/tensorflow/benchmarks/tree/master/scripts/tf_cnn_benchmarks).\n"
Copy link
Contributor

Choose a reason for hiding this comment

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

s/choosed/chose

"source": [
"## How does it work\n",
"\n",
"The cell above downloaded a Python 3 CPU container locally and used it to simulate SageMaker training. When training starts, the script mode will invoke the following command inside the container:\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

When training starts, the container will invoke the 'train.py' script as shown bellow:

Choose a reason for hiding this comment

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

I have more edits to suggest, but it would be easier for me to do a full edit in Jupyter, and submit that as a PR.

Copy link

@eslesar-aws eslesar-aws left a comment

Choose a reason for hiding this comment

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

I'd like to submit an edit of the notebook as a PR

"source": [
"# Using the Script Mode to train any TensorFlow script from GitHub in SageMaker\n",
"\n",
"In this tutorial, we will show how is simple to train a TensorFlow script in SageMaker using the new Script Mode Tensorflow Container.\n",

Choose a reason for hiding this comment

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

"we show"

present tense, when possible, is easier to read and translate

"source": [
"## How does it work\n",
"\n",
"The cell above downloaded a Python 3 CPU container locally and used it to simulate SageMaker training. When training starts, the script mode will invoke the following command inside the container:\n",

Choose a reason for hiding this comment

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

I have more edits to suggest, but it would be easier for me to do a full edit in Jupyter, and submit that as a PR.

"from sagemaker.estimator import Framework\n",
"from sagemaker.tensorflow import TensorFlow\n",
"\n",
"class ScriptModeTensorFlow(Framework):\n",
Copy link
Contributor

Choose a reason for hiding this comment

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

Current design is to add a flag to the existing TensorFlow estimator, script_mode=true. I talked to yuan briefly last week, we are going to deprioritize the sdk change until we get some feedbacks from the beta customers.

Beta users can use the current TensorFlow estimator with the script-mode containers. They just have to specify the entire image uri and ignore the extra arguments we passed in as hyperparamters, eg, training_steps and eval_steps. I think we can explain all of that here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The script in this example breaks with the TF estimator because the additional hyperparameters, which is why I had to create the estimator.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. I think Nadia's idea of use scriptmode with py3 might work. This is fine as is and we can modify this notebook once we made the changes to the sdk.

"metadata": {},
"outputs": [],
"source": [
"inputs = sagemaker_session.upload_data(path='sherlock', bucket=bucket, key_prefix='datasets/sherlock')"
Copy link
Contributor

Choose a reason for hiding this comment

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

For testing with localmode, we can point it out that the users can use the training data on disk.

@mvsusp mvsusp merged commit 1338820 into aws:script-mode Oct 9, 2018
@mvsusp mvsusp deleted the mvs-sm-example branch October 9, 2018 18:04
Elizaaaaa pushed a commit to Elizaaaaa/sagemaker-tensorflow-container that referenced this pull request Nov 4, 2019
* Add Script Mode example
Elizaaaaa pushed a commit to Elizaaaaa/sagemaker-tensorflow-container that referenced this pull request Nov 4, 2019
* Add Script Mode example
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.

3 participants