작성
·
1K
0
from __future__ import absolute_import, division, print_function, unicode_literals
import numpy as np
import tensorflow as tf
import tensorflow_hub as hub
import tensorflow_datasets as tfds
train_validation_split = tfds.Split.TRAIN.subsplit([6, 4])
(train_data, validation_data), test_data = tfds.load(
name="imdb_reviews",
split=(train_validation_split, tfds.Split.TEST),
as_supervised=True)
print("Version: ", tf.__version__)
print("Eager mode: ", tf.executing_eagerly())
print("Hub version: ", hub.__version__)
print("GPU is", "available" if tf.config.experimental.list_physical_devices("GPU") else "NOT AVAILABLE")
Version: 2.0.0 Eager mode: True Hub version: 0.7.0 GPU is NOT AVAILABLE
다음과 같은 에러가 납니다.
--------------------------------------------------------------------------- AssertionError Traceback (most recent call last) <ipython-input-6-55c5f5ff433f> in <module> 6 name="imdb_reviews", 7 split=(train_validation_split, tfds.Split.TEST), ----> 8 as_supervised=True) ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs) 50 _check_no_positional(fn, args, ismethod, allowed=allowed) 51 _check_required(fn, kwargs) ---> 52 return fn(*args, **kwargs) 53 54 return disallow_positional_args_dec(wrapped) # pylint: disable=no-value-for-parameter ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\registered.py in load(name, split, data_dir, batch_size, in_memory, shuffle_files, download, as_supervised, decoders, read_config, with_info, builder_kwargs, download_and_prepare_kwargs, as_dataset_kwargs, try_gcs) 316 as_dataset_kwargs.setdefault("read_config", read_config) 317 --> 318 ds = dbuilder.as_dataset(**as_dataset_kwargs) 319 if with_info: 320 return ds, dbuilder.info ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\api_utils.py in disallow_positional_args_dec(fn, instance, args, kwargs) 50 _check_no_positional(fn, args, ismethod, allowed=allowed) 51 _check_required(fn, kwargs) ---> 52 return fn(*args, **kwargs) 53 54 return disallow_positional_args_dec(wrapped) # pylint: disable=no-value-for-parameter ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in as_dataset(self, split, batch_size, shuffle_files, decoders, read_config, as_supervised, in_memory) 474 in_memory=in_memory, 475 ) --> 476 datasets = utils.map_nested(build_single_dataset, split, map_tuple=True) 477 return datasets 478 ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in map_nested(function, data_struct, dict_only, map_tuple) 151 if isinstance(data_struct, tuple(types)): 152 mapped = [map_nested(function, v, dict_only, map_tuple) --> 153 for v in data_struct] 154 if isinstance(data_struct, list): 155 return mapped ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in <listcomp>(.0) 151 if isinstance(data_struct, tuple(types)): 152 mapped = [map_nested(function, v, dict_only, map_tuple) --> 153 for v in data_struct] 154 if isinstance(data_struct, list): 155 return mapped ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in map_nested(function, data_struct, dict_only, map_tuple) 151 if isinstance(data_struct, tuple(types)): 152 mapped = [map_nested(function, v, dict_only, map_tuple) --> 153 for v in data_struct] 154 if isinstance(data_struct, list): 155 return mapped ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in <listcomp>(.0) 151 if isinstance(data_struct, tuple(types)): 152 mapped = [map_nested(function, v, dict_only, map_tuple) --> 153 for v in data_struct] 154 if isinstance(data_struct, list): 155 return mapped ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in map_nested(function, data_struct, dict_only, map_tuple) 157 return tuple(mapped) 158 # Singleton --> 159 return function(data_struct) 160 161 ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in _build_single_dataset(self, split, shuffle_files, batch_size, decoders, read_config, as_supervised, in_memory) 542 shuffle_files=shuffle_files, 543 decoders=decoders, --> 544 read_config=read_config, 545 ) 546 ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\dataset_builder.py in _as_dataset(self, split, decoders, read_config, shuffle_files) 899 split_infos=self.info.splits.values(), 900 read_config=read_config, --> 901 shuffle_files=shuffle_files, 902 ) 903 else: ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\tfrecords_reader.py in read(self, name, instructions, split_infos, read_config, shuffle_files) 244 name2len=name2len, name2shard_lengths=name2shard_lengths, 245 shuffle_files=shuffle_files) --> 246 datasets = utils.map_nested(read_instruction, instructions, map_tuple=True) 247 return datasets 248 ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\utils\py_utils.py in map_nested(function, data_struct, dict_only, map_tuple) 157 return tuple(mapped) 158 # Singleton --> 159 return function(data_struct) 160 161 ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\tfrecords_reader.py in _read_single_instruction(instruction, parse_fn, read_config, name, path, name2len, name2shard_lengths, shuffle_files) 138 """ 139 if not isinstance(instruction, ReadInstruction): --> 140 instruction = ReadInstruction.from_spec(instruction) 141 absolute_instructions = instruction.to_absolute(name2len) 142 files = list(itertools.chain.from_iterable([ ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\tfrecords_reader.py in from_spec(cls, spec) 436 if not subs: 437 raise AssertionError('No instructions could be built out of %s' % spec) --> 438 instruction = _str_to_relative_instruction(subs[0]) 439 return sum([_str_to_relative_instruction(sub) for sub in subs[1:]], 440 instruction) ~\Anaconda3\envs\jhsong37\lib\site-packages\tensorflow_datasets\core\tfrecords_reader.py in _str_to_relative_instruction(spec) 277 res = _SUB_SPEC_RE.match(spec) 278 if not res: --> 279 raise AssertionError('Unrecognized instruction format: %s' % spec) 280 unit = '%' if res.group('from_pct') or res.group('to_pct') else 'abs' 281 return ReadInstruction( AssertionError: Unrecognized instruction format: NamedSplit('train')(tfds.percent[0:60])
답변 1
0
안녕하세요?
일단 해당코드가 다른 머신에서는 정상적으로 작동하고 있습니다.
그럼 사용하시는 머신에 텐서플로우 라이브러리 설치를 일단 의심해 볼 수 있습니다.
AssertionError: Unrecognized instruction format: NamedSplit('train')(tfds.percent[0:60])
일간 tensorflow_datasets 에서 에러가 발생하므로
pip uninstall tensorflow-datasets하고
다시 pip install tensorflow-datasets 하여 설치 후
머신을 재부팅하고 실행해 보세요.
문제가 해결되시길 바랍니다.
감사합니다.