Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def auc_roc(y_true, y_pred):
- auc, up_opt = tf.metrics.auc(y_true, y_pred)
- K.get_session().run(tf.local_variables_initializer())
- with tf.control_dependencies([up_opt]):
- auc = tf.identity(auc)
- return auc
- from sklearn.metrics import roc_auc_score
- from keras.callbacks import Callback
- class IntervalEvaluation(Callback):
- def __init__(self, validation_data=(), interval=10):
- super(Callback, self).__init__()
- self.interval = interval
- self.X_val, self.y_val = validation_data
- def on_epoch_end(self, epoch, logs={}):
- if epoch % self.interval == 0:
- y_pred = self.model.predict_proba(self.X_val, verbose=0)
- score = roc_auc_score(self.y_val, y_pred)
- print("interval evaluation - epoch: {:d} - score: {:.6f}".format(epoch, score))
- ival = IntervalEvaluation(validation_data=(x_test2, y_test2), interval=1)
Add Comment
Please, Sign In to add comment