Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Revert usage of Datasets API
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 163421122
  • Loading branch information
Ryan Sepassi committed Jul 28, 2017
1 parent 01f245f commit 7c072d7
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions tensor2tensor/utils/data_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import math
import os
import random

# Dependency imports

Expand Down Expand Up @@ -114,17 +113,18 @@ def decode_record(record):
return dict(zip(decode_items, decoded))

with tf.name_scope("examples_in"):
# Read serialized examples using slim parallel_reader.
data_files = tf.contrib.slim.parallel_reader.get_data_files(data_sources)
if training:
random.shuffle(data_files)
dataset = tf.contrib.data.TFRecordDataset(data_files)
num_readers = min(4 if training else 1, len(data_files))
dataset = dataset.map(decode_record, num_threads=num_readers)
if training:
dataset = dataset.shuffle(capacity)
dataset = dataset.repeat(None if training else 1)
it = dataset.make_one_shot_iterator()
return it.get_next()
_, example_serialized = tf.contrib.slim.parallel_reader.parallel_read(
data_sources,
tf.TFRecordReader,
num_epochs=None if training else 1,
shuffle=training,
capacity=2 * capacity,
min_after_dequeue=capacity,
num_readers=num_readers)
return decode_record(example_serialized)


def preprocessing(examples, data_file_pattern, mode):
Expand Down

0 comments on commit 7c072d7

Please sign in to comment.