Home

Published

- 1 min read

keras auc without tf.metrics.auc

img of keras auc without tf.metrics.auc

The solution for this is noted below

keras auc without tf.metrics.auc

Solution

   import tensorflow as tf
from sklearn.metrics import roc_auc_score

def auroc(y_true, y_pred):
    return tf.py_func(roc_auc_score, (y_true, y_pred), tf.double)

# Build Model...

model.compile(loss='categorical_crossentropy', optimizer='adam',metrics=['accuracy', auroc])

Try other methods by searching on the site. That is if this doesn’t work