Skip to content

Commit 7c80d16

Browse files
author
Ragav Venkatesan
committed
2 parents 5754cba + 066e8b7 commit 7c80d16

33 files changed

+1451
-252
lines changed

CHANGELOG.rst

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,41 @@
22
CHANGELOG
33
=========
44

5+
1.1.0
6+
=====
7+
8+
* feature: Estimators: add support for TensorFlow-1.5.0
9+
* feature: Estimators: add support for MXNet-1.0.0
10+
* feature: Tests: use ``sagemaker_timestamp`` when creating endpoint names in integration tests
11+
* feature: Session: print out billable seconds after training completes
12+
* bug-fix: Estimators: fix LinearLearner and add unit tests
13+
* bug-fix: Tests: fix timeouts for PCA async integration test
14+
* feature: Predictors: allow ``predictor.predict()`` in the JSON serializer to accept dictionaries
15+
516
1.0.4
617
=====
718

819
* feature: Estimators: add support for Amazon Neural Topic Model(NTM) algorithm
9-
* feature: Documentation: Fix description of an argument of sagemaker.session.train
10-
* feature: Documentation: Add FM and LDA to the documentation
20+
* feature: Documentation: fix description of an argument of sagemaker.session.train
21+
* feature: Documentation: add FM and LDA to the documentation
1122
* feature: Estimators: add support for async fit
1223
* bug-fix: Estimators: fix estimator role expansion
1324

1425
1.0.3
1526
=====
1627

1728
* feature: Estimators: add support for Amazon LDA algorithm
18-
* feature: Hyperparameters: Add data_type to hyperparameters
19-
* feature: Documentation: Update TensorFlow examples following API change
20-
* feature: Session: Support multi-part uploads
29+
* feature: Hyperparameters: add data_type to hyperparameters
30+
* feature: Documentation: update TensorFlow examples following API change
31+
* feature: Session: support multi-part uploads
32+
* feature: add new SageMaker CLI
2133

2234

2335
1.0.2
2436
=====
2537

2638
* feature: Estimators: add support for Amazon FactorizationMachines algorithm
27-
* feature: Session: Correctly handle TooManyBuckets error_code in default_bucket method
39+
* feature: Session: correctly handle TooManyBuckets error_code in default_bucket method
2840
* feature: Tests: add training failure tests for TF and MXNet
2941
* feature: Documentation: show how to make predictions against existing endpoint
3042
* feature: Estimators: implement write_spmatrix_to_sparse_tensor to support any scipy.sparse matrix
@@ -45,4 +57,3 @@ CHANGELOG
4557
=====
4658

4759
* Initial commit
48-

README.rst

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can install from source by cloning this repository and issuing a pip install
3939

4040
git clone https://github.com/aws/sagemaker-python-sdk.git
4141
python setup.py sdist
42-
pip install dist/sagemaker-1.0.4.tar.gz
42+
pip install dist/sagemaker-1.1.0.tar.gz
4343

4444
Supported Python versions
4545
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -114,6 +114,8 @@ MXNet SageMaker Estimators
114114

115115
With MXNet Estimators, you can train and host MXNet models on Amazon SageMaker.
116116

117+
Supported versions of MXNet: ``1.0.0``, ``0.12.1``.
118+
117119
Training with MXNet
118120
~~~~~~~~~~~~~~~~~~~
119121

@@ -185,7 +187,7 @@ If you want to run your training script locally via the Python interpreter, look
185187
Using MXNet and numpy
186188
^^^^^^^^^^^^^^^^^^^^^
187189

188-
You can import both ``mxnet`` and ``numpy`` in your training script. When your script runs in SageMaker, it will run with access to MXNet version 0.12 and numpy version 1.12.0. For more information on the environment your script runs in, please see `SageMaker MXNet Containers <#sagemaker-mxnet-containers>`__.
190+
You can import both ``mxnet`` and ``numpy`` in your training script. When your script runs in SageMaker, it will run with access to MXNet version 1.0.0 and numpy version 1.13.3 by default. For more information on the environment your script runs in, please see `SageMaker MXNet Containers <#sagemaker-mxnet-containers>`__.
189191

