Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative GDL loss implemetation #31

Open
mrgloom opened this issue Apr 19, 2019 · 0 comments
Open

Alternative GDL loss implemetation #31

mrgloom opened this issue Apr 19, 2019 · 0 comments

Comments

@mrgloom
Copy link

mrgloom commented Apr 19, 2019

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant