1. 程式人生 > 其它 >Pycharm 使用 tensorflow_datasets 錯誤 【Failed to construct dataset ...】

Pycharm 使用 tensorflow_datasets 錯誤 【Failed to construct dataset ...】

技術標籤:TensorFlowpythonpycharmtensorflow

tensorflow-datasets 版本 : 2.1.0

import tensorflow_datasets as tfds

datasets, info = tfds.load('imdb_reviews/subwords8k', with_info=True, as_supervised=True)

報錯:Failed to construct datasetimdb_reviews

增加一行程式碼即可:

_is_gcs_disabled = False

tfds.load( ) 還可以新增的引數:

Some common arguments:

  • split=: Which split to read (e.g.'train',['train', 'test'],'train[80%:]',...). See oursplit API guide.
  • shuffle_files=: Control whether to shuffle the files between each epoch (TFDS store big datasets in multiple smaller files).
  • data_dir=: Location where the dataset is saved ( defaults to~/tensorflow_datasets/
    ),設定下載資料夾,預設為~/tensorflow_datasets/
  • with_info=True: Returns thetfds.core.DatasetInfocontaining dataset metadata
  • download=False: Disable download, 如果本地存在,可以直接讀取,不下載

來源官網:https://www.tensorflow.org/datasets/overview