How to Caculate AUC Value in TensorFlow

AUC value is a metrics to estimate your model, more better, more bigger of its value

Here is an example to caculate it.

auc_value, auc_op = tf.metrics.auc(y_, y)

y_: true value,like [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]

y: the predict value

with tf.Session() as sess:
    sess.run(init)
    sess.run(init_local)
    for _ in range(1000):
        try:
            batch_xs, batch_ys = mnist.train.next_batch(100) #ndarray           
            sess.run(train_step, feed_dict = {x: batch_xs, y_ : batch_ys})
            
            if _ % 5 == 0:
                print('Test', _, sess.run([accuracy, auc_value, auc_op], feed_dict = {x: mnist.test.images, y_ : mnist.test.labels}))
        except Exception as e:
            print e
            pass

The resut is:

('Test', 975, [0.9094, 0.9889064, 0.98890686])
('Test', 980, [0.913, 0.98890686, 0.98891836])
('Test', 985, [0.9157, 0.98891836, 0.98893])
('Test', 990, [0.904, 0.98893, 0.9889345])
('Test', 995, [0.901, 0.9889345, 0.9889386])

,