我试图在 https://codelabs.developers.google.com/codelabs/tensorflow-for-poets-2 的例子中替换一个 graph.pb 文件 但它未能在 Andriod 中启动,并出现错误:
Not a valid TensorFlow Graph serialization: NodeDef mentions attr 'dilations' not in 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 Op<name=Conv2D; signature=input:T, filter:T -> output: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'
}
关于android - Tensorflow 移动应用程序 : Not a valid TensorFlow Graph serialization: NodeDef mentions attr 'dilations' not in Op,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47851049/