Skip to content

Add support for TensorFlow 1.11.0 and bump library version up to 1.12.0 #439

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 3 commits into from
Oct 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
CHANGELOG
=========

1.12.0
Copy link
Contributor

Choose a reason for hiding this comment

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

if it doesn't seem like this will be released today, append this with a "dev"

======

* feature: add support for TensorFlow 1.11.0

1.11.3
======

Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ TensorFlow SageMaker Estimators

By using TensorFlow SageMaker ``Estimators``, you can train and host TensorFlow models on Amazon SageMaker.

Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``.
Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``, ``1.11.0``.

We recommend that you use the latest supported version, because that's where we focus most of our development efforts.

Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@
from sagemaker.session import s3_input # noqa: F401
from sagemaker.session import get_execution_role # noqa: F401

__version__ = '1.11.3'
__version__ = '1.12.0'
2 changes: 1 addition & 1 deletion src/sagemaker/fw_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def framework_name_from_image(image_name):
str: The image tag
"""
# image name format: <account>.dkr.ecr.<region>.amazonaws.com/sagemaker-<framework>-<py_ver>-<device>:<tag>
sagemaker_pattern = re.compile('^(\d+)(\.)dkr(\.)ecr(\.)(.+)(\.)amazonaws.com(/)(.*:.*)$')
sagemaker_pattern = re.compile(r'^(\d+)(\.)dkr(\.)ecr(\.)(.+)(\.)amazonaws.com(/)(.*:.*)$')
sagemaker_match = sagemaker_pattern.match(image_name)
if sagemaker_match is None:
return None, None, None
Expand Down
4 changes: 2 additions & 2 deletions src/sagemaker/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -1050,8 +1050,8 @@ def _deployment_entity_exists(describe_fn):
describe_fn()
return True
except ClientError as ce:
if not (ce.response['Error']['Code'] == 'ValidationException' and
'Could not find' in ce.response['Error']['Message']):
error_code = ce.response['Error']['Code']
if not (error_code == 'ValidationException' and 'Could not find' in ce.response['Error']['Message']):
raise ce
return False

Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/tensorflow/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TensorFlow SageMaker Estimators allow you to run your own TensorFlow
training algorithms on SageMaker Learner, and to host your own TensorFlow
models on SageMaker Hosting.

Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``.
Supported versions of TensorFlow: ``1.4.1``, ``1.5.0``, ``1.6.0``, ``1.7.0``, ``1.8.0``, ``1.9.0``, ``1.10.0``, ``1.11.0``.

Training with TensorFlow
~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion src/sagemaker/tensorflow/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@
# language governing permissions and limitations under the License.
from __future__ import absolute_import

TF_VERSION = '1.10'
TF_VERSION = '1.11'
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def sagemaker_local_session(boto_config):

@pytest.fixture(scope='module', params=['1.4', '1.4.1', '1.5', '1.5.0', '1.6', '1.6.0',
'1.7', '1.7.0', '1.8', '1.8.0', '1.9', '1.9.0',
'1.10', '1.10.0'])
'1.10', '1.10.0', '1.11', '1.11.0'])
def tf_version(request):
return request.param

Expand Down
32 changes: 11 additions & 21 deletions tests/data/cifar_10/source/keras_cnn_cifar_10.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,12 @@
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
# ANY KIND, either express or implied. See the License for the specific
# language governing permissions and limitations under the License.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os
from __future__ import absolute_import, division, print_function

import tensorflow as tf
from tensorflow.python.keras.layers import InputLayer, Conv2D, Activation, MaxPooling2D, Dropout, Flatten, Dense
from tensorflow.python.keras.layers import Activation, Conv2D, Dense, Dropout, Flatten, MaxPooling2D
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.optimizers import RMSprop
from tensorflow.python.saved_model.signature_constants import PREDICT_INPUTS
from tensorflow.python.training.rmsprop import RMSPropOptimizer

HEIGHT = 32
WIDTH = 32
Expand All @@ -29,7 +24,7 @@
NUM_DATA_BATCHES = 5
NUM_EXAMPLES_PER_EPOCH_FOR_TRAIN = 10000 * NUM_DATA_BATCHES
BATCH_SIZE = 128
INPUT_TENSOR_NAME = PREDICT_INPUTS
INPUT_TENSOR_NAME = 'inputs_input' # needs to match the name of the first layer + "_input"


def keras_model_fn(hyperparameters):
Expand All @@ -43,10 +38,7 @@ def keras_model_fn(hyperparameters):
"""
model = Sequential()