190192
Running an MXNet training script in SageMaker
191193
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -682,26 +684,33 @@ When training and deploying training scripts, SageMaker runs your Python script
682684
683685
SageMaker runs MXNet Estimator scripts in either Python 2.7 or Python 3.5. You can select the Python version by passing a ``py_version`` keyword arg to the MXNet Estimator constructor. Setting this to ``py2`` (the default) will cause your training script to be run on Python 2.7. Setting this to ``py3`` will cause your training script to be run on Python 3.5. This Python version applies to both the Training Job, created by fit, and the Endpoint, created by deploy.
684686
685-
Your MXNet training script will be run on version 0.12 of MXNet, built for either GPU or CPU use. The decision to use the GPU or CPU version of MXNet is made by the train_instance_type, set on the MXNet constructor. If you choose a GPU instance type, your training job will be run on a GPU version of MXNet. If you choose a CPU instance type, your training job will be run on a CPU version of MXNet. Similarly, when you call deploy, specifying a GPU or CPU deploy_instance_type, will control which MXNet build your Endpoint runs.
687+
Your MXNet training script will be run on version 1.0.0 (by default) or 0.12 of MXNet, built for either GPU or CPU use. The decision to use the GPU or CPU version of MXNet is made by the ``train_instance_type``, set on the MXNet constructor. If you choose a GPU instance type, your training job will be run on a GPU version of MXNet. If you choose a CPU instance type, your training job will be run on a CPU version of MXNet. Similarly, when you call deploy, specifying a GPU or CPU deploy_instance_type, will control which MXNet build your Endpoint runs.
686688
687-
Each Docker container has the following dependencies installed:
689+
The Docker images have the following dependencies installed:
688690
689-
- Python 2.7 or Python 3.5, depending on the ``py_version`` argument on
690-
the MXNet constructor.
691-
- MXNet 0.12, built for either GPU or CPU, depending on the instance
692-
type for training or deploying.
693-
- CUDA 9.0
694-
- numpy 1.12
691+
+-------------------------+--------------+-------------+
692+
| Dependencies | MXNet 0.12.1 | MXNet 1.0.0 |
693+
+-------------------------+--------------+-------------+
694+
| Python | 2.7 or 3.5 | 2.7 or 3.5|
695+
+-------------------------+--------------+-------------+
696+
| CUDA | 9.0 | 9.0 |
697+
+-------------------------+--------------+-------------+
698+
| numpy | 1.13.3 | 1.13.3 |
699+
+-------------------------+--------------+-------------+
695700
696701
The Docker images extend Ubuntu 16.04.
697702
703+
You can select version of MXNet by passing a ``framework_version`` keyword arg to the MXNet Estimator constructor. Currently supported versions are ``1.0.0`` and ``0.12.1``. You can also set ``framework_version`` to ``1.0 (default)`` or ``0.12`` which will cause your training script to be run on the latest supported MXNet 1.0 or 0.12 versions respectively.
704+
698705
TensorFlow SageMaker Estimators
699706
-------------------------------
700707
701708
TensorFlow SageMaker Estimators allow you to run your own TensorFlow
702709
training algorithms on SageMaker Learner, and to host your own TensorFlow
703710
models on SageMaker Hosting.
704711
712+
Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``.
713+
705714
Training with TensorFlow
706715
~~~~~~~~~~~~~~~~~~~~~~~~
707716
@@ -735,7 +744,7 @@ Preparing the TensorFlow training script
735744
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
736745
737746
Your TensorFlow training script must be a **Python 2.7** source file. The current supported TensorFlow
738-
version is **1.4.0**. This training script **must contain** the following functions:
747+
versions are **1.5.0 (default)** and **1.4.1**. This training script **must contain** the following functions:
739748
740749
- ``model_fn``: defines the model that will be trained.
741750
- ``train_input_fn``: preprocess and load training data.
@@ -1419,27 +1428,49 @@ A example with ``input_fn`` and ``output_fn`` above can be found in
14191428
SageMaker TensorFlow Docker containers
14201429
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14211430
1422-
The TensorFlow Docker container supports Python 2.7. The Docker container has the following Python modules installed:
1423-
- awscli 1.12.1
1424-
- boto3 1.4.7
1425-
- botocore 1.5.92
1426-
- futures 2.2.0
1427-
- gevent 1.2.2
1428-
- grpcio 1.7.0
1429-
- numpy 1.13.3
1430-
- pandas 0.21.0
1431-
- protobuf 3.4.0
1432-
- requests 2.14.2
1433-
- scikit-learn 0.19.1
1434-
- scipy 1.0.0
1435-
- six 1.10.0
1436-
- sklearn 0.0
1437-
- tensorflow 1.4.0
1438-
- tensorflow-serving-api 1.4.0
1439-
- tensorflow-tensorboard 0.4.0rc2
1431+
The TensorFlow Docker images support Python 2.7 and have the following Python modules installed:
1432+
1433+
+------------------------+------------------+------------------+
1434+
| Dependencies | tensorflow 1.4.1 | tensorflow 1.5.0 |
1435+
+------------------------+------------------+------------------+
1436+
| awscli | 1.12.1 | 1.14.35 |
1437+
+------------------------+------------------+------------------+
1438+
| boto3 | 1.4.7 | 1.5.22 |
1439+
+------------------------+------------------+------------------+
1440+
| botocore | 1.5.92 | 1.8.36 |
1441+
+------------------------+------------------+------------------+
1442+
| futures | 2.2.0 | 2.2.0 |
1443+
+------------------------+------------------+------------------+
1444+
| gevent | 1.2.2 | 1.2.2 |
1445+
+------------------------+------------------+------------------+
1446+
| grpcio | 1.7.0 | 1.9.0 |
1447+
+------------------------+------------------+------------------+
1448+
| numpy | 1.13.3 | 1.14.0 |
1449+
+------------------------+------------------+------------------+
1450+
| pandas | 0.21.0 | 0.22.0 |
1451+
+------------------------+------------------+------------------+
1452+
| protobuf | 3.4.0 | 3.5.1 |
1453+
+------------------------+------------------+------------------+
1454+
| requests | 2.14.2 | 2.18.4 |
1455+
+------------------------+------------------+------------------+
1456+
| scikit-learn | 0.19.1 | 0.19.1 |
1457+
+------------------------+------------------+------------------+
1458+
| scipy | 1.0.0 | 1.0.0 |
1459+
+------------------------+------------------+------------------+
1460+
| six | 1.10.0 | 1.10.0 |
1461+
+------------------------+------------------+------------------+
1462+
| sklearn | 0.0 | 0.0 |
1463+
+------------------------+------------------+------------------+
1464+
| tensorflow | 1.4.1 | 1.5.0 |
1465+
+------------------------+------------------+------------------+
1466+
| tensorflow-serving-api | 1.4.0 | 1.5.0 |
1467+
+------------------------+------------------+------------------+
1468+
| tensorflow-tensorboard | 0.4.0 | 1.5.1 |
1469+
+------------------------+------------------+------------------+
14401470
14411471
The Docker images extend Ubuntu 16.04.
14421472
1473+
You can select version of TensorFlow by passing a ``framework_version`` keyword arg to the TensorFlow Estimator constructor. Currently supported versions are ``1.5.0`` and ``1.4.1``. You can also set ``framework_version`` to ``1.5 (default)`` or ``1.4`` which will cause your training script to be run on the latest supported TensorFlow 1.5 or 1.4 versions respectively.
14431474
14441475
AWS SageMaker Estimators
14451476
------------------------

