-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the Cifar10ImagePreprocessor class to use newer dataset APIs #320
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -858,24 +858,29 @@ def minibatch(self, | |
subset, | ||
params, | ||
shift_ratio=-1): | ||
# TODO(jsimsa): Implement datasets code path | ||
del shift_ratio, params | ||
with tf.name_scope('batch_processing'): | ||
all_images, all_labels = dataset.read_data_files(subset) | ||
all_images = tf.constant(all_images) | ||
all_labels = tf.constant(all_labels) | ||
input_image, input_label = tf.train.slice_input_producer( | ||
[all_images, all_labels]) | ||
input_image = tf.cast(input_image, self.dtype) | ||
input_label = tf.cast(input_label, tf.int32) | ||
# Ensure that the random shuffling has good mixing properties. | ||
input_image = tf.cast(all_images, self.dtype) | ||
input_label = tf.cast(all_labels, tf.int32) | ||
dataset_train = tf.data.Dataset.from_tensor_slices( | ||
(input_image, input_label)) | ||
|
||
min_fraction_of_examples_in_queue = 0.4 | ||
min_queue_examples = int(dataset.num_examples_per_epoch(subset) * | ||
min_fraction_of_examples_in_queue) | ||
raw_images, raw_labels = tf.train.shuffle_batch( | ||
[input_image, input_label], batch_size=self.batch_size, | ||
capacity=min_queue_examples + 3 * self.batch_size, | ||
min_after_dequeue=min_queue_examples) | ||
|
||
dataset_train = dataset_train.shuffle(min_queue_examples).batch( | ||
self.batch_size, drop_remainder=True) | ||
|
||
if tf.VERSION > "1.12": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can safely assume TensorFlow is at least version 1.12. There are branches such as |
||
raw_images, raw_labels = tf.compat.v1.data.make_one_shot_iterator( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No need for |
||
dataset_train).get_next() | ||
else: | ||
raw_images, raw_labels = dataset_train.make_one_shot_iterator( | ||
).get_next() | ||
|
||
images = [[] for i in range(self.num_splits)] | ||
labels = [[] for i in range(self.num_splits)] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should call
.repeat()
in betweenshuffle
andbatch