【问题标题】:when run with tf-tutorials it happened:AttributeError: module 'tensorflow.python.estimator.api.estimator' has no attribute 'SessionRunHook'使用 tf-tutorials 运行时发生:AttributeError: module 'tensorflow.python.estimator.api.estimator' has no attribute 'SessionRunHook'
【发布时间】:2019-04-02 08:34:58
【问题描述】:

当它发生上述错误时,我正在反复阅读有关估计器的 tensorflow 官方教程,而它在 google.colab 中运行正常。

我使用的环境是win10-64bit & tensorflow-gpu==1.12.0 & python==3.6.6。

import tensorflow as tf
import tensorflow.feature_column as fc
import os
import sys
import matplotlib.pyplot as plt
from IPython.display import clear_output
tf.enable_eager_execution()

models_path = os.path.join(os.getcwd(), 'models')
sys.path.append(models_path)

from official.wide_deep import census_dataset
from official.wide_deep import census_main

这是错误信息:

D:\python\python.exe F:/hupnos/PycharmProject/estimator/linear_model.py
Traceback (most recent call last):
  File "F:/hupnos/PycharmProject/estimator/linear_model.py", line 13, in <module>
    from official.wide_deep import census_dataset
  File "F:\hupnos\PycharmProject\estimator\models\official\wide_deep\census_dataset.py", line 31, in <module>
    from official.utils.flags import core as flags_core
  File "F:\hupnos\PycharmProject\estimator\models\official\utils\flags\core.py", line 30, in <module>
    from official.utils.flags import _base
  File "F:\hupnos\PycharmProject\estimator\models\official\utils\flags\_base.py", line 25, in <module>
    from official.utils.logs import hooks_helper
  File "F:\hupnos\PycharmProject\estimator\models\official\utils\logs\hooks_helper.py", line 29, in <module>
    from official.utils.logs import hooks
  File "F:\hupnos\PycharmProject\estimator\models\official\utils\logs\hooks.py", line 28, in <module>
    class ExamplesPerSecondHook(tf.estimator.SessionRunHook):
AttributeError: module 'tensorflow.python.estimator.api.estimator' has no attribute 'SessionRunHook'

【问题讨论】:

  • 有没有人可以帮我解决这个问题。

标签: python tensorflow-estimator


【解决方案1】:

我在 tf 1.12 上得到了同样的结果。 1.13 api 文档确实包含 SessionRunHook

in <module>
    class ExamplesPerSecondHook(tf.estimator.SessionRunHook):
AttributeError: module 'tensorflow.python.estimator.api.estimator' has no attribute 'SessionRunHook'
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.__version__)
1.12.0
>>>

【讨论】:

    猜你喜欢
    • 2022-12-01
    • 1970-01-01
    • 2023-01-12
    • 2022-08-04
    • 2020-03-26
    • 2015-09-26
    • 2020-11-23
    • 2022-08-24
    • 2021-05-28
    相关资源
    最近更新 更多