tensorflow - 尝试通过 Tensorflow Serving 使用 Universal Sentence Encoder Lite/2

标签 tensorflow tensorflow-serving tensorflow-hub

我使用 Universal Sentence Encoder Lite 版本创建了一个 SavedModel。如果我使用 tf.saved_model.loader.load 加载 SavedModel,它工作得很好。

但是,如果我尝试使用 Tensorflow Serving 为模型提供服务,我会收到以下错误:

"error": "indices[3] = 1 is not in [0, 1)\n\t [[Node: lite_module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/GatherV2_1 = GatherV2[Taxis=DT_INT32, Tindices=DT_INT64, Tparams=DT_INT64, _output_shapes=[[?]], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_qsph_v_0_7, lite_module_apply_default/Encoder_en/KonaTransformer/ClipToMaxLength/Reshape, lite_module_apply_default_1/Encoder_en/KonaTransformer/SequenceMask/Const)]]"

为什么会发生这种情况?

python 版本:3.6

tensorflow 版本:1.9.0

tensorflow_hub 版本:0.1.1

使用 tensorflow/serving docker 1.11

最佳答案

我以行格式提供输入张量。通过将输入张量的格式更改为柱状格式,我能够纠正这个问题。可以找到行格式和列格式的详细说明 here .

关于tensorflow - 尝试通过 Tensorflow Serving 使用 Universal Sentence Encoder Lite/2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52955320/

相关文章:

python - 如何在 TensorFlow 中设置矢量化参数的双射器?

java - 用 java 编写的 Tensorflow-serving 客户端没有给出正确的结果

python - 属性错误: module 'tensorflow.python.framework.op_def_registry' has no attribute 'get_registered_ops'

keras - Keras 和 TensorFlow Hub 版 MobileNetV2 的区别

python - 使用 Tensorflow-Hub 中的 ELMo 时内存消耗大幅增加

tensorflow - 在 while_loop 的上下文中使用 TensorArrays 来累积值

python - 警告 :tensorflow:Model was constructed with shape for input Tensor(). 但它在形状不兼容的输入上被调用

python - 加权稀疏分类交叉熵

python - 从数据集 map() 函数调用中生成的图形操作添加 Tensorboard 摘要

tensorflow - 在对象检测 API 中支持 Tensorflow 2.0