From 6063e6062d920cb4b666c29b5c49f37521cf3edc Mon Sep 17 00:00:00 2001 From: Di Zeng Date: Mon, 24 Oct 2016 17:34:53 -0700 Subject: [PATCH 1/2] improved mnist/convolution.py performance by moving the extra nodes fetch with print --- tensorflow/models/image/mnist/convolutional.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tensorflow/models/image/mnist/convolutional.py b/tensorflow/models/image/mnist/convolutional.py index 7630c59c99b..f83404283e5 100644 --- a/tensorflow/models/image/mnist/convolutional.py +++ b/tensorflow/models/image/mnist/convolutional.py @@ -296,11 +296,13 @@ def main(argv=None): # pylint: disable=unused-argument # node in the graph it should be fed to. feed_dict = {train_data_node: batch_data, train_labels_node: batch_labels} - # Run the graph and fetch some of the nodes. - _, l, lr, predictions = sess.run( - [optimizer, loss, learning_rate, train_prediction], - feed_dict=feed_dict) + # Run the optimizer to update weights. + sess.run(optimizer, feed_dict = feed_dict) + # print some extra information once reach the evaluation frequency if step % EVAL_FREQUENCY == 0: + # fetch some extra nodes' data + l, lr, predictions = sess.run([loss, learning_rate, train_prediction], + feed_dict = feed_dict) elapsed_time = time.time() - start_time start_time = time.time() print('Step %d (epoch %.2f), %.1f ms' % From c408796391ce6df2ab35971fe7f868cfac5e74a2 Mon Sep 17 00:00:00 2001 From: DI ZENG Date: Tue, 25 Oct 2016 11:46:37 -0700 Subject: [PATCH 2/2] Minor change to convolutional.py Made consistent with coding guidence. --- tensorflow/models/image/mnist/convolutional.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tensorflow/models/image/mnist/convolutional.py b/tensorflow/models/image/mnist/convolutional.py index f83404283e5..2e5836bda27 100644 --- a/tensorflow/models/image/mnist/convolutional.py +++ b/tensorflow/models/image/mnist/convolutional.py @@ -297,12 +297,12 @@ def main(argv=None): # pylint: disable=unused-argument feed_dict = {train_data_node: batch_data, train_labels_node: batch_labels} # Run the optimizer to update weights. - sess.run(optimizer, feed_dict = feed_dict) + sess.run(optimizer, feed_dict=feed_dict) # print some extra information once reach the evaluation frequency if step % EVAL_FREQUENCY == 0: # fetch some extra nodes' data l, lr, predictions = sess.run([loss, learning_rate, train_prediction], - feed_dict = feed_dict) + feed_dict=feed_dict) elapsed_time = time.time() - start_time start_time = time.time() print('Step %d (epoch %.2f), %.1f ms' %