How to calculate AUC with tensorflow?

前端 未结 1 1608
攒了一身酷
攒了一身酷 2021-02-06 03:56

I\'ve built a binary classifier using Tensorflow and now I would like to evaluate the classifier using AUC and accuracy.

As far as accuracy is concerned, I can easily d

1条回答
  •  一生所求
    2021-02-06 04:15

    I've found the same issue on github. At the moment, it seems that you also need to run sess.run(tf.initialize_local_variables()) in order to make tf.contrib.metrics.streaming_auc() work. They're working on it.

    Here you have an example demonstrating how you can solve this issue:

    import tensorflow as tf
    
    a = tf.Variable([0.1, 0.5])
    b = tf.Variable([0.2, 0.6])
    
    auc = tf.contrib.metrics.streaming_auc(a, b)
    
    sess = tf.Session()
    sess.run(tf.initialize_all_variables())
    sess.run(tf.initialize_local_variables()) # try commenting this line and you'll get the error
    train_auc = sess.run(auc)
    
    print(train_auc)
    

    0 讨论(0)
提交回复
热议问题