title: Adding text labels to confusion matrix in Tensorflow for Tensorboard
body: <p>I am customizing the code from Tensorflow's example <a href="https://github.com/tensorflow/hub/blob/master/examples/image_retraining/retrain.py" rel="nofollow noreferrer">retrain.py</a>, to train on my own images by adding additional dense layers, dropouts, momentum Gradient descent etc. </p>
  
  <p>I wanted to add a confusion matrix to Tensorboard so I followed the first answer (Jerod's) from <a href="https://stackoverflow.com/questions/41617463/tensorflow-confusion-matrix-in-tensorboard">this</a> post (I had also tried the second answer but facing some debugging issues) and added a few lines to <code>add_evaluation_step</code> function. So now it looks like :</p>
  
  <pre><code>def add_evaluation_step(result_tensor, ground_truth_tensor):
  
    with tf.name_scope('accuracy'):
      with tf.name_scope('correct_prediction'):
        prediction = tf.argmax(result_tensor, 1)
        correct_prediction = tf.equal(
            prediction, tf.argmax(ground_truth_tensor, 1))
      with tf.name_scope('accuracy'):
        evaluation_step = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
    tf.summary.scalar('accuracy', evaluation_step)
    print('prediction shape :: {}'.format(ground_truth_tensor))
  
    #Add confusion matrix
    batch_confusion = tf.confusion_matrix(tf.argmax(ground_truth_tensor, 1), prediction,
                                               num_classes=7,
                                               name='batch_confusion')
    # Create an accumulator variable to hold the counts
    confusion = tf.Variable( tf.zeros([7,7], 
                                            dtype=tf.int32 ),
                                   name='confusion' )
    # Create the update op for doing a "+=" accumulation on the batch
    confusion_update = confusion.assign( confusion + batch_confusion )
    # Cast counts to float so tf.summary.image renormalizes to [0,255]
    confusion_image = tf.reshape( tf.cast( confusion_update, tf.float32),
                                   [1, 7, 7, 1])
  
    tf.summary.image('confusion',confusion_image)
  
    return evaluation_step, prediction
  </code></pre>
  
  <p>This gives me :
  <a href="https://i.stack.imgur.com/Rv0Nu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Rv0Nu.png" alt="confusion matrix"></a></p>
  
  <p>My question is how can I add the labels to the rows(actual class) and columns(Predicted class). To get something like :</p>
  
  <p><a href="https://i.stack.imgur.com/5g76I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5g76I.png" alt="required confusion matrix"></a></p>