ososkp / tf-image-classifier

0 stars 0 forks source link

Add AUC as metric #2

Open ososkp opened 4 years ago

ososkp commented 4 years ago

Rather than accuracy

ososkp commented 4 years ago

https://www.tensorflow.org/api_docs/python/tf/keras/metrics/AUC

https://stackoverflow.com/questions/41032551/how-to-compute-receiving-operating-characteristic-roc-and-auc-in-keras

https://www.kaggle.com/c/invasive-species-monitoring/discussion/32762

For TF1 but may come in handy:

import tensorflow as tf
from keras import backend as K

def auc(y_true, y_pred):
    auc = tf.metrics.auc(y_true, y_pred)[1]
    K.get_session().run(tf.local_variables_initializer())
    return auc

model.compile(loss="binary_crossentropy", optimizer='adam', metrics=[auc])