Open mrgloom opened 5 years ago
def gdl_loss(y_true, y_pred, alpha=2): y_true_dy, y_true_dx = tf.image.image_gradients(y_true) y_pred_dy, y_pred_dx = tf.image.image_gradients(y_pred) grad_diff_y = tf.abs(tf.abs(y_true_dy) - tf.abs(y_pred_dy)) grad_diff_x = tf.abs(tf.abs(y_true_dx) - tf.abs(y_pred_dx)) loss = tf.reduce_mean(tf.pow(grad_diff_y, alpha) + tf.pow(grad_diff_x, alpha)) return loss