How to use TensorFlow metrics in Keras
you can still usecontrol_dependencies def mean_iou(y_true, y_pred): score, up_opt = tf.metrics.mean_iou(y_true, y_pred, NUM_CLASSES) K.get_session().run(tf.local_variables_initializer()) with tf.control_dependencies([up_opt]): score = tf.identity(score) return score