sigmoid#

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

Apply the sigmoid function element-wise.

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

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

Return type:

Array

Returns:

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

Examples

With ivy.Array input:

>>> x = ivy.array([-1.0, 1.0, 2.0])
>>> y = ivy.sigmoid(x)
>>> print(y)
ivy.array([0.269, 0.731, 0.881])
>>> x = ivy.array([-1.0, 1.0, 2.0])
>>> y = x.sigmoid()
>>> print(y)
ivy.array([0.269, 0.731, 0.881])
>>> x = ivy.array([[-1.3, 3.8, 2.1], [1.7, 4.2, -6.6]])
>>> y = ivy.sigmoid(x)
>>> print(y)
ivy.array([[0.214, 0.978, 0.891], [0.846,0.985,0.001]] )
Array.sigmoid(self, /, *, out=None)#

ivy.Array instance method variant of ivy.sigmoid.

This method simply wraps the function, and so the docstring for ivy.sigmoid also applies to this method with minimal changes.

Parameters:
  • self (Array) – Input array

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

Return type:

Array

Returns:

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

Examples

>>> x = ivy.array([-1., 1., 2.])
>>> y = x.sigmoid()
>>> print(y)
ivy.array([0.269, 0.731, 0.881])
Container.sigmoid(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#

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

Parameters:
  • self (Container) – input container.

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

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

  • prune_unapplied (bool) – Whether to prune key_chains for which the function was not applied. (default: False) Default is False.

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

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

Return type:

Container

Returns:

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

Examples

>>> ivy.Container(a=ivy.array([-1., 1., 2.]), b=ivy.array([0.5, 0., -0.1]))
>>> y = x.sigmoid()
>>> print(y)
{
    a: ivy.array([0.2689414, 0.7310586, 0.88079703]),
    b: ivy.array([0.62245935, 0.5, 0.4750208])
}