scipy.special.

softplus#

scipy.special.softplus(x, **kwargs)[source]#

Compute the softplus function element-wise.

The softplus function is defined as: softplus(x) = log(1 + exp(x)). It is a smooth approximation of the rectifier function (ReLU).

Parameters:
xarray_like

Input value.

**kwargs

For other keyword-only arguments, see the ufunc docs.

Returns:
softplusndarray

Logarithm of exp(0) + exp(x).

Notes

Array API Standard Support

softplus has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

n/a

CuPy

n/a

PyTorch

JAX

Dask

n/a

See Support for the array API standard for more information.

Examples

>>> from scipy import special
>>> special.softplus(0)
0.6931471805599453
>>> special.softplus([-1, 0, 1])
array([0.31326169, 0.69314718, 1.31326169])