Skip to content
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

How to support multiple model inputs? #58

Open
iluoyi opened this issue Dec 17, 2018 · 3 comments
Open

How to support multiple model inputs? #58

iluoyi opened this issue Dec 17, 2018 · 3 comments
Labels
type: question Further information is requested

Comments

@iluoyi
Copy link

iluoyi commented Dec 17, 2018

https://github.com/aws/sagemaker-mxnet-container/blob/ee9098c8c2de6a635dcd9f4b0819dc5340061cde/src/sagemaker_mxnet_container/serving.py#L228

If my mxnet model takes 2 data inputs (both are float arrays), how should I make it work at this point?

  • I defined my model-shapes.json like
    [{"shape": [1, 12], "name": "data0"}, {"shape": [1, 12], "name": "data1"}]

  • And one example input looks like:
    data = {'data0':[1.0, 2904.0, 1452.0, 464.0, 3022.0, 2948.0, 2548.0, 2.0, 0.0, 0.0, 0.0, 0.0], 'data1':[1.0, 2204.0, 1552.0, 494.0, 3032.0, 298.0, 2568.0, 2.0, 0.0, 0.0, 0.0, 0.0]}

But I got errors on the server side:

Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/sagemaker_containers/_functions.py", line 84, in wrapper
return fn(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/sagemaker_mxnet_container/serving.py", line 229, in default_input_fn
[data_shape] = self._model.data_shapes

ValueError: too many values to unpack (expected 1)
@laurenyu
Copy link
Contributor

sorry for the delayed response @iluoyi!

We don't natively support multiple inputs in our default hosting functions, but you can override the defaults by providing your own transform_fn in your entry point code.

Here is an example of where we've overridden the default transform_fn: https://github.com/awslabs/amazon-sagemaker-examples/blob/master/sagemaker-python-sdk/mxnet_gluon_mnist/mnist.py#L166-L183. (Unfortunately, I don't think we have an example of a model accepting multiple inputs yet.)

@laurenyu laurenyu added the type: question Further information is requested label Dec 19, 2018
@ZHAO0189
Copy link

same question here. I trained my own model which requires two inputs and deployed it as endpoint. But when I called predict(), the error was "Expects arg[1] to be int32 but float is provided".

@laurenyu
Copy link
Contributor

@ZHAO0189 sorry for the slow response. that sounds like it's likely an issue with your serving entry point code. can you share your inference script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants