(TensorFlow on Windows) ImportError: cannot import name 'model_analyzer'

(TensorFlow on Windows) ImportError: cannot import name 'model_analyzer'

我正在尝试使用以下步骤在 Windows10 中训练 TensorFlow 模型:https://github.com/tensorflow/models/tree/master/attention_ocr#requirements

我已经为 Windows (following this example)

安装了 virtualenv

Windows 无法识别源命令。 Windows 是否需要 virtualenv 命令的额外步骤,或者是否有 source 命令的替代用法?

请注意,后续的 pip 安装命令有效(pip,tensorflow_gpu),但是当我尝试使用 train.py 进行训练时,出现以下错误:

 File "train.py", line 27, in <module>
    from tensorflow.contrib.tfprof import model_analyzer
ImportError: cannot import name 'model_analyzer'

看起来您的 virtualenv 配置正确,但您尝试使用的代码导入 tf.contrib.tfprof,即 not currently (as of TensorFlow 1.2) supported on Windows

但是,由于 tf.contrib.tfprof 仅用于提供分析信息,您应该能够 运行 通过从 train.py 中手动删除以下行来 运行 代码:

  • Line 27: from tensorflow.contrib.tfprof import model_analyzer

...并在 运行 脚本时传递标志 --show_graph_stats=false