tensorflowのチュートリアルを今勉強しています.
UnicodeDecodeErrorがでて,imdbデータをロードできません.
pythonimport
1import numpy as np 2 3import tensorflow as tf 4import tensorflow_hub as hub 5import tensorflow_datasets as tfds 6 7# Load compressed models from tensorflow_hub 8os.environ["TFHUB_MODEL_LOAD_FORMAT"] = "COMPRESSED" 9 10print("Version: ", tf.__version__) 11print("Eager mode: ", tf.executing_eagerly()) 12print("Hub version: ", hub.__version__) 13print("GPU is", "available" if tf.config.experimental.list_physical_devices("GPU") else "NOT AVAILABLE") 14# Split the training set into 60% and 40%, so we'll end up with 15,000 examples 15# for training, 10,000 examples for validation and 25,000 examples for testing. 16train_data, validation_data, test_data = tfds.load( 17 name="imdb_reviews", 18 split=('train[:60%]', 'train[60%:]', 'test'), 19 as_supervised=True)
上記はサンプルコードそのままです.実行をすると,
python
1UnicodeDecodeError Traceback (most recent call last) 2<ipython-input-2-e1ef7979aab3> in <module> 3 18 name="imdb_reviews", 4 19 split=('train[:60%]', 'train[60%:]', 'test'), 5---> 20 as_supervised=True) 6 7~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs) 8 50 _check_no_positional(fn, args, ismethod, allowed=allowed) 9 51 _check_required(fn, kwargs) 10---> 52 return fn(*args, **kwargs) 11 53 12 54 return disallow_positional_args_dec(wrapped) # pylint: disable=no-value-for-parameter 13 14~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow_datasets\core\registered.py in load(name, split, data_dir, batch_size, in_memory, shuffle_files, download, as_supervised, decoders, with_info, builder_kwargs, download_and_prepare_kwargs, as_dataset_kwargs, try_gcs) 15 298 if download: 16 299 download_and_prepare_kwargs = download_and_prepare_kwargs or {} 17--> 300 dbuilder.download_and_prepare(**download_and_prepare_kwargs) 18 301 19 302 if as_dataset_kwargs is None: 20 21~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs) 22 50 _check_no_positional(fn, args, ismethod, allowed=allowed) 23 51 _check_required(fn, kwargs) 24---> 52 return fn(*args, **kwargs) 25 53 26 54 return disallow_positional_args_dec(wrapped) # pylint: disable=no-value-for-parameter 27 28~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in download_and_prepare(self, download_dir, download_config) 29 305 self.info.size_in_bytes = dl_manager.downloaded_size 30 306 # Write DatasetInfo to disk, even if we haven't computed the statistics. 31--> 307 self.info.write_to_directory(self._data_dir) 32 308 self._log_download_done() 33 309 34 35~\anaconda3\envs\DEEEP\lib\contextlib.py in __exit__(self, type, value, traceback) 36 117 if type is None: 37 118 try: 38--> 119 next(self.gen) 39 120 except StopIteration: 40 121 return False 41 42~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow_datasets\core\file_format_adapter.py in incomplete_dir(dirname) 43 198 try: 44 199 yield tmp_dir 45--> 200 tf.io.gfile.rename(tmp_dir, dirname) 46 201 finally: 47 202 if tf.io.gfile.exists(tmp_dir): 48 49~\anaconda3\envs\DEEEP\lib\site-packages\tensorflow\python\lib\io\file_io.py in rename_v2(src, dst, overwrite) 50 544 """ 51 545 _pywrap_file_io.RenameFile( 52--> 546 compat.as_bytes(src), compat.as_bytes(dst), overwrite) 53 547 54 548 55 56UnicodeDecodeError: 'utf-8' codec can't decode byte 0x83 in position 175: invalid start byte 57
なぜUnicodeDecodeErrorが出るのかが分かりません.
ディレクトリ名が悪いのか,tensorflowのverが悪いのかわかりませんでした.
調べても同様のエラーが出ているという情報は内容でした.
回答1件
あなたの回答
tips
プレビュー