tf.keras.ops.stop_gradient

Stops gradient computation.

variable A tensor variable for which the gradient computation is to be disabled.

The variable with gradient computation disabled.

Examples:

var = keras.backend.convert_to_tensor(  [1., 2., 3.],  dtype="float32" ) var = keras.ops.stop_gradient(var)