AttributeError: module 'tensorflow.python.framework.op_def_registry' has no attribute 'get_registered_ops'

AttributeError: module 'tensorflow.python.framework.op_def_registry' has no attribute 'get_registered_ops'

我正在尝试重新训练 inception v3 模型。

然而,我被一个错误卡住了

A​​ttributeError: 模块 'tensorflow.python.framework.op_def_registry' 没有属性 'get_registered_ops'

在 tensorflow_hub native_module.py 文件中。

为什么会出现此错误?

missing_ops = graph_ops - set(op_def_registry.get_registered_ops().keys())

get_registered_ops() 已在最新版本中删除。请务必使用 tensorflow-hub>=0.7.0 来了解 https://github.com/tensorflow/hub/blob/v0.7.0/tensorflow_hub/native_module.py#L50

的黑魔法
  1. 使用 Tensorflow 1.11 或更高版本。但是,不要继续使用 Tensorflow 2.*.
  2. 另外,对于当前最新版本的tensorflow-hub 0.10.0,你需要tf >= 1.15.0。 因此,最好将 1.15.0 <= tf < 2.* 与 tf-hub latest(0.10.0).
  3. 一起使用