我尝试在https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2的示例中替换graph.pb文件 但是它无法在Andriod中启动并出现错误:
不是有效的TensorFlow图形序列化:NodeDef提到attr'dilations'不在Op name = Conv2D中.
12-16 15:06:24.986 4310-4310/org.tensorflow.demo E/AndroidRuntime: Caused by: java.io.IOException: Not a valid TensorFlow Graph serialization: NodeDef mentions attr 'dilations' not in Opoutput:T; attr=T:type,allowed=[DT_HALF, DT_FLOAT]; attr=strides:list(int); attr=use_cudnn_on_gpu:bool,default=true; attr=padding:string,allowed=["SAME", "VALID"]; attr=data_format:string,default="NHWC",allowed=["NHWC", "NCHW"]>; NodeDef: conv0/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[1, 2, 2, 1], use_cudnn_on_gpu=true](truediv, conv0/W). (Check whether your GraphDef-interpreting binary is up to date with your GraphDef-generating binary.). at org.tensorflow.contrib.android.TensorFlowInferenceInterface.loadGraph(TensorFlowInferenceInterface.java:392)
如何使用正确的Conv2D graphDef生成推理pb文件?
我有同样的问题,并试图遵循上述解决方法.(没有成功)
但后来我重新评估了原来的错误."版本未与Tensorflow匹配"
这导致我(显而易见的)简单的解决方案对我有用.
验证笔记本电脑上使用的Tensorflow版本是否构建1.5.0
在Android版本中设置相同的版本.拍前额....
dependencies { compile 'org.tensorflow:tensorflow-android:1.5.0' }