import tensorflow as tf

    if targets in [0., 1.]:
        entropy = 0.
    else:
        entropy = - targets*tf.log(targets) - (1. - targets)*tf.log(1. - targets)
    return sigmoid_ce_with_logits(logits, tf.ones_like(logits)*targets) - entropy

def gradient_difference_loss(x, y):
    x_h_diff = x[:, 1:] - x[:, :-1]
