softplus#

ivy.softplus(x, /, *, beta=None, threshold=None, complex_mode='jax', out=None)[source]#

Apply the softplus function element-wise.

If the input is complex, then by default we apply the softplus operation log(1+ exp(x)) to each element If threshold is set we check if either its real part is strictly negative or if its real part is zero and its imaginary part is negative then we apply input×β > threshold.

Parameters:
• x (`Union`[`Array`, `NativeArray`]) – input array.

• beta (`Optional`[`Union`[`int`, `float`]], default: `None`) – The beta value for the softplus formation. Default: `None`.

• threshold (`Optional`[`Union`[`int`, `float`]], default: `None`) – values above this revert to a linear function If the input is complex, only its real part is considered. Default: `None`

• complex_mode (`Literal`[`'split'`, `'magnitude'`, `'jax'`], default: `'jax'`) – optional specifier for how to handle complex data types. See `ivy.func_wrapper.handle_complex_input` for more detail.

• out (`Optional`[`Array`], default: `None`) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

`Array`

Returns:

ret – an array containing the softplus activation of each element in `x`.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([-0.3461, -0.6491])
>>> y = ivy.softplus(x)
>>> print(y)
ivy.array([0.535,0.42])
```
```>>> x = ivy.array([-0.3461, -0.6491])
>>> y = ivy.softplus(x, beta=0.5)
>>> print(y)
ivy.array([1.22, 1.09])
```
```>>> x = ivy.array([1., 2., 3.])
>>> y = ivy.softplus(x, threshold=2)
>>> print(y)
ivy.array([1.31, 2.13, 3.  ])
```
Array.softplus(self, /, *, beta=None, threshold=None, complex_mode='jax', out=None)[source]#

ivy.Array instance method variant of ivy.softplus. This method simply wraps the function, and so the docstring for ivy.softplus also applies to this method with minimal changes.

Parameters:
• self (`Array`) – input array.

• beta (`Optional`[`Union`[`int`, `float`]], default: `None`) – the beta parameter of the softplus function.

• threshold (`Optional`[`Union`[`int`, `float`]], default: `None`) – the threshold parameter of the softplus function.

• complex_mode (`Literal`[`'split'`, `'magnitude'`, `'jax'`], default: `'jax'`) –

optional specifier for how to handle complex data types. See

`ivy.func_wrapper.handle_complex_input` for more detail.

• out (`Optional`[`Array`], default: `None`) – optional output array, for writing the result to. It must have a shape

Return type:

`Array`

Returns:

ret – an array with the softplus activation function applied element-wise.

Examples

```>>> x = ivy.array([-0.3461, -0.6491])
>>> y = x.softplus()
>>> print(y)
ivy.array([0.535,0.42])
```
```>>> x = ivy.array([-0.3461, -0.6491])
>>> y = x.softplus(beta=0.5)
>>> print(y)
ivy.array([1.22, 1.09])
```
```>>> x = ivy.array([1.31, 2., 2.])
>>> y = x.softplus(threshold=2, out=x)
>>> print(x)
ivy.array([1.55, 2.13, 2.13])
```
Container.softplus(self, /, *, beta=None, threshold=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax', out=None)[source]#

ivy.Container instance method variant of ivy.softplus. This method simply wraps the function, and so the docstring for ivy.softplus also applies to this method with minimal changes.

Parameters:
• self (`Container`) – input container.

• beta (`Optional`[`Union`[`int`, `float`, `Container`]], default: `None`) – The beta value for the softplus formation. Default: `None`.

• threshold (`Optional`[`Union`[`int`, `float`, `Container`]], default: `None`) – values above this revert to a linear function. Default: `None`.

• key_chains (`Optional`[`Union`[`List`[`str`], `Dict`[`str`, `str`], `Container`]], default: `None`) – The key-chains to apply or not apply the method to. Default is `None`.

• to_apply (`Union`[`bool`, `Container`], default: `True`) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is `True`.

• prune_unapplied (`Union`[`bool`, `Container`], default: `False`) – Whether to prune key_chains for which the function was not applied. Default is `False`.

• map_sequences (`Union`[`bool`, `Container`], default: `False`) – Whether to also map method to sequences (lists, tuples). Default is `False`.

• complex_mode (`Literal`[`'split'`, `'magnitude'`, `'jax'`], default: `'jax'`) – optional specifier for how to handle complex data types. See `ivy.func_wrapper.handle_complex_input` for more detail.

• out (`Optional`[`Container`], default: `None`) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

`Container`

Returns:

ret – a container with the softplus unit function applied element-wise.

Examples

```>>> x = ivy.Container(a=ivy.array([-0.3461, -0.6491]))
>>> y = x.softplus()
>>> print(y)
{
a: ivy.array([0.535, 0.42])
}
```
```>>> x = ivy.Container(a=ivy.array([-1., 2., 4.]))
>>> y = x.softplus(beta=0.5, threshold=2)
>>> print(y)
{
a: ivy.array([0.948, 2.63, 4.25])
}
```