Skip to content

Commit

Permalink
fix incorrect cifar data preprocessing code
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent-Xiao committed Mar 9, 2018
1 parent d4f2728 commit 7e49bea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions data.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __read_cifar(filenames, shuffle=True, cifar100=False):
depth_major = tf.reshape(
tf.strided_slice(record_bytes, [label_bytes],
[label_bytes + image_bytes]),
[result.depth, result.height, result.width])
[depth, height, width])
# Convert from [depth, height, width] to [height, width, depth].
image = tf.transpose(depth_major, [1, 2, 0])

Expand Down Expand Up @@ -135,17 +135,15 @@ def generate_batches(self, batch_size, min_queue_examples=1000, num_threads=8):
# Create a queue that shuffles the examples, and then
# read 'batch_size' images + labels from the example queue.

# Set the shapes of tensors.
float_image.set_shape([height, width, 3])
read_input.label.set_shape([1])

# Ensure that the random shuffling has good mixing properties.
min_fraction_of_examples_in_queue = 0.4
min_queue_examples = int(self.size[0] *
min_fraction_of_examples_in_queue)
image, label = self.data
if self.training:
distorted_image=distorted_inputs(image, height=self.size[1], width=self.size[2], normalize=True)
distorted_image.set_shape([self.size[1], self.size[2], 3])
label.set_shape([1])
images, label_batch = tf.train.shuffle_batch(
[distorted_image, label],
batch_size=batch_size,
Expand All @@ -154,6 +152,8 @@ def generate_batches(self, batch_size, min_queue_examples=1000, num_threads=8):
min_after_dequeue=min_queue_examples)
else:
image=distorted_inputs(image, height=self.size[1], width=self.size[2], normalize=True)
image.set_shape([self.size[1], self.size[2], 3])
label.set_shape([1])
images, label_batch = tf.train.batch(
[image, label],
batch_size=batch_size,
Expand Down

0 comments on commit 7e49bea

Please sign in to comment.