Przeglądaj źródła

Merge pull request #1031 from tensorflow/update-resnet

Update resnet model README, API calls, and evaluation code
Xin Pan 8 lat temu
rodzic
commit
afb2291b22
3 zmienionych plików z 11 dodań i 6 usunięć
  1. 3 0
      resnet/README.md
  2. 4 2
      resnet/resnet_main.py
  3. 4 4
      resnet/resnet_model.py

+ 3 - 0
resnet/README.md

@@ -93,6 +93,9 @@ bazel-bin/resnet/resnet_main --train_data_path=cifar10/data_batch* \
                              --dataset='cifar10' \
                              --num_gpus=1
 
+# While the model is training, you can also check on its progress using tensorboard:
+tensorboard --logdir=/tmp/resnet_model
+
 # Evaluate the model.
 # Avoid running on the same GPU as the training job at the same time,
 # otherwise, you might run out of memory.

+ 4 - 2
resnet/resnet_main.py

@@ -128,7 +128,6 @@ def evaluate(hps):
 
   best_precision = 0.0
   while True:
-    time.sleep(60)
     try:
       ckpt_state = tf.train.get_checkpoint_state(FLAGS.log_root)
     except tf.errors.OutOfRangeError as e:
@@ -163,13 +162,15 @@ def evaluate(hps):
         tag='Best Precision', simple_value=best_precision)
     summary_writer.add_summary(best_precision_summ, train_step)
     summary_writer.add_summary(summaries, train_step)
-    tf.logging.info('loss: %.3f, precision: %.3f, best precision: %.3f\n' %
+    tf.logging.info('loss: %.3f, precision: %.3f, best precision: %.3f' %
                     (loss, precision, best_precision))
     summary_writer.flush()
 
     if FLAGS.eval_once:
       break
 
+    time.sleep(60)
+
 
 def main(_):
   if FLAGS.num_gpus == 0:
@@ -207,4 +208,5 @@ def main(_):
 
 
 if __name__ == '__main__':
+  tf.logging.set_verbosity(tf.logging.INFO)
   tf.app.run()

+ 4 - 4
resnet/resnet_model.py

@@ -183,8 +183,8 @@ class ResNet(object):
             'moving_variance', params_shape, tf.float32,
             initializer=tf.constant_initializer(1.0, tf.float32),
             trainable=False)
-        tf.histogram_summary(mean.op.name, mean)
-        tf.histogram_summary(variance.op.name, variance)
+        tf.summary.histogram(mean.op.name, mean)
+        tf.summary.histogram(variance.op.name, variance)
       # elipson used to be 1e-5. Maybe 0.001 solves NaN problem in deeper net.
       y = tf.nn.batch_normalization(
           x, mean, variance, beta, gamma, 0.001)
@@ -221,7 +221,7 @@ class ResNet(object):
                      [(out_filter-in_filter)//2, (out_filter-in_filter)//2]])
       x += orig_x
 
-    tf.logging.info('image after unit %s', x.get_shape())
+    tf.logging.debug('image after unit %s', x.get_shape())
     return x
 
   def _bottleneck_residual(self, x, in_filter, out_filter, stride,
@@ -265,7 +265,7 @@ class ResNet(object):
     for var in tf.trainable_variables():
       if var.op.name.find(r'DW') > 0:
         costs.append(tf.nn.l2_loss(var))
-        # tf.histogram_summary(var.op.name, var)
+        # tf.summary.histogram(var.op.name, var)
 
     return tf.multiply(self.hps.weight_decay_rate, tf.add_n(costs))