jaxopt.loss.sparse_sigmoid

jaxopt.loss.sparse_sigmoid(x)[source]

Sparse sigmoid function.

Computes the function:

\[\begin{split}\mathrm{sparse\_sigmoid}(x) = \begin{cases} 0, & x \leq -1\\ \frac{1}{2}(x+1), & -1 < x < 1 \\ 1, & 1 \leq x \end{cases}\end{split}\]

This is the twin function of the sigmoid activation ensuring a zero output for inputs less than -1, a 1 ouput for inputs greater than 1, and a linear output for inputs between -1 and 1. This is the derivative of the sparse plus function.

Parameters

x (float) – input (float)

Return type

float

Returns

sparse_sigmoid(x) as defined above