Browse Source

Update resnet to run with tf r0.12 API. (#833)

* Update resnet to run with tf r0.12 API.
1. tf.image.per_image_whitening -> tf.image.per_image_standardization
2. Use tf.summary to replace tf.image_summary, tf.scalar_summary, tf.merge_all_summaries.

* remove log
Wills Cui 8 years ago
parent
commit
22036b6f44
3 changed files with 7 additions and 7 deletions
  1. 2 2
      resnet/cifar_input.py
  2. 2 2
      resnet/resnet_main.py
  3. 3 3
      resnet/resnet_model.py

+ 2 - 2
resnet/cifar_input.py

@@ -84,7 +84,7 @@ def build_input(dataset, data_path, batch_size, mode):
   else:
     image = tf.image.resize_image_with_crop_or_pad(
         image, image_size, image_size)
-    image = tf.image.per_image_whitening(image)
+    image = tf.image.per_image_standardization(image)
 
     example_queue = tf.FIFOQueue(
         3 * batch_size,
@@ -112,5 +112,5 @@ def build_input(dataset, data_path, batch_size, mode):
   assert labels.get_shape()[1] == num_classes
 
   # Display the training images in the visualizer.
-  tf.image_summary('images', images)
+  tf.summary.image('images', images)
   return images, labels

+ 2 - 2
resnet/resnet_main.py

@@ -70,8 +70,8 @@ def train(hps):
   summary_hook = tf.train.SummarySaverHook(
       save_steps=100,
       output_dir=FLAGS.train_dir,
-      summary_op=[model.summaries,
-                  tf.summary.scalar('Precision', precision)])
+      summary_op=tf.summary.merge([model.summaries,
+                                   tf.summary.scalar('Precision', precision)]))
 
   logging_hook = tf.train.LoggingTensorHook(
       tensors={'step': model.global_step,

+ 3 - 3
resnet/resnet_model.py

@@ -59,7 +59,7 @@ class ResNet(object):
     self._build_model()
     if self.mode == 'train':
       self._build_train_op()
-    self.summaries = tf.merge_all_summaries()
+    self.summaries = tf.summary.merge_all()
 
   def _stride_arr(self, stride):
     """Map a stride scalar to the stride array for tf.nn.conv2d."""
@@ -122,12 +122,12 @@ class ResNet(object):
       self.cost = tf.reduce_mean(xent, name='xent')
       self.cost += self._decay()
 
-      tf.scalar_summary('cost', self.cost)
+      tf.summary.scalar('cost', self.cost)
 
   def _build_train_op(self):
     """Build training specific ops for the graph."""
     self.lrn_rate = tf.constant(self.hps.lrn_rate, tf.float32)
-    tf.scalar_summary('learning rate', self.lrn_rate)
+    tf.summary.scalar('learning rate', self.lrn_rate)
 
     trainable_variables = tf.trainable_variables()
     grads = tf.gradients(self.cost, trainable_variables)