import tensorflow as tf

def gradient_difference_loss(x, y):
    x_h_diff = x[:, 1:] - x[:, :-1]
    x_w_diff = x[:, :, 1:] - x[:, :, :-1]
    y_h_diff = y[:, 1:] - y[:, :-1]
    y_w_diff = y[:, :, 1:] - y[:, :, :-1]
    h_diff = tf.abs(tf.abs(x_h_diff) - tf.abs(y_h_diff))
    w_diff = tf.abs(tf.abs(x_w_diff) - tf.abs(y_w_diff))
    return h_diff + tf.transpose(w_diff)

def leaky_relu(x, leak=0.2, name='leaky_relu'):
    with tf.variable_scope(name):
        f1 = 0.5 * (1 + leak)
