selu#

ivy.selu(x, /, *, out=None)[source]#

Apply the scaled exponential linear unit function element-wise.

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

  • 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 scaled exponential linear unit activation of each element in x.

Examples

With ivy.Array input: >>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.selu(x) >>> print(y) ivy.array([-1.11133075, 0. , 1.05070102, 2.10140204, 3.15210295,

4.20280409, 5.25350523, 6.30420589, 7.35490704])

>>> x = ivy.array([-1.,  0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.])
>>> y = ivy.zeros(9)
>>> ivy.selu(x, out = y)
>>> print(y)
ivy.array([-1.11133075,  0.        ,  1.05070102,  2.10140204,  3.15210295,
        4.20280409,  5.25350523,  6.30420589,  7.35490704])

With ivy.Container input: >>> x = ivy.Container(a=ivy.array([-3., -2., -1., 0., 1., 2., 3., 4., 5.]), … b=ivy.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) … ) >>> x = ivy.selu(x, out=x) >>> print(x) {

a: ivy.array([-1.6705687, -1.52016652, -1.11133075, 0., 1.05070102,

2.10140204, 3.15210295, 4.20280409, 5.25350523]),

b: ivy.array([1.05070102, 2.10140204, 3.15210295, 4.20280409, 5.25350523,

6.30420589, 7.35490704, 8.40560818, 9.45630932])

}

Array.selu(self, /, *, out=None)[source]#

Apply the scaled exponential linear unit function element-wise.

Parameters:
  • self – input array

  • 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 scaled exponential linear unit activation of each element in input.

Examples

With ivy.Array input:

>>> x = ivy.array([-1.,  0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.])
>>> y = x.selu()
>>> print(y)
ivy.array([-1.11133075,  0.,  1.05070102,  2.10140204,  3.15210295,
            4.20280409,  5.25350523,  6.30420589,  7.35490704])
>>> x = ivy.array([-1.,  0.,  1.,  2.,  3.,  4.,  5.,  6.,  7.])
>>> y = ivy.zeros(9)
>>> x.selu(out = y)
>>> print(y)
ivy.array([-1.11133075,  0.,  1.05070102,  2.10140204,  3.15210295,
            4.20280409,  5.25350523,  6.30420589,  7.35490704])
Container.selu(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • 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.

  • 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 scaled exponential linear unit activation function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.selu()
>>> print(y)
{
    a: ivy.array([1.05070102, -1.22856998]),
    b: ivy.array([0.42028043, -0.31868932])
}