How to find AUC metric value for keras model? I have wanted to find AUC metric for my Keras model. Keras doesn't have any inbuilt function to measure AUC metric.  So I found that write a function which calculates AUC metric and call this function while compiling Keras model like:

from sklearn import metrics
from keras import backend as K

def auc(y_true, y_pred):
    return metrics.roc_auc_score(K.eval(y_true), K.eval(y_pred))     
model.compile(loss="binary_crossentropy", optimizer='adam',metrics=['auc'])


But this doesn't work in my case. Please help me to figure out this query.

thanks
There is now a built-in function to compute (an approximation of) the AUC. See tf.keras.metrics.AUC. Apparently, you just need to do the following

...
model = tf.keras.Model(inputs, outputs)
model.compile('sgd', loss='mse', metrics=[tf.keras.metrics.AUC()])