本文整理匯總了Python中tensor2tensor.data_generators.generator_utils.generate_dataset_and_shuffle方法的典型用法代碼示例。如果您正苦於以下問題:Python generator_utils.generate_dataset_and_shuffle方法的具體用法?Python generator_utils.generate_dataset_and_shuffle怎麽用?Python generator_utils.generate_dataset_and_shuffle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensor2tensor.data_generators.generator_utils
的用法示例。
在下文中一共展示了generator_utils.generate_dataset_and_shuffle方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, _, task_id=-1):
def generator_eos(nbr_symbols, max_length, nbr_cases):
"""Shift by NUM_RESERVED_IDS and append EOS token."""
for case in self.generator(nbr_symbols, max_length, nbr_cases):
new_case = {}
for feature in case:
new_case[feature] = [
i + text_encoder.NUM_RESERVED_TOKENS for i in case[feature]
] + [text_encoder.EOS_ID]
yield new_case
utils.generate_dataset_and_shuffle(
generator_eos(self.num_symbols, self.train_length, self.train_size),
self.training_filepaths(data_dir, self.num_shards, shuffled=True),
generator_eos(self.num_symbols, self.dev_length, self.dev_size),
self.dev_filepaths(data_dir, 1, shuffled=True),
shuffle=False)
示例2: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
train_paths = self.training_filepaths(
data_dir, self.num_shards, shuffled=False)
dev_paths = self.dev_filepaths(
data_dir, self.num_dev_shards, shuffled=False)
test_paths = self.test_filepaths(
data_dir, self.num_test_shards, shuffled=True)
generator_utils.generate_files(
self.generator(data_dir, tmp_dir, self.TEST_DATASETS), test_paths)
if self.use_train_shards_for_dev:
all_paths = train_paths + dev_paths
generator_utils.generate_files(
self.generator(data_dir, tmp_dir, self.TRAIN_DATASETS), all_paths)
generator_utils.shuffle_dataset(all_paths)
else:
generator_utils.generate_dataset_and_shuffle(
self.generator(data_dir, tmp_dir, self.TRAIN_DATASETS), train_paths,
self.generator(data_dir, tmp_dir, self.DEV_DATASETS), dev_paths)
示例3: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
generator_utils.generate_dataset_and_shuffle(
self.generator(data_dir, tmp_dir, True),
self.training_filepaths(data_dir, self.train_shards, shuffled=False),
self.generator(data_dir, tmp_dir, False),
self.dev_filepaths(data_dir, self.dev_shards, shuffled=False))
示例4: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
generator_utils.generate_dataset_and_shuffle(
tabbed_parsing_token_generator(data_dir, tmp_dir, True, "ice",
self.source_vocab_size,
self.targeted_vocab_size),
self.training_filepaths(data_dir, self.num_shards, shuffled=False),
tabbed_parsing_token_generator(data_dir, tmp_dir, False, "ice",
self.source_vocab_size,
self.targeted_vocab_size),
self.dev_filepaths(data_dir, 1, shuffled=False))
示例5: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
"""Generates LSUN bedrooms dataset and writes it in data_dir."""
generator_utils.generate_dataset_and_shuffle(
self.read_and_convert_to_png(tmp_dir, "train"),
self.training_filepaths(data_dir, 100, shuffled=False),
self.read_and_convert_to_png(tmp_dir, "val"),
self.dev_filepaths(data_dir, 1, shuffled=False))
示例6: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
generator_utils.generate_dataset_and_shuffle(
self.generator(data_dir, tmp_dir, True),
self.training_filepaths(data_dir, self.train_shards, shuffled=True),
self.generator(data_dir, tmp_dir, False),
self.dev_filepaths(data_dir, self.dev_shards, shuffled=True))
示例7: generate_data
# 需要導入模塊: from tensor2tensor.data_generators import generator_utils [as 別名]
# 或者: from tensor2tensor.data_generators.generator_utils import generate_dataset_and_shuffle [as 別名]
def generate_data(self, data_dir, tmp_dir, task_id=-1):
generator_utils.generate_dataset_and_shuffle(
self.generator(data_dir, tmp_dir, problem.DatasetSplit.TRAIN),
self.training_filepaths(data_dir, self.train_shards, shuffled=False),
self.generator(data_dir, tmp_dir, problem.DatasetSplit.EVAL),
self.dev_filepaths(data_dir, self.dev_shards, shuffled=False))