我已经在Google Cloud ML Engine上部署了一个模型,但是当我尝试执行预测(我正在使用curl)时,这是我得到的结果:

{"error": "Prediction failed: Error during model execution: AbortionError(code=StatusCode.INVALID_ARGUMENT, details=\"You must feed a value for placeholder tensor 'lstm_1/keras_learning_phase' with dtype bool\n\t [[Node: lstm_1/keras_learning_phase = Placeholder[dtype=DT_BOOL, shape=[], _device=\"/job:localhost/replica:0/task:0/device:CPU:0\"]()]]\")"}

如何精确设置此占位符张量的值?它在json上吗?训练期间必须做些什么吗?正如许多建议所说,我尝试设置K.set_learning_phase(0)但没有成功。

谢谢

最佳答案

让我猜测-您的模型具有批处理规范化层,对吗? :)


  正如许多建议所说,我尝试设置K.set_learning_phase(0)但没有成功。


确实-前几天我碰巧遇到了同样的问题;解决方案是设置

K.set_learning_phase(0)


在初始化(或加载)模型之前-如果稍后在脚本中执行该操作,则该错误会不断弹出...

关于tensorflow - Google ML Engine上的Keras错误:您必须输入占位符张量的值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52151309/

10-12 16:34
查看更多