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

Cannot convert JSON float numbers #1136

Closed
thomasSve opened this issue Oct 11, 2018 · 1 comment
Closed

Cannot convert JSON float numbers #1136

thomasSve opened this issue Oct 11, 2018 · 1 comment
Assignees

Comments

@thomasSve
Copy link

thomasSve commented Oct 11, 2018

Bug Report

System information

  • OS Platform and Distribution: macOS 10
  • TensorFlow Serving installed from (source or binary): Deployed from docker image tensorflow/serving
  • TensorFlow Serving version: 1.11

Describe the problem

I believe there is an issue with how the json numbers are checked

https://github.com/tensorflow/serving/blob/master/tensorflow_serving/util/json_tensor.cc#L210

Example:
curl -X POST http://localhost:8501/v1/models/estimator:predict -H 'cache-control: no-cache' -d '{ "signature_name": "predict", "instances": [{"speed": 0.96 }] }'

returns:
{ "error": "Failed to process element: 0 key: speed of \'instances\' list. Error: Invalid argument: Cannot convert JSON value: 0.96 to float without loss of precision." }


Another example when testing the example in https://www.tensorflow.org/serving/api_rest#example

curl -d '{"instances": [1.0,2.0,5.0]}' -X POST http://localhost:8501/v1/models/half_plus_three:predict

returns fine:
{ "predictions": [3.5, 4.0, 5.5 ]

while changing one of the numbers, for example:
curl -d '{"instances": [1.24,5.0]}' -X POST http://localhost:8501/v1/models/half_plus_three:predict

returns:
{ "error": "Failed to process element: 0 of \'instances\' list. Error: Invalid argument: Cannot convert JSON value: 1.24 to float without loss of precision." }

@netfs netfs self-assigned this Oct 12, 2018
@WarrenZevon
Copy link

I am seeing the same behavior on Windows 10, running Tensorflow Serving through a docker image. HTTP requests return successfully for floating point numbers with less than 2 numbers after the decimal point, but fail with more precision.

The error message returned:
{ "error": "Failed to process element: 0 of 'instances' list. Error: Invalid argument: Cannot convert JSON value: 234.04 to float without loss of precision." }

netfs added a commit to netfs/serving that referenced this issue Oct 23, 2018
Underlying rapidjson::IsLosslessFloat() does not work correctly
(e.g. IsLosslessFloat(0.2) returns false!). We now split the
range check into two parts: one to check if a integral value
can fit in float/double without loss and other part to do usual
decimal compare against the defined limits. The latter is used
for non-integer values.

Fixes tensorflow#1136

PiperOrigin-RevId: 217166796
(cherry picked from commit 01c2fb8)
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

No branches or pull requests

3 participants