Skip to content

Commit b144cc0

Browse files
authored
Merge branch 'master' into arpin_billable_seconds
2 parents 7f86d3d + 284c712 commit b144cc0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3560
-336
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,5 @@ examples/tensorflow/distributed_mnist/data
1919
*.iml
2020
doc/_build
2121
**/.DS_Store
22+
venv/
23+
*~

CHANGELOG.rst

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
=========
2+
CHANGELOG
3+
=========
4+
5+
1.0.4
6+
=====
7+
8+
* 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
11+
* feature: Estimators: add support for async fit
12+
* bug-fix: Estimators: fix estimator role expansion
13+
14+
1.0.3
15+
=====
16+
17+
* 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
21+
22+
23+
1.0.2
24+
=====
25+
26+
* feature: Estimators: add support for Amazon FactorizationMachines algorithm
27+
* feature: Session: Correctly handle TooManyBuckets error_code in default_bucket method
28+
* feature: Tests: add training failure tests for TF and MXNet
29+
* feature: Documentation: show how to make predictions against existing endpoint
30+
* feature: Estimators: implement write_spmatrix_to_sparse_tensor to support any scipy.sparse matrix
31+
32+
33+
1.0.1
34+
=====
35+
36+
* api-change: Model: Remove support for 'supplemental_containers' when creating Model
37+
* feature: Documentation: multiple updates
38+
* feature: Tests: ignore tests data in tox.ini, increase timeout for endpoint creation, capture exceptions during endpoint deletion, tests for input-output functions
39+
* feature: Logging: change to describe job every 30s when showing logs
40+
* feature: Session: use custom user agent at all times
41+
* feature: Setup: add travis file
42+
43+
44+
1.0.0
45+
=====
46+
47+
* Initial commit
48+

README.rst

+154-83
Large diffs are not rendered by default.

doc/conf.py

+1-1
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'
21+
version = '1.0.4'
2222
project = u'sagemaker'
2323

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

doc/factorization_machines.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FactorizationMachines
2+
-------------------------
3+
4+
The Amazon SageMaker Factorization Machines algorithm.
5+
6+
.. autoclass:: sagemaker.FactorizationMachines
7+
:members:
8+
:undoc-members:
9+
:show-inheritance:
10+
:inherited-members:
11+
:exclude-members: image, num_factors, predictor_type, epochs, clip_gradient, mini_batch_size, feature_dim, eps, rescale_grad, bias_lr, linear_lr, factors_lr, bias_wd, linear_wd, factors_wd, bias_init_method, bias_init_scale, bias_init_sigma, bias_init_value, linear_init_method, linear_init_scale, linear_init_sigma, linear_init_value, factors_init_method, factors_init_scale, factors_init_sigma, factors_init_value
12+
13+
14+
.. autoclass:: sagemaker.FactorizationMachinesModel
15+
:members:
16+
:undoc-members:
17+
:show-inheritance:
18+
19+
.. autoclass:: sagemaker.FactorizationMachinesPredictor
20+
:members:
21+
:undoc-members:
22+
:show-inheritance:

doc/index.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ A managed environment for TensorFlow training and hosting on Amazon SageMaker
3838

3939
SageMaker First-Party Algorithms
4040
--------------------------------
41-
Amazon provides implementations of some common machine learning algortithms optimized for GPU archicture and massive datasets.
41+
Amazon provides implementations of some common machine learning algortithms optimized for GPU architecture and massive datasets.
4242

4343
.. toctree::
4444
:maxdepth: 2
4545

4646
kmeans
4747
pca
4848
linear_learner
49+
sagemaker.amazon.amazon_estimator
50+
factorization_machines
51+
lda
52+
ntm

doc/lda.rst

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
LDA
2+
--------------------
3+
4+
The Amazon SageMaker LDA algorithm.
5+
6+
.. autoclass:: sagemaker.LDA
7+
:members:
8+
:undoc-members:
9+
:show-inheritance:
10+
:inherited-members:
11+
:exclude-members: image, num_topics, alpha0, max_restarts, max_iterations, mini_batch_size, feature_dim, tol
12+
13+
14+
.. autoclass:: sagemaker.LDAModel
15+
:members:
16+
:undoc-members:
17+
:show-inheritance:
18+
19+
.. autoclass:: sagemaker.LDAPredictor
20+
:members:
21+
:undoc-members:
22+
:show-inheritance:

doc/ntm.rst

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
NTM
2+
--------------------
3+
4+
The Amazon SageMaker NTM algorithm.
5+
6+
.. autoclass:: sagemaker.NTM
7+
:members:
8+
:undoc-members:
9+
:show-inheritance:
10+
:inherited-members:
11+
:exclude-members: image, num_topics, encoder_layers, epochs, encoder_layers_activation, optimizer, tolerance,
12+
num_patience_epochs, batch_norm, rescale_gradient, clip_gradient, weight_decay, learning_rate
13+
14+
15+
.. autoclass:: sagemaker.NTMModel
16+
:members:
17+
:undoc-members:
18+
:show-inheritance:
19+
20+
.. autoclass:: sagemaker.NTMPredictor
21+
:members:
22+
:undoc-members:
23+
:show-inheritance:

