Skip to content

Using customized tensor name for prediction after deploying the model #394

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

Closed
vbvg2008 opened this issue Sep 19, 2018 · 4 comments
Closed
Assignees

Comments

@vbvg2008
Copy link

Please fill out the form below.

System Information

  • Framework (e.g. TensorFlow) / Algorithm (e.g. KMeans): TensorFlow
  • Framework Version: 1.10
  • Python Version: 2.7
  • CPU or GPU: GPU
  • Are you using a custom image: No

Describe the problem

All of the Sagemaker tensorflow tutorial uses "inputs" as the input name for prediction. for example, in "tensorflow_resnet_cifar10_with_tensorboard" example, the prediction is simply done by

random_image = np.random.rand(32, 32, 3)
predictor.predict(random_image_data)

but what if I trained a tensorflow model with a customized input name? say my model inputs only accepts a dictionary like this:
inputs = {"input_image": tf.placeholder(tf.float32, [None, 32, 32, 3])}

Although I successfully trained and deployed the model, but when I try to do the prediction such as:

random_image = np.random.rand(32, 32, 3)
predictor.predict({'input_image':random_image})

it gives me error saying my data is not JSON serializable. How do I use a customized name as input name for prediction?

@mvsusp
Copy link
Contributor

mvsusp commented Sep 20, 2018

Hello @vbvg2008 ,

I believe that this issue is related to aws/sagemaker-tensorflow-training-toolkit#71.
We are in the process to release a newer container with these codefixes. I will update you in this ticket when it happens.

Thanks for using SageMaker!

@winstonaws
Copy link
Contributor

@mvsusp The problem is fixed on the container side, but now we need to make a fix to the Python SDK to serialize numpy arrays in dicts correctly.

@vbvg2008 in the meantime, if you want to unblock yourself, try the workaround described here:
aws/sagemaker-tensorflow-training-toolkit#71 (comment)

Basically, convert your numpy arrays into lists before putting them in the dict.

@tlelson
Copy link

tlelson commented Oct 5, 2018

hi @winstonaws,
I am running into an issue that seems like it may be related. I have logged it under issue #413.
If you have any idea on how to coerce my input data into an acceptable format I would very much appreciate it.

@icywang86rui
Copy link
Contributor

hi @eL0ck,

We have merged in a change to accept dicts with numpy arrays on the python sdk side - #404 .
Your original way to do the prediction should work now:

random_image = np.random.rand(32, 32, 3)
predictor.predict({'input_image':random_image})

Please let us know if the problems persists.

apacker pushed a commit to apacker/sagemaker-python-sdk that referenced this issue Nov 15, 2018
Update KMS encryption notebook with steps for batch transformation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants