title: How to use TensorBoard and summary operations with the tf.layers module
body: <p>I have followed the <a href="https://www.tensorflow.org/tutorials/layers" rel="nofollow noreferrer">TensorFlow Layers tutorial</a> to create a CNN for MNIST digit classification using TensorFlow's tf.layers module. Now I'm trying to learn how to use TensorBoard from <a href="https://www.tensorflow.org/programmers_guide/summaries_and_tensorboard" rel="nofollow noreferrer">TensorBoard: Visualizing Learning</a>. Perhaps this tutorial hasn't been updated recently, because it says its example code is a modification of that tutorial's and links to it, but the code is completely different: it manually defines a single-hidden-layer fully-connected network.</p>
  
  <p>The TensorBoard tutorial shows how to use tf.summary to attach summaries to a layer by creating operations on the layer's weights tensor, which is directly accessible because we manually defined the layer, and attaching tf.summary objects to those operations. To do this if I'm using tf.layers and its tutorial code, I believe I'd have to:</p>
  
  <ol>
  <li>Modify the Layers tutorial's example code to use the non-functional interface (Conv2D instead of conv2d and Dense instead of dense) to create the layers</li>
  <li>Use the layer objects' trainable_weights() functions to get the weight tensors and attach tf.summary objects to those</li>
  </ol>
  
  <p>Is that the best way to use TensorBoard with tf.layers, or is there a way that's more directly compatible with tf.layers and the functional interface? If so, is there an updated official TensorBoard tutorial? It would be nice if the documentation and tutorials were more unified. </p>