我正在尝试通过Java Tensorflow API启动用Keras Tensorflow训练的图。除了标准输入图像占位符外,这个图包含一个'keras_learning_phase'占位符,需要用一个布尔值来填充。然而,在TensorFlowInferenceInterface中没有提供给boolean值的方法,你只能使用float、double、int或byte值进行填充。
很明显,当我尝试通过以下代码向该张量传递int时:
很明显,当我尝试通过以下代码向该张量传递int时:
inferenceInterface.fillNodeInt("keras_learning_phase",
new int[]{1}, new int[]{0});
我得到了
tensorflow_inference_jni.cc:207 推理过程中发生错误:内部错误: 与节点 _recv_keras_learning_phase_0 相关的类型为 int32 的输出与已声明的 bool 类型的输出不匹配, recv_device="/job:localhost/replica:0/task:0/cpu:0", send_device="/job:localhost/replica:0/task:0/cpu:0", send_device_incarnation=4742451733276497694, tensor_name="keras_learning_phase", tensor_type=DT_BOOL, _device="/job:localhost/replica:0/task:0/cpu:0"
有没有办法规避这个问题?
也许可以将图中的 Placeholder 节点显式转换为 Constant ,这样做可以解决问题吗?
或者最初就避免在图中创建此 Placeholder 节点?