title: How are the new tf.contrib.summary summaries in TensorFlow evaluated?
body: <p>I'm having a bit of trouble understanding the new <a href="https://www.tensorflow.org/api_docs/python/tf/contrib/summary" rel="nofollow noreferrer"><code>tf.contrib.summary</code></a> API. In the old one, it seemed that all one was supposed to do was to run <a href="https://www.tensorflow.org/api_docs/python/tf/summary/merge_all" rel="nofollow noreferrer"><code>tf.summary.merge_all()</code></a> and run that as an op.</p>
  <p>But now we have things like <a href="https://www.tensorflow.org/api_docs/python/tf/contrib/summary/record_summaries_every_n_global_steps" rel="nofollow noreferrer"><code>tf.contrib.summary.record_summaries_every_n_global_steps</code></a>, which can be used like this:</p>
  <pre><code>import tensorflow.contrib.summary as tfsum
  
  summary_writer = tfsum.create_file_writer(logdir, flush_millis=3000)
  summaries = []
  
  # First we create one summary which runs every n global steps
  with summary_writer.as_default(), tfsum.record_summaries_every_n_global_steps(30):
      summaries.append(tfsum.scalar(&quot;train/loss&quot;, loss))
  
  # And then one that runs every single time?
  with summary_writer.as_default(), tfsum.always_record_summaries():
      summaries.append(tfsum.scalar(&quot;train/accuracy&quot;, accuracy))
  
  # Then create an optimizer which uses a global step
  step = tf.create_global_step()
  train = tf.train.AdamOptimizer().minimize(loss, global_step=step)
  </code></pre>
  <p>And now come a few questions:</p>
  <ol>
  <li>If we just run <code>session.run(summaries)</code> in a loop, I assume that the accuracy summary would get written every single time, while the loss one wouldn't, because it only gets written if the global step is divisible by 30?</li>
  <li>Assuming the summaries automatically evaluate their dependencies, I never need to run <code>session.run([accuracy, summaries])</code> but can just run, <code>session.run(summaries)</code> since they have a dependency in the graph, right?</li>
  <li>If 2) is true, can't I just add a control dependency to the training step so that the summaries are written on every train run? Or is this a bad practice?</li>
  <li>Is there any downside to using control dependencies in general for things that are going to be evaluated at the same time anyway?</li>
  <li>Why does <a href="https://www.tensorflow.org/api_docs/python/tf/contrib/summary/scalar" rel="nofollow noreferrer"><code>tf.contrib.summary.scalar</code></a> (and others) take in a <code>step</code> parameter?</li>
  </ol>
  <p>By adding a control dependency in 3) I mean doing this:</p>
  <pre><code>tf.control_dependencies(summaries):
      train = tf.train.AdamOptimizer().minimize(loss, global_step=step)
  </code></pre>