-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add section about transform_fn and fix input_fn signature in MXNet README #636
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
Conversation
Codecov Report
@@ Coverage Diff @@
## master #636 +/- ##
=======================================
Coverage 92.73% 92.73%
=======================================
Files 71 71
Lines 5437 5437
=======================================
Hits 5042 5042
Misses 395 395 Continue to review full report at Codecov.
|
src/sagemaker/mxnet/README.rst
Outdated
@@ -666,10 +679,29 @@ The ``output_fn`` has the following signature: | |||
def output_fn(prediction, content_type) | |||
|
|||
Where ``prediction`` is the result of invoking ``predict_fn`` and | |||
``content_type`` is the InvokeEndpoint requested response content-type. The function should return a byte array of data serialized to content_type. | |||
``content_type`` is the InvokeEndpoint requested response content type. The function should return a byte array of data serialized to the expected content type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...is the requested response content type for InvokeEndpoint
. The function should return an array of bytes serialized to the expected content type."
src/sagemaker/mxnet/README.rst
Outdated
Using ``transform_fn`` | ||
'''''''''''''''''''''' | ||
|
||
If you would rather not structure your code around the three methods described above, you can also define your own ``transform_fn`` to handle inference requests. This function has the following signature: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"...described above, you can instead define..."
src/sagemaker/mxnet/README.rst
Outdated
@@ -538,29 +538,39 @@ For more information on how to enable MXNet to interact with Amazon Elastic Infe | |||
Model serving | |||
^^^^^^^^^^^^^ | |||
|
|||
After the SageMaker model server has loaded your model, by calling either the default ``model_fn`` or the implementation in your training script, SageMaker will serve your model. Model serving is the process of responding to inference requests, received by SageMaker InvokeEndpoint API calls. The SageMaker MXNet model server breaks request handling into three steps: | |||
After the SageMaker model server has loaded your model, by calling either the default ``model_fn`` or the implementation in your script, SageMaker will serve your model. | |||
Model serving is the process of responding to inference requests, received by SageMaker InvokeEndpoint API calls. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the SageMaker model server loads your model by calling either the default model_fn
or the implementation in your script, SageMaker serves your model.
Model serving is the process of responding to inference requests received by SageMaker InvokeEndpoint API calls.
doc/using_mxnet.rst
Outdated
@@ -563,7 +573,10 @@ The above code-sample shows the three function definitions: | |||
- ``output_fn``: Takes the result of prediction and serializes this | |||
according to the response content type. | |||
|
|||
The SageMaker MXNet model server provides default implementations of these functions. These work with common-content types, and Gluon API and Module API model objects. You can provide your own implementations for these functions in your training script. If you omit any definition then the SageMaker MXNet model server will use its default implementation for that function. | |||
The SageMaker MXNet model server provides default implementations of these functions. | |||
These work with common content types, and Gluon API and Module API model objects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would list the content types we support here.
doc/using_mxnet.rst
Outdated
Using ``transform_fn`` | ||
'''''''''''''''''''''' | ||
|
||
If you would rather not structure your code around the three methods described above, you can instead define your own ``transform_fn`` to handle inference requests. This function has the following signature: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does having transform_fn
override input_fn
, perdict_fn
or output_fn
? Let's make it clear here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ship!
Description of changes:
input_fn
method signature has an extra arg (model
), which causes a confusing error ofTypeError: input_fn() missing 1 required positional argument: 'model'
.transform_fn
which has been supported with all versions of our MXNet images.Merge Checklist
Put an
x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.