Skip to content

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

Merged
merged 7 commits into from
Feb 12, 2019

Conversation

laurenyu
Copy link
Contributor

@laurenyu laurenyu commented Feb 9, 2019

Description of changes:

  • The input_fn method signature has an extra arg (model), which causes a confusing error of TypeError: input_fn() missing 1 required positional argument: 'model'.
  • The README also makes no mention of writing a custom transform_fn which has been supported with all versions of our MXNet images.
  • I also made some more wording tweaks along the way.
  • the changes to the README and Sphinx doc should be identical

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.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have updated the changelog with a description of my changes (if appropriate)
  • I have updated any necessary documentation (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@codecov-io
Copy link

codecov-io commented Feb 9, 2019

Codecov Report

Merging #636 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bcb9216...750ea0c. Read the comment docs.

@laurenyu laurenyu requested a review from eslesar-aws February 9, 2019 19:17
@@ -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.
Copy link
Contributor

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."

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:
Copy link
Contributor

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..."

@@ -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.
Copy link
Contributor

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.

eslesar-aws
eslesar-aws previously approved these changes Feb 10, 2019
@@ -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.
Copy link
Contributor

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.

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:
Copy link
Contributor

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.

Copy link
Contributor

@icywang86rui icywang86rui left a comment

Choose a reason for hiding this comment

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

Ship!

@laurenyu laurenyu merged commit c012a0f into aws:master Feb 12, 2019
@laurenyu laurenyu deleted the fix-mxnet-readme branch February 12, 2019 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants