dyelax / Adversarial_Video_Generation

A TensorFlow Implementation of "Deep Multi-Scale Video Prediction Beyond Mean Square Error" by Mathieu, Couprie & LeCun.
MIT License
735 stars 184 forks source link

Alternative GDL loss implemetation #31

Open mrgloom opened 5 years ago

mrgloom commented 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