{"action":"created","issue":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5914","repository_url":"https://api.github.com/repos/tensorflow/tensorflow","labels_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5914/labels{/name}","comments_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5914/comments","events_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5914/events","html_url":"https://github.com/tensorflow/tensorflow/issues/5914","id":192130428,"number":5914,"title":"No documentation for sending input parameters of request to TensorFlow Serving ","user":{"login":"vasantivmahajan","id":17990840,"avatar_url":"https://avatars.githubusercontent.com/u/17990840?v=3","gravatar_id":"","url":"https://api.github.com/users/vasantivmahajan","html_url":"https://github.com/vasantivmahajan","followers_url":"https://api.github.com/users/vasantivmahajan/followers","following_url":"https://api.github.com/users/vasantivmahajan/following{/other_user}","gists_url":"https://api.github.com/users/vasantivmahajan/gists{/gist_id}","starred_url":"https://api.github.com/users/vasantivmahajan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasantivmahajan/subscriptions","organizations_url":"https://api.github.com/users/vasantivmahajan/orgs","repos_url":"https://api.github.com/users/vasantivmahajan/repos","events_url":"https://api.github.com/users/vasantivmahajan/events{/privacy}","received_events_url":"https://api.github.com/users/vasantivmahajan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-28T22:07:48Z","updated_at":"2016-11-29T17:49:02Z","closed_at":null,"body":"I am running the sample iris program in TensorFlow Serving. Since it is a TF.Learn model, I am exporting the model using the following `classifier.export(export_dir=model_dir,signature_fn=my_classification_signature_fn)`\r\n\r\nand the signature_fn is defined as shown below:\r\n\r\n```\r\ndef my_classification_signature_fn(examples, unused_features, predictions):\r\n  \"\"\"Creates classification signature from given examples and predictions.\r\n  Args:\r\n    examples: `Tensor`.\r\n    unused_features: `dict` of `Tensor`s.\r\n    predictions: `Tensor` or dict of tensors that contains the classes tensor\r\n      as in {'classes': `Tensor`}.\r\n  Returns:\r\n    Tuple of default classification signature and empty named signatures.\r\n  Raises:\r\n    ValueError: If examples is `None`.\r\n  \"\"\"\r\n  if examples is None:\r\n    raise ValueError('examples cannot be None when using this signature fn.')\r\n\r\n  if isinstance(predictions, dict):\r\n    default_signature = exporter.classification_signature(\r\n        examples, classes_tensor=predictions['classes'])\r\n\r\n  else:\r\n\r\n    default_signature = exporter.classification_signature(\r\n        examples, classes_tensor=predictions)\r\n  named_graph_signatures={\r\n        'inputs': exporter.generic_signature({'x_values': examples}),\r\n        'outputs': exporter.generic_signature({'preds': predictions})}    \r\n  return default_signature, named_graph_signatures\r\n```\r\nThe model gets successfully exported using the following piece of code.\r\n\r\nI have created a client which makes real-time predictions using TensorFlow Serving.\r\n\r\nThe following is the code for the client:\r\n\r\n```\r\nflags.DEFINE_string(\"model_dir\", \"/tmp/iris_model_dir\", \"Base directory for output models.\")\r\ntf.app.flags.DEFINE_integer('concurrency', 1,\r\n                            'maximum number of concurrent inference requests')\r\ntf.app.flags.DEFINE_string('server', '', 'PredictionService host:port')\r\n\r\n#connection\r\nhost, port = FLAGS.server.split(':')\r\nchannel = implementations.insecure_channel(host, int(port))\r\nstub = prediction_service_pb2.beta_create_PredictionService_stub(channel)\r\n\r\n\r\n# Classify two new flower samples.\r\nnew_samples = np.array([5.8, 3.1, 5.0, 1.7], dtype=float)\r\n\r\nrequest = predict_pb2.PredictRequest()\r\nrequest.model_spec.name = 'iris'\r\n\r\nrequest.inputs[\"x_values\"].CopyFrom(\r\n        tf.contrib.util.make_tensor_proto(new_samples))\r\n\r\nresult = stub.Predict(request, 10.0)  # 10 secs timeout\r\n```\r\n\r\nHowever, on making the predictions, the following error is displayed:\r\n\r\n`grpc.framework.interfaces.face.face.AbortionError: AbortionError(code=StatusCode.INTERNAL, details=\"Output 0 of type double does not match declared output type string for node _recv_input_example_tensor_0 = _Recv[client_terminated=true, recv_device=\"/job:localhost/replica:0/task:0/cpu:0\", send_device=\"/job:localhost/replica:0/task:0/cpu:0\", send_device_incarnation=2016246895612781641, tensor_name=\"input_example_tensor:0\", tensor_type=DT_STRING, _device=\"/job:localhost/replica:0/task:0/cpu:0\"]()\")`\r\n\r\nHere is the entire stack trace.\r\n![image](https://cloud.githubusercontent.com/assets/17990840/20688020/fac6285a-b58c-11e6-8a93-1fed6d78b8de.png)\r\n\r\nThe iris model is defined in the following manner:\r\n\r\n```\r\n# Specify that all features have real-value data\r\nfeature_columns = [tf.contrib.layers.real_valued_column(\"\", dimension=4)]\r\n\r\n# Build 3 layer DNN with 10, 20, 10 units respectively.\r\nclassifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,\r\n                                            hidden_units=[10, 20, 10],\r\n                                            n_classes=3, model_dir=model_dir)\r\n\r\n# Fit model.\r\nclassifier.fit(x=training_set.data, \r\n               y=training_set.target, \r\n               steps=2000)\r\n```\r\n\r\nCan someone provide some documentation for creating the client program which sends the request to TensorFlow Serving. "},"comment":{"url":"https://api.github.com/repos/tensorflow/tensorflow/issues/comments/263644547","html_url":"https://github.com/tensorflow/tensorflow/issues/5914#issuecomment-263644547","issue_url":"https://api.github.com/repos/tensorflow/tensorflow/issues/5914","id":263644547,"user":{"login":"vasantivmahajan","id":17990840,"avatar_url":"https://avatars.githubusercontent.com/u/17990840?v=3","gravatar_id":"","url":"https://api.github.com/users/vasantivmahajan","html_url":"https://github.com/vasantivmahajan","followers_url":"https://api.github.com/users/vasantivmahajan/followers","following_url":"https://api.github.com/users/vasantivmahajan/following{/other_user}","gists_url":"https://api.github.com/users/vasantivmahajan/gists{/gist_id}","starred_url":"https://api.github.com/users/vasantivmahajan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasantivmahajan/subscriptions","organizations_url":"https://api.github.com/users/vasantivmahajan/orgs","repos_url":"https://api.github.com/users/vasantivmahajan/repos","events_url":"https://api.github.com/users/vasantivmahajan/events{/privacy}","received_events_url":"https://api.github.com/users/vasantivmahajan/received_events","type":"User","site_admin":false},"created_at":"2016-11-29T17:49:02Z","updated_at":"2016-11-29T17:49:02Z","body":"Can someone help me with this?\r\n"}}
{"actor":{"display_login":"vasantivmahajan"}}