2

I'm playing with slim.learning.train and want to display the log in the console. According to the source code this is done using tf_logging module :

if 'should_log' in train_step_kwargs:
    if sess.run(train_step_kwargs['should_log']):
      logging.info('global step %d: loss = %.4f (%.2f sec)',
                   np_global_step, total_loss, time_elapsed) 

I can run my training loop but there's no logs in the console. How can I enable it ?

jrabary
  • 2,411
  • 1
  • 28
  • 50
  • tf_logging goes to STDOUT. If your console doesn't capture stdout, you can do it yourself as described here -- http://stackoverflow.com/questions/37898478/is-there-a-way-to-get-tensorflow-tf-print-output-to-appear-in-jupyter-notebook-o/37912925#37912925 – Yaroslav Bulatov Jul 02 '16 at 12:12

1 Answers1

1

tf.logging.info() goes to stderr, not stdout, as mentioned here: https://groups.google.com/a/tensorflow.org/forum/#!msg/discuss/SO_JRts-VIs/JG1x8vOLDAAJ

and i can verify this from my personal experience, having spent several hours twiddling versions of subprocess.Popen()'s parameters, and not capturing the logging. a simple change to stderr=PIPE worked, as in my specific example, which you should be able to generalize to your problem.

training_results = Popen(cmds,shell=False,stderr=PIPE,bufsize=1,executable="python")
for line in iter(training_results.stderr.readline, b''):
  print line
  if line.startswith("INFO:tensorflow:Final test accuracy"):
    tf_final_acc = line
training_results.wait() # wait for the subprocess to exit