I am training a binary classifier using Keras.
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=[auroc,'accuracy'])
I use a custom metric, AUROC.as in here
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)
So far, I have encoded my target as one-hot encoding and I had a last layer as
from keras.utils import to_categorical
y = to_categorical(y)
[...]
model.add(Dense(2, activation='sigmoid'))
I have learned that in principle here Keras binary_crossentropy vs categorical_crossentropy performance?I should not perform categorical encoding, and I should predict only one class using
# y = to_categorical(y)
[...]
model.add(Dense(1, activation='sigmoid'))
However, if I apply this and only this change my training auroc
changes dramatically, from high 0.90s to 0.50. Even more strangely, val_auroc
loss seems unaffected
How did that happen?