【发布时间】:2020-01-13 18:31:57
【问题描述】:
我对 Tensorflow 比较陌生。我使用 Docker 在本地部署了这个模型,但是我输入的数据没有经过预处理,所以它给了我一个错误。这可能是因为我在创建模型时对模型外的数据进行了预处理?
当我输入数据时,我从部署的 tensorflow/serving 通过 Docker 得到这个错误:
{ "error": "Failed to process element: 0 of \'instances\' list. Error: Invalid argument: JSON Value: \"Hello\" Type: String is not of expected type: float" }
这意味着它需要一个标记化的单词数组,因此,[[32],[1]]。类似的东西。
这是我的模型的样子:
model = tf.keras.Sequential([
tf.keras.layers.Embedding(
vocab_size, embedding_dim, input_length=max_length),
tf.keras.layers.Bidirectional(tf.keras.layers.LSTM(32)),
tf.keras.layers.Dense(128, activation="relu"),
tf.keras.layers.Dense(3, activation="softmax")
])
如何以与初始训练数据相同的方式对数据进行标记和填充,或者如何将该步骤添加到模型中?
【问题讨论】:
标签: python docker tensorflow tensorflow-serving