# TensorFlow Serving default prediction input tensor name is PREDICT_INPUTS.
# We must conform to this naming scheme.
model.add(InputLayer(input_shape=(HEIGHT, WIDTH, DEPTH), name=PREDICT_INPUTS))
model.add(Conv2D(32, (3, 3), padding='same'))
model.add(Conv2D(32, (3, 3), padding='same', name='inputs', input_shape=(HEIGHT, WIDTH, DEPTH)))
model.add(Activation('relu'))
model.add(Conv2D(32, (3, 3)))
model.add(Activation('relu'))
Expand All @@ -67,19 +59,17 @@ def keras_model_fn(hyperparameters):
model.add(Dense(NUM_CLASSES))
model.add(Activation('softmax'))

_model = tf.keras.Model(inputs=model.input, outputs=model.output)

opt = RMSprop(lr=hyperparameters['learning_rate'], decay=hyperparameters['decay'])
opt = RMSPropOptimizer(learning_rate=hyperparameters['learning_rate'], decay=hyperparameters['decay'])

_model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])
model.compile(loss='categorical_crossentropy',
optimizer=opt,
metrics=['accuracy'])

return _model
return model


def serving_input_fn(hyperpameters):
inputs = {PREDICT_INPUTS: tf.placeholder(tf.float32, [None, 32, 32, 3])}
inputs = {INPUT_TENSOR_NAME: tf.placeholder(tf.float32, [None, 32, 32, 3])}
return tf.estimator.export.ServingInputReceiver(inputs, inputs)


Expand Down
2 changes: 1 addition & 1 deletion tests/integ/test_tf_keras.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_keras(sagemaker_session, tf_full_version):
source_dir=script_path,
role='SageMakerRole', sagemaker_session=sagemaker_session,
hyperparameters={'learning_rate': 1e-4, 'decay': 1e-6},
training_steps=500, evaluation_steps=5,
training_steps=50, evaluation_steps=5,
train_instance_count=1, train_instance_type='ml.c4.xlarge',
train_max_run=45 * 60)

Expand Down
4 changes: 2 additions & 2 deletions tests/integ/test_tuner.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def test_tuning_chainer(sagemaker_session):

objective_metric_name = 'Validation-accuracy'
metric_definitions = [
{'Name': 'Validation-accuracy', 'Regex': '\[J1\s+\d\.\d+\s+\d\.\d+\s+\d\.\d+\s+(\d\.\d+)'}]
{'Name': 'Validation-accuracy', 'Regex': r'\[J1\s+\d\.\d+\s+\d\.\d+\s+\d\.\d+\s+(\d\.\d+)'}]

tuner = HyperparameterTuner(estimator, objective_metric_name, hyperparameter_ranges, metric_definitions,
max_jobs=2, max_parallel_jobs=2)
Expand Down Expand Up @@ -327,7 +327,7 @@ def test_attach_tuning_pytorch(sagemaker_session):

with timeout(minutes=TUNING_DEFAULT_TIMEOUT_MINUTES):
objective_metric_name = 'evaluation-accuracy'
metric_definitions = [{'Name': 'evaluation-accuracy', 'Regex': 'Overall test accuracy: (\d+)'}]
metric_definitions = [{'Name': 'evaluation-accuracy', 'Regex': r'Overall test accuracy: (\d+)'}]
hyperparameter_ranges = {'batch-size': IntegerParameter(50, 100)}

tuner = HyperparameterTuner(estimator, objective_metric_name, hyperparameter_ranges, metric_definitions,
Expand Down
6 changes: 3 additions & 3 deletions tests/integ/timeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ def _show_endpoint_logs(endpoint_name, sagemaker_session):
aws_region=sagemaker_session.boto_session.region_name)
logs.list_logs()
except Exception:
LOGGER.exception('Failure occurred while listing cloudwatch log group %s. ' +
'Swallowing exception but printing stacktrace for debugging.', log_group)
LOGGER.exception('Failure occurred while listing cloudwatch log group %s. Swallowing exception but printing '
'stacktrace for debugging.', log_group)


def _cleanup_endpoint_logs(endpoint_name, sagemaker_session):
Expand All @@ -109,5 +109,5 @@ def _cleanup_endpoint_logs(endpoint_name, sagemaker_session):
cwl_client.delete_log_group(logGroupName=log_group)
LOGGER.info('deleted cloudwatch log group: {}'.format(log_group))
except Exception:
LOGGER.exception('Failure occurred while cleaning up cloudwatch log group %s. ' +
LOGGER.exception('Failure occurred while cleaning up cloudwatch log group %s. '
'Swallowing exception but printing stacktrace for debugging.', log_group)