Tensorflow 构建量化工具 - bazel 构建错误
Posted
技术标签:
【中文标题】Tensorflow 构建量化工具 - bazel 构建错误【英文标题】:Tensorflow build quantization tool - bazel build error 【发布时间】:2017-03-18 19:40:06 【问题描述】:我正在尝试按照Pete Warden's blog 中的说明编译量化脚本。但是,在运行以下 bazel 构建后,我收到以下错误消息:
bazel build tensorflow/contrib/quantization/tools:quantize_graph
ERROR: no such package 'tensorflow/contrib/quantization/tools': BUILD file not found on package path.
INFO: Elapsed time: 0.277s
【问题讨论】:
【参考方案1】:我认为发生的事情是这个量化工具被移出 contrib 并进入 TensorFlow 核心。您应该可以改用它:
bazel build tensorflow/tools/quantization:quantize_graph
【讨论】:
谢谢。就是这样。 在我得到这个工作之后,下一个命令是:bazel-bin/tensorflow/contrib/quantization/tools/quantize_graph \ --input=/tmp/classify_image_graph_def.pb \ --output_node_names="softmax" --output=/tmp/quantized_graph.pb \ --mode=eightbit
但是我从那里得到这个错误:Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter
。对此有任何想法吗? (我在我的 tensorflow 根目录中运行它)
我认为是同一个原因。试试bazel-bin/tensorflow/tools/quantization/quantize_graph \ --input=/tmp/classify_image_graph_def.pb \ --output_node_names="softmax" --output=/tmp/quantized_graph.pb \ --mode=eightbit
嗯,这就是我正在运行的(我只是从 Pete 的博客中复制了示例,尽管我正在运行 bazel-bin/tensorflow/tools/quantization/quantize_graph),它表明它找到了它并且运行。我得到的错误与 quantize_graph 内部使用的一些 python 代码有关,这里是带有错误消息的完整输出:(下一条评论)
Traceback (most recent call last): File "/home/moazzami/tensorflow/tensorflow/bazel-bin/tensorflow/tools/quantization/quantize_graph.runfiles/org_tensorflow/tensorflow/tools/quantization/quantize_graph.py", line 34, in <module> import tensorflow as tf ...
Error importing tensorflow. Unless you are using bazel, you should not try to import tensorflow from its source directory; please exit the tensorflow source tree, and relaunch your python interpreter from there.
以上是关于Tensorflow 构建量化工具 - bazel 构建错误的主要内容,如果未能解决你的问题,请参考以下文章