成功解决在部署CNN,RNN等模型出现的ValueError: Tensor Tensor("dense_2/Softmax:0"bug

ValueError: Tensor Tensor(“dense_2/Softmax:0”, shape=(?, 15), dtype=float32) is not an element of this graph.
对于上面的bug,猜测估计是python2.7出现的编码问题。

解决方法:
在加载模型后,首先自定义一条模型可以处理的案例,让模型预测一下,就可以避免上述bug的出现。
具体解决办法如下所述:
test_case = [np.zeros(10)]
test_case = pad_sequences(test_case, maxlen=85, padding=’post’,dtype=’int32’)
model.predict(test_case, verbose=0)

你可能感兴趣的:(自然语言处理,MachineLearning)