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

Commit 302d0ca

Browse files
author
Lukasz Kaiser
committed
internal merge from github
PiperOrigin-RevId: 160607416
1 parent 0d5422d commit 302d0ca

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

.gitignore

100755100644
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,3 @@
77
# PyPI distribution artificats
88
build/
99
dist/
10-
11-
# Sublime project files
12-
*.sublime-project
13-
*.sublime-workspace
14-

tensor2tensor/data_generators/text_encoder.py

100755100644
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -321,10 +321,10 @@ def bisect(min_val, max_val):
321321
other_subtokenizer = bisect(present_count + 1, max_val)
322322
else:
323323
other_subtokenizer = bisect(min_val, present_count - 1)
324-
if (abs(other_subtokenizer.vocab_size - target_size) <
325-
abs(subtokenizer.vocab_size - target_size)):
326-
return other_subtokenizer
327-
return subtokenizer
324+
if (abs(other_subtokenizer.vocab_size - target_size) <
325+
abs(subtokenizer.vocab_size - target_size)):
326+
return other_subtokenizer
327+
return subtokenizer
328328

329329
return bisect(min_val, max_val)
330330

tensor2tensor/models/common_layers.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,14 @@ def image_augmentation(images, do_colors=False):
135135
def cifar_image_augmentation(images):
136136
"""Image augmentation suitable for CIFAR-10/100.
137137
138-
As described in https://arxiv.org/pdf/1608.06993v3.pdf (page 5)."""
139-
images = tf.image.resize_image_with_crop_or_pad(
140-
images, 40, 40)
138+
As described in https://arxiv.org/pdf/1608.06993v3.pdf (page 5).
139+
140+
Args:
141+
images: a Tensor.
142+
Returns:
143+
Tensor of the same shape as images.
144+
"""
145+
images = tf.image.resize_image_with_crop_or_pad(images, 40, 40)
141146
images = tf.random_crop(images, [32, 32, 3])
142147
images = tf.image.random_flip_left_right(images)
143148
return images

tensor2tensor/utils/data_reader.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ def preprocess(img):
203203
lambda img=inputs: resize(img))
204204
else:
205205
examples["inputs"] = tf.to_int64(resize(inputs))
206-
207206
elif ("image_cifar10" in data_file_pattern
208-
and mode == tf.contrib.learn.ModeKeys.TRAIN):
207+
and mode == tf.contrib.learn.ModeKeys.TRAIN):
209208
examples["inputs"] = common_layers.cifar_image_augmentation(
210209
examples["inputs"])
211-
212210
elif "audio" in data_file_pattern:
213211
# Reshape audio to proper shape
214212
sample_count = tf.to_int32(examples.pop("audio/sample_count"))

0 commit comments

Comments
 (0)