Since tensorflow 1.7 there is a new way to redefine the gradient. ```python @tf.custom_gradient def flip_grad_layer(x, l): def grad(dy): return tf.negative(dy) * l, None return tf.identity(x), grad ```