title: How to use validation monitor in Softmax classifier in tensorflow
body: <p>I just edit the <a href="http://mnist_softmax_classifier" rel="nofollow">https://github.com/tensorflow/tensorflow/blob/r0.10/tensorflow/examples/tutorials/mnist/mnist_softmax.py</a>   to enable logging by using a validation monitor </p>
  
  <pre><code>from __future__ import absolute_import
      from __future__ import division
      from __future__ import print_function
  
      # Import data
      from tensorflow.examples.tutorials.mnist import input_data
  
      import tensorflow as tf
  
      flags = tf.app.flags
      FLAGS = flags.FLAGS
      flags.DEFINE_string('data_dir', '/tmp/data/', 'Directory for storing data')
  
      mnist = input_data.read_data_sets(FLAGS.data_dir, one_hot=True)
  
      sess = tf.InteractiveSession()
  
      # Create the model
      x = tf.placeholder(tf.float32, [None, 784])
      W = tf.Variable(tf.zeros([784, 10]))
      b = tf.Variable(tf.zeros([10]))
      y = tf.nn.softmax(tf.matmul(x, W) + b)
  
      validation_metrics = {"accuracy": tf.contrib.metrics.streaming_accuracy,
                            "precision": tf.contrib.metrics.streaming_precision,
                            "recall": tf.contrib.metrics.streaming_recall}
      validation_monitor = tf.contrib.learn.monitors.ValidationMonitor(
          mnist.test.images,
          mnist.test.labels,
          every_n_steps=50, metrics=validation_metrics,
          early_stopping_metric="loss",
          early_stopping_metric_minimize=True,
          early_stopping_rounds=200)
      # Define loss and optimizer
      y_ = tf.placeholder(tf.float32, [None, 10])
      cross_entropy = tf.reduce_mean(-tf.reduce_sum(y_ * tf.log(y), reduction_indices=[1]))
      train_step = tf.train.GradientDescentOptimizer(0.5).minimize(cross_entropy)
  
      # Train
      tf.initialize_all_variables().run()
      for i in range(1000):
        batch_xs, batch_ys = mnist.train.next_batch(100)
        train_step.run({x: batch_xs, y_: batch_ys})
  
      # Test trained model
      correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))
      accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
      print(accuracy.eval({x: mnist.test.images, y_: mnist.test.labels}))
  </code></pre>
  
  <p>But i am confused how i set  <strong>validation_monitor</strong> in this program. I have learned in  <strong>DNNClassfier</strong> , the validation_monitor is used in the flowwing way </p>
  
  <pre><code># Fit model.
  classifier.fit(x=training_set.data,
                 y=training_set.target,
                 steps=2000, monitors=[validation_monitor])
  </code></pre>
  
  <p>So, how i can use validation_monitor in softmax_classifer? </p>