Implement the Softsign activation function. Softsign is defined as f(x) = x / (1 + |x|). It is similar to tanh but converges to its asymptotes more slowly.
import numpy as np
def softsign(x: np.ndarray) -> np.ndarray:
return x / (1 + np.abs(x))x / (1 + |x|) is computationally simpler than tanh since it avoids exponential operations.1 - 1/|x|), while tanh approaches exponentially. This means softsign has longer tails.