Packaging Models


Zip the exported estimator output in your checkpoint directory:

$ ls export/estimator/1560263597/
saved_model.pb variables/
$ zip -r export/estimator

Upload the zipped file to Amazon S3:

$ aws s3 cp s3://my-bucket/

Reference your model in an API:

- kind: api
name: my-api
model_format: tensorflow
model: s3://my-bucket/


Export your trained model to an ONNX model format. An example of an sklearn model being exported to ONNX is shown below:

from sklearn.linear_model import LogisticRegression
from onnxmltools import convert_sklearn
from onnxconverter_common.data_types import FloatTensorType
logreg_model = LogisticRegression(solver="lbfgs", multi_class="multinomial"), y_train)
# Convert to ONNX model format
onnx_model = convert_sklearn(logreg_model, initial_types=[("input", FloatTensorType([1, 4]))])
with open("sklearn.onnx", "wb") as f:

Here are examples of converting models from some of the common ML frameworks to ONNX:

Upload your trained model in ONNX format to Amazon S3:

$ aws s3 cp model.onnx s3://my-bucket/model.onnx

Reference your model in an API:

- kind: api
name: my-api
model: s3://my-bucket/model.onnx
model_format: onnx