tfds.load出现TypeError问题

前段时间使用tfds.load("mnist",with-info=True)的时候发现出error了。

信息为:

UnimplementedError                        Traceback (most recent call last)
c:\python37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in try_reraise(*args, **kwargs)
    398   try:
--> 399     yield
    400   except Exception:   # pylint: disable=broad-except

c:\python37\lib\site-packages\tensorflow_datasets\core\registered.py in builder(name, **builder_init_kwargs)
    243       prefix="Failed to construct dataset {}".format(name)):
--> 244     return builder_cls(name)(**builder_kwargs)
    245 

c:\python37\lib\site-packages\wrapt\wrappers.py in __call__(self, *args, **kwargs)
    602             return self._self_wrapper(self.__wrapped__, self._self_instance,
--> 603                     args, kwargs)
    604 

c:\python37\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs)
     68     _check_required(fn, kwargs)
---> 69     return fn(*args, **kwargs)
     70 

c:\python37\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in __init__(self, data_dir, config, version)
    205     else:  # Use the code version (do not restore data)
--> 206       self.info.initialize_from_bucket()
    207 

c:\python37\lib\site-packages\tensorflow_datasets\core\dataset_info.py in initialize_from_bucket(self)
    422     tmp_dir = tempfile.mkdtemp("tfds")
--> 423     data_files = gcs_utils.gcs_dataset_info_files(self.full_name)
    424     if not data_files:

c:\python37\lib\site-packages\tensorflow_datasets\core\utils\gcs_utils.py in gcs_dataset_info_files(dataset_dir)
     69   """Return paths to GCS files in the given dataset directory."""
---> 70   return gcs_listdir(posixpath.join(GCS_DATASET_INFO_DIR, dataset_dir))
     71 

c:\python37\lib\site-packages\tensorflow_datasets\core\utils\gcs_utils.py in gcs_listdir(dir_name)
     62   root_dir = gcs_path(dir_name)
---> 63   if _is_gcs_disabled or not tf.io.gfile.exists(root_dir):
     64     return None

c:\python37\lib\site-packages\tensorflow\python\lib\io\file_io.py in file_exists_v2(path)
    266   try:
--> 267     _pywrap_file_io.FileExists(compat.as_bytes(path))
    268   except errors.NotFoundError:

UnimplementedError: File system scheme 'gs' not implemented (file: 'gs://tfds-data/dataset_info/imdb_reviews/plain_text/1.0.0')

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-36-06930b64f980> in <module>
      1 #tfds.list_builders()
----> 2 imdb, info = tfds.load('imdb_reviews', with_info=True, as_supervised=True)

c:\python37\lib\site-packages\wrapt\wrappers.py in __call__(self, *args, **kwargs)
    562 
    563         return self._self_wrapper(self.__wrapped__, self._self_instance,
--> 564                 args, kwargs)
    565 
    566 class BoundFunctionWrapper(_FunctionWrapperBase):

c:\python37\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs)
     67     _check_no_positional(fn, args, ismethod, allowed=allowed)
     68     _check_required(fn, kwargs)
---> 69     return fn(*args, **kwargs)
     70 
     71   return disallow_positional_args_dec(wrapped)  # pylint: disable=no-value-for-parameter

c:\python37\lib\site-packages\tensorflow_datasets\core\registered.py in load(name, split, data_dir, batch_size, shuffle_files, download, as_supervised, decoders, read_config, with_info, builder_kwargs, download_and_prepare_kwargs, as_dataset_kwargs, try_gcs)
    366     data_dir = constants.DATA_DIR
    367 
--> 368   dbuilder = builder(name, data_dir=data_dir, **builder_kwargs)
    369   if download:
    370     download_and_prepare_kwargs = download_and_prepare_kwargs or {}

c:\python37\lib\site-packages\tensorflow_datasets\core\registered.py in builder(name, **builder_init_kwargs)
    242   with py_utils.try_reraise(
    243       prefix="Failed to construct dataset {}".format(name)):
--> 244     return builder_cls(name)(**builder_kwargs)
    245 
    246 

c:\python37\lib\contextlib.py in __exit__(self, type, value, traceback)
    128                 value = type()
    129             try:
--> 130                 self.gen.throw(type, value, traceback)
    131             except StopIteration as exc:
    132                 # Suppress StopIteration *unless* it's the same exception that

c:\python37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in try_reraise(*args, **kwargs)
    399     yield
    400   except Exception:   # pylint: disable=broad-except
--> 401     reraise(*args, **kwargs)
    402 
    403 

c:\python37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in reraise(prefix, suffix)
    390   suffix = '\n' + suffix if suffix else ''
    391   msg = prefix + str(exc_value) + suffix
--> 392   six.reraise(exc_type, exc_type(msg), exc_traceback)
    393 
    394 

TypeError: __init__() missing 2 required positional arguments: 'op' and 'message'

(错误信息大致如上,有一位stack overflow的朋友也出现和我一样的问题,所以我只复制了他的错误信息,如果侵权那我删掉吧)

这种情况下,我把运行环境win10换成centos7,把tf版本从2.2到2.0都没法解决问题,tfds版本是3.2.0,装了tfds-nightly也没用。这种情况我怀疑是不是tfds本身的lib出现问题还是说别的地方引起什么冲突,苦索无果。

于是考虑有没有可能是tfds的版本问题,我就把tensorflow-datasets的版本从3.2.0换成3.0.0,再利用tfds.load则不出现TypeError了。

pip uninstall tensorflow-datasets
pip install tensorflow-datasets==3.0.0

问题总算是暂时解决了或者有哪位大佬知道是什么原因的,求下面告知……感激不尽!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值