doc/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def __getattr__(cls, name):
1818
'tensorflow.python.framework', 'tensorflow_serving', 'tensorflow_serving.apis']
1919
sys.modules.update((mod_name, Mock()) for mod_name in MOCK_MODULES)
2020

21-
version = '1.0.4'
21+
version = '1.1.0'
2222
project = u'sagemaker'
2323

2424
# Add any Sphinx extension module names here, as strings. They can be extensions

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def read(fname):
1111

1212

1313
setup(name="sagemaker",
14-
version="1.0.4",
14+
version="1.1.0",
1515
description="Open source library for training and deploying models on Amazon SageMaker.",
1616
packages=find_packages('src'),
1717
package_dir={'': 'src'},

src/sagemaker/amazon/linear_learner.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LinearLearner(AmazonAlgorithmEstimatorBase):
5151
momentum = hp('momentum', (gt(0), lt(1)), 'A float in (0,1)', float)
5252
learning_rate = hp('learning_rate', (gt(0), lt(1)), 'A float in (0,1)', float)
5353
beta_1 = hp('beta_1', (gt(0), lt(1)), 'A float in (0,1)', float)
54-
beta_2 = hp('beta_1', (gt(0), lt(1)), 'A float in (0,1)', float)
54+
beta_2 = hp('beta_2', (gt(0), lt(1)), 'A float in (0,1)', float)
5555
bias_lr_mult = hp('bias_lr_mult', gt(0), 'A float greater-than 0', float)
5656
bias_wd_mult = hp('bias_wd_mult', gt(0), 'A float greater-than 0', float)
5757
use_lr_scheduler = hp('use_lr_scheduler', (), 'A boolean', bool)
@@ -62,7 +62,7 @@ class LinearLearner(AmazonAlgorithmEstimatorBase):
6262
normalize_label = hp('normalize_label', (), 'A boolean', bool)
6363
unbias_data = hp('unbias_data', (), 'A boolean', bool)
6464
unbias_label = hp('unbias_label', (), 'A boolean', bool)
65-
num_point_for_scalar = hp('num_point_for_scalar', gt(0), 'An integer greater-than 0', int)
65+
num_point_for_scaler = hp('num_point_for_scaler', gt(0), 'An integer greater-than 0', int)
6666

6767
def __init__(self, role, train_instance_count, train_instance_type, predictor_type='binary_classifier',
6868
binary_classifier_model_selection_criteria=None, target_recall=None, target_precision=None,
@@ -71,7 +71,7 @@ def __init__(self, role, train_instance_count, train_instance_type, predictor_ty
7171
optimizer=None, loss=None, wd=None, l1=None, momentum=None, learning_rate=None, beta_1=None,
7272
beta_2=None, bias_lr_mult=None, bias_wd_mult=None, use_lr_scheduler=None, lr_scheduler_step=None,
7373
lr_scheduler_factor=None, lr_scheduler_minimum_lr=None, normalize_data=None,
74-
normalize_label=None, unbias_data=None, unbias_label=None, num_point_for_scalar=None, **kwargs):
74+
normalize_label=None, unbias_data=None, unbias_label=None, num_point_for_scaler=None, **kwargs):
7575
"""An :class:`Estimator` for binary classification and regression.
7676
7777
Amazon SageMaker Linear Learner provides a solution for both classification and regression problems, allowing
@@ -186,14 +186,14 @@ def __init__(self, role, train_instance_count, train_instance_type, predictor_ty
186186
self.normalize_data = normalize_data
187187
self.normalize_label = normalize_label
188188
self.unbias_data = unbias_data
189-
self.ubias_label = unbias_label
190-
self.num_point_for_scaler = num_point_for_scalar
189+
self.unbias_label = unbias_label
190+
self.num_point_for_scaler = num_point_for_scaler
191191

192192
def create_model(self):
193193
"""Return a :class:`~sagemaker.amazon.kmeans.LinearLearnerModel` referencing the latest
194194
s3 model data produced by this Estimator."""
195195

196-
return LinearLearnerModel(self, self.model_data, self.role, self.sagemaker_session)
196+
return LinearLearnerModel(self.model_data, self.role, self.sagemaker_session)
197197

198198
def fit(self, records, mini_batch_size=None, **kwargs):
199199
# mini_batch_size can't be greater than number of records or training job fails

src/sagemaker/fw_utils.py

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -28,26 +28,28 @@
2828
"""
2929

3030

31-
def create_image_uri(region, framework, instance_type, py_version='py2', tag='1.0', account='520713654638'):
31+
def create_image_uri(region, framework, instance_type, framework_version, py_version, account='520713654638'):
3232
"""Return the ECR URI of an image.
3333
3434
Args:
3535
region (str): AWS region where the image is uploaded.
3636
framework (str): framework used by the image.
3737
instance_type (str): EC2 instance type. Used to determine whether to use the CPU image or GPU image.
38-
py_version (str): Python version. (default: 'py2')
39-
tag (str): ECR image tag, which denotes the image version. (default: '1.0')
38+
framework_version (str): The version of the framework.
39+
py_version (str): Python version. One of 'py2' or 'py3'.
4040
account (str): AWS account that contains the image. (default: '520713654638')
4141
4242
Returns:
4343
str: The appropriate image URI based on the given parameters.
4444
"""
45-
device_version = 'cpu'
46-
# Instance types that start with G, P are GPU powered: https://aws.amazon.com/ec2/instance-types/
45+
device_type = 'cpu'
46+
# Instance types that start with G, P are GPU powered: https://aws.amazon.com/sagemaker/pricing/instance-types/
4747
if instance_type[3] in ['g', 'p']:
48-
device_version = 'gpu'
48+
device_type = 'gpu'
49+
50+
tag = "{}-{}-{}".format(framework_version, device_type, py_version)
4951
return "{}.dkr.ecr.{}.amazonaws.com/sagemaker-{}-{}-{}:{}" \
50-
.format(account, region, framework, py_version, device_version, tag)
52+
.format(account, region, framework, py_version, device_type, tag)
5153

5254

5355
def tar_and_upload_dir(session, bucket, s3_key_prefix, script, directory):
@@ -112,21 +114,37 @@ def framework_name_from_image(image_name):
112114
tuple: A tuple containing:
113115
str: The framework name
114116
str: The Python version
117+
str: The image tag
115118
"""
116119
# image name format: <account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<framework>-<py_ver>-<device>:<tag>
117-
sagemaker_pattern = re.compile('^(\d+)(\.)dkr(\.)ecr(\.)(.+)(\.)amazonaws.com(/)(.*)(:)(.*)$')
120+
sagemaker_pattern = re.compile('^(\d+)(\.)dkr(\.)ecr(\.)(.+)(\.)amazonaws.com(/)(.*:.*)$')
118121
sagemaker_match = sagemaker_pattern.match(image_name)
119122
if sagemaker_match is None:
120-
return None, None
123+
return None, None, None
121124
else:
122-
# extract framework and python version
123-
name_pattern = re.compile('^sagemaker-(tensorflow|mxnet)-(py2|py3)-(cpu|gpu)$')
125+
# extract framework, python version and image tag
126+
name_pattern = re.compile('^sagemaker-(tensorflow|mxnet)-(py2|py3)-(cpu|gpu):(.*)$')
127+
124128
name_match = name_pattern.match(sagemaker_match.group(8))
125129

126130
if name_match is None:
127-
return None, None
131+
return None, None, None
128132
else:
129-
return name_match.group(1), name_match.group(2)
133+
return name_match.group(1), name_match.group(2), name_match.group(4)
134+
135+
136+
def framework_version_from_tag(image_tag):
137+
"""Extract the framework version from the image tag.
138+
139+
Args:
140+
image_tag (str): Image tag, which should take the form '<framework_version>-<device>-<py_version>'
141+
142+
Returns:
143+
str: The framework version.
144+
"""
145+
tag_pattern = re.compile('^(.*)-(cpu|gpu)-(py2|py3)$')
146+
tag_match = tag_pattern.match(image_tag)
147+
return None if tag_match is None else tag_match.group(1)
130148

131149

132150
def parse_s3_url(url):

src/sagemaker/mxnet/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
1+
# Copyright 2017-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License"). You
44
# may not use this file except in compliance with the License. A copy of
@@ -14,5 +14,3 @@
1414
from sagemaker.mxnet.model import MXNetModel, MXNetPredictor
1515

1616
__all__ = [MXNet, MXNetModel, MXNetPredictor]
17-
18-
DOCKER_TAG = "1.0"

src/sagemaker/mxnet/defaults.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You
4+
# may not use this file except in compliance with the License. A copy of
5+
# the License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is
10+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11+
# ANY KIND, either express or implied. See the License for the specific
12+
# language governing permissions and limitations under the License.
13+
MXNET_VERSION = '1.0'

0 commit comments

Comments
 (0)