tf.keras.ops.sparse_plus

SparsePlus activation function.

It is defined as

f(x) = 0 for x <= -1. f(x) = (1/4) * (x + 1)^2 for -1 < x < 1. f(x) = x for x >= 1.

x Input tensor.

A tensor with the same shape as x.

Example:

x = np.array([-1.0, 0.0, 1.0])
x_sparse_plus = keras.ops.sparse_plus(x)
print(x_sparse_plus)
Array([0.   0.25 1.  ], shape=(3,), dtype=float32)