examples/cli/host/data/model.json

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
{
2+
"nodes": [
3+
{
4+
"op": "null",
5+
"name": "data",
6+
"inputs": []
7+
},
8+
{
9+
"op": "null",
10+
"name": "sequential0_dense0_weight",
11+
"attr": {
12+
"__dtype__": "0",
13+
"__lr_mult__": "1.0",
14+
"__shape__": "(128, 0)",
15+
"__wd_mult__": "1.0"
16+
},
17+
"inputs": []
18+
},
19+
{
20+
"op": "null",
21+
"name": "sequential0_dense0_bias",
22+
"attr": {
23+
"__dtype__": "0",
24+
"__init__": "zeros",
25+
"__lr_mult__": "1.0",
26+
"__shape__": "(128,)",
27+
"__wd_mult__": "1.0"
28+
},
29+
"inputs": []
30+
},
31+
{
32+
"op": "FullyConnected",
33+
"name": "sequential0_dense0_fwd",
34+
"attr": {"num_hidden": "128"},
35+
"inputs": [[0, 0, 0], [1, 0, 0], [2, 0, 0]]
36+
},
37+
{
38+
"op": "Activation",
39+
"name": "sequential0_dense0_relu_fwd",
40+
"attr": {"act_type": "relu"},
41+
"inputs": [[3, 0, 0]]
42+
},
43+
{
44+
"op": "null",
45+
"name": "sequential0_dense1_weight",
46+
"attr": {
47+
"__dtype__": "0",
48+
"__lr_mult__": "1.0",
49+
"__shape__": "(64, 0)",
50+
"__wd_mult__": "1.0"
51+
},
52+
"inputs": []
53+
},
54+
{
55+
"op": "null",
56+
"name": "sequential0_dense1_bias",
57+
"attr": {
58+
"__dtype__": "0",
59+
"__init__": "zeros",
60+
"__lr_mult__": "1.0",
61+
"__shape__": "(64,)",
62+
"__wd_mult__": "1.0"
63+
},
64+
"inputs": []
65+
},
66+
{
67+
"op": "FullyConnected",
68+
"name": "sequential0_dense1_fwd",
69+
"attr": {"num_hidden": "64"},
70+
"inputs": [[4, 0, 0], [5, 0, 0], [6, 0, 0]]
71+
},
72+
{
73+
"op": "Activation",
74+
"name": "sequential0_dense1_relu_fwd",
75+
"attr": {"act_type": "relu"},
76+
"inputs": [[7, 0, 0]]
77+
},
78+
{
79+
"op": "null",
80+
"name": "sequential0_dense2_weight",
81+
"attr": {
82+
"__dtype__": "0",
83+
"__lr_mult__": "1.0",
84+
"__shape__": "(10, 0)",
85+
"__wd_mult__": "1.0"
86+
},
87+
"inputs": []
88+
},
89+
{
90+
"op": "null",
91+
"name": "sequential0_dense2_bias",
92+
"attr": {
93+
"__dtype__": "0",
94+
"__init__": "zeros",
95+
"__lr_mult__": "1.0",
96+
"__shape__": "(10,)",
97+
"__wd_mult__": "1.0"
98+
},
99+
"inputs": []
100+
},
101+
{
102+
"op": "FullyConnected",
103+
"name": "sequential0_dense2_fwd",
104+
"attr": {"num_hidden": "10"},
105+
"inputs": [[8, 0, 0], [9, 0, 0], [10, 0, 0]]
106+
}
107+
],
108+
"arg_nodes": [0, 1, 2, 5, 6, 9, 10],
109+
"node_row_ptr": [
110+
0,
111+
1,
112+
2,
113+
3,
114+
4,
115+
5,
116+
6,
117+
7,
118+
8,
119+
9,
120+
10,
121+
11,
122+
12
123+
],
124+
"heads": [[11, 0, 0]],
125+
"attrs": {"mxnet_version": ["int", 1100]}
126+
}

examples/cli/host/data/model.params

428 KB
Binary file not shown.
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
sagemaker mxnet host --role-name <your-sagemaker-execution-role>

examples/cli/host/script.py

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from __future__ import print_function
2+
3+
import json
4+
import mxnet as mx
5+
from mxnet import gluon
6+
7+
8+
def model_fn(model_dir):
9+
"""
10+
Load the gluon model. Called once when hosting service starts.
11+
12+
:param: model_dir The directory where model files are stored.
13+
:return: a model (in this case a Gluon network)
14+
"""
15+
symbol = mx.sym.load('%s/model.json' % model_dir)
16+
outputs = mx.symbol.softmax(data=symbol, name='softmax_label')
17+
inputs = mx.sym.var('data')
18+
param_dict = gluon.ParameterDict('model_')
19+
net = gluon.SymbolBlock(outputs, inputs, param_dict)
20+
net.load_params('%s/model.params' % model_dir, ctx=mx.cpu())
21+
return net
22+
23+
24+
def transform_fn(net, data, input_content_type, output_content_type):
25+
"""
26+
Transform a request using the Gluon model. Called once per request.
27+
28+
:param net: The Gluon model.
29+
:param data: The request payload.
30+
:param input_content_type: The request content type.
31+
:param output_content_type: The (desired) response content type.
32+
:return: response payload and content type.
33+
"""
34+
# we can use content types to vary input/output handling, but
35+
# here we just assume json for both
36+
parsed = json.loads(data)
37+
nda = mx.nd.array(parsed)
38+
output = net(nda)
39+
prediction = mx.nd.argmax(output, axis=1)
40+
response_body = json.dumps(prediction.asnumpy().tolist())
41+
return response_body, output_content_type
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from mxnet import gluon
2+
3+
4+
def download_training_data():
5+
gluon.data.vision.MNIST('./data/training', train=True)
6+
gluon.data.vision.MNIST('./data/training', train=False)
7+
8+
9+
if __name__ == "__main__":
10+
download_training_data()
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"batch_size": 100,
3+
"epochs": 10,
4+
"learning_rate": 0.1,
5+
"momentum": 0.9,
6+
"log_interval": 100
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
python ./download_training_data.py
4+
sagemaker mxnet train --role-name <your-sagemaker-execution-role>

0 commit comments

Comments
 (0)