Skip to content

Commit b871670

Browse files
authored
Latest changes to the official models (tensorflow#2422)
1 parent 669422c commit b871670

File tree

6 files changed

+15
-6
lines changed

6 files changed

+15
-6
lines changed

official/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
cnn/data
21
MNIST-data
32
labels.txt

official/mnist/convert_to_records.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16-
"""Converts MNIST data to TFRecords file format with Example protos."""
16+
"""Converts MNIST data to TFRecords file format with Example protos.
17+
18+
To read about optimizations that can be applied to the input preprocessing
19+
stage, see: https://www.tensorflow.org/performance/performance_guide#input_pipeline_optimization.
20+
"""
21+
1722
from __future__ import absolute_import
1823
from __future__ import division
1924
from __future__ import print_function

official/mnist/mnist.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def mnist_model(inputs, mode):
9292
if tf.test.is_built_with_cuda():
9393
# When running on GPU, transpose the data from channels_last (NHWC) to
9494
# channels_first (NCHW) to improve performance.
95+
# See https://www.tensorflow.org/performance/performance_guide#data_formats
9596
data_format = 'channels_first'
9697
inputs = tf.transpose(inputs, [0, 3, 1, 2])
9798

official/resnet/cifar10_download_and_extract.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
# limitations under the License.
1414
# ==============================================================================
1515

16-
"""Converts MNIST data to TFRecords file format with Example protos."""
16+
"""Downloads and extracts the binary version of the CIFAR-10 dataset."""
17+
1718
from __future__ import absolute_import
1819
from __future__ import division
1920
from __future__ import print_function

official/resnet/imagenet.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
2828
WARNING: Don't use for object detection, in this case all the bounding boxes
2929
of the image belong to just one class.
30+
31+
To read about optimizations that can be applied to the input preprocessing
32+
stage, see: https://www.tensorflow.org/performance/performance_guide#input_pipeline_optimization.
3033
"""
3134

3235
from __future__ import absolute_import

official/resnet/resnet_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
def batch_norm_relu(inputs, is_training, data_format):
4242
"""Performs a batch normalization followed by a ReLU."""
4343
# We set fused=True for a significant performance boost.
44+
# See https://www.tensorflow.org/performance/performance_guide#common_fused_ops
4445
inputs = tf.layers.batch_normalization(
4546
inputs=inputs, axis=1 if data_format == 'channels_first' else 3,
4647
momentum=_BATCH_NORM_DECAY, epsilon=_BATCH_NORM_EPSILON, center=True,
@@ -240,6 +241,7 @@ def model(inputs, is_training):
240241
if data_format == 'channels_first':
241242
# Convert from channels_last (NHWC) to channels_first (NCHW). This
242243
# provides a large performance boost on GPU.
244+
# See https://www.tensorflow.org/performance/performance_guide#data_formats
243245
inputs = tf.transpose(inputs, [0, 3, 1, 2])
244246

245247
inputs = conv2d_fixed_padding(
@@ -261,14 +263,12 @@ def model(inputs, is_training):
261263
data_format=data_format)
262264

263265
inputs = batch_norm_relu(inputs, is_training, data_format)
264-
265266
inputs = tf.layers.average_pooling2d(
266267
inputs=inputs, pool_size=8, strides=1, padding='VALID',
267268
data_format=data_format)
268269
inputs = tf.identity(inputs, 'final_avg_pool')
269270
inputs = tf.reshape(inputs, [-1, 64])
270-
inputs = tf.layers.dense(
271-
inputs=inputs, units=num_classes)
271+
inputs = tf.layers.dense(inputs=inputs, units=num_classes)
272272
inputs = tf.identity(inputs, 'final_dense')
273273
return inputs
274274

0 commit comments

Comments
 (0)