【问题标题】:AttributeError: module 'tensorflow.io' has no attribute 'experimental'AttributeError:模块 'tensorflow.io' 没有属性 'experimental'
【发布时间】:2020-09-22 09:12:17
【问题描述】:

我正在尝试从 tensorflow 调用一个函数来解码 tiff 图像,同时我在 kaggle 笔记本上运行笔记本并在这一行中:

img = tfio.experimental.image.decode_tiff(img, channels=1)

它给了我错误:

AttributeError:在用户代码中:

<ipython-input-5-d30698f56813>:11 load  *
    img = tfio.experimental.image.decode_tiff(img, channels=1)

AttributeError: module 'tensorflow.io' has no attribute 'experimental'

我目前正在像这样导入 tensorflow.io:

import tensorflow.io as tfio

而我当前的版本:print(f"Tensorflow ver. {tf.__version__}")

张量流版本。 2.3.0

【问题讨论】:

    标签: python python-3.x tensorflow tensorflow2.0


    【解决方案1】:

    Tensorflow I/O 不自带Tensorflow,必须通过pip单独安装;来自repo(强调我的):

    TensorFlow I/O 是 TensorFlow 内置支持中提供的文件系统和文件格式的集合。

    而且,它不是那样导入的。

    你应该做的是通过pip安装它:

    !pip install tensorflow-io
    

    并验证您是否获得了最新版本 v0.15.0,因为它是目前唯一与 TF 2.3 (source) 兼容的版本:

    import tensorflow_io as tfio
    tfio.__version__
    # 0.15.0
    

    注意不同的导入 - tensorflow_io, not tensorflow.io; Github 中的简单用法示例也证明了这一点。

    【讨论】:

      猜你喜欢
      • 2022-08-07
      • 2018-04-14
      • 2019-02-18
      • 1970-01-01
      • 2020-01-01
      • 2019-07-20
      • 2021-11-05
      • 2021-11-04
      相关资源
      最近更新 更多