简体   繁体   中英

ImportError: cannot import name 'testing' from 'tensorflow_datasets'

I'm unable to import tensorflow_datasets module into my jupyter notebook to do some deep learning on.

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

This is the line where I get the error:

import tensorflow_datasets as tfds

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

It seems there was an issue in installation of Tensorflow Datasets(TFDS). To install and use TFDS you should start with getting started guide .

To use TensorFlow Datasets >=4.0.0 it requires TensorFlow version >= 2.1.0 .

For TF 2.0 , the compatible TFDS <=3.2.1 . You can uninstall existing TFDS and install required version as shown below

!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__)

Output:

2.0.0
3.2.1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM