Tensorflow:ImportError无法在retrain.py中导入名称graph_util

Alb*_*ert 1 python tensorflow

我从源代码编译了Tensorflow以使用GPU。我能够成功安装它。它能够成功运行示例mnist convolutional.py脚本。

但是,当我在中执行retrain.py脚本时tensorflow/examples/image_retraining,它会吐出以下错误:

Traceback (most recent call last):
  File "retrain.py", line 70, in <module>
    from tensorflow.python.client import graph_util
ImportError: cannot import name graph_util
Run Code Online (Sandbox Code Playgroud)

带有命令和其他输出:

$ python retrain.py \
--bottleneck_dir=gpu_train/bottlenecks \
--model_dir=inception \
--output_graph=gpu_train/retrained_graph.pb \
--output_labels=gpu_train/retrained_labels.txt \
--image_dir categories
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcuda.dylib locally
I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcurand.dylib locally
Traceback (most recent call last):
  File "retrain.py", line 70, in <module>
    from tensorflow.python.client import graph_util
ImportError: cannot import name graph_util
Run Code Online (Sandbox Code Playgroud)

Oli*_*rot 5

昨天有一次提交,将文件graph_util.pytensorflow.python.client移到tensorflow.python.framework

retrain.py使用import 的旧版本很奇怪from tensorflow.python.client import graph_util,但是也graph_util.py搬了。


无论如何,主版本graph_util.py是最新的(有from tensorflow.python.framework import graph_util),所以你应该得到的最新版本(无需重新编译,只是拉)。