【问题标题】:ImportError: cannot import name 'testing' from 'tensorflow_datasets'ImportError:无法从“tensorflow_datasets”导入名称“testing”
【发布时间】:2020-07-22 03:56:45
【问题描述】:

我无法将 tensorflow_datasets 模块导入我的 jupyter notebook 以进行深度学习。

import tensorflow as tf
import matplotlib.pyplot as plt
import tensorflow_hub as hub

这是我得到错误的那一行:

import tensorflow_datasets as tfds

ImportError: cannot import name 'testing' from 'tensorflow_datasets' (C:\Users\visha\Anaconda3\lib\site-packages\tensorflow_datasets_init_.py)

【问题讨论】:

  • 能否提供更多细节,例如版本等?
  • @AdityaMishra tensorflow 版本 2.0.0 和 python 版本 3.7.3

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


【解决方案1】:

Tensorflow Datasets(TFDS) 的安装似乎存在问题。要安装和使用 TFDS,您应该以 getting started guide 开头。

要使用TensorFlow Datasets >=4.0.0,它需要TensorFlow版本>= 2.1.0。

对于TF 2.0,兼容的TFDS <=3.2.1。您可以卸载现有的 TFDS 并安装所需的版本,如下所示

!pip install tensorflow-datasets==3.2.1

import tensorflow as tf
print(tf.__version__)
import matplotlib.pyplot as plt
import tensorflow_hub as hub
import tensorflow_datasets as tfds
print(tfds.__version__)

输出:

2.0.0
3.2.1

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-22
    • 2021-06-30
    • 2020-10-19
    • 2018-08-13
    • 2015-01-26
    • 2020-10-10
    • 2020-02-12
    • 2021-11-27
    相关资源
    最近更新 更多