logit#

ivy.logit(x, /, *, eps=None, complex_mode='jax', out=None)[source]#

Compute the logit of x.

logit(x) = log(x / (1 - x)).

Parameters:
  • x (Union[float, int, Array]) – Input data.

  • eps (Optional[float], default: None) – When eps is None the function outputs NaN where x < 0 or x > 1. and inf or -inf where x = 1 or x = 0, respectively. Otherwise if eps is defined, x is clamped to [eps, 1 - eps]

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

Return type:

Array

Returns:

ret – Array containing elementwise logits of x.

Examples

>>> x = ivy.array([1, 0, 0.9])
>>> z = ivy.logit(x)
>>> print(z)
ivy.array([       inf,       -inf, 2.19722438])
>>> x = ivy.array([1, 2, -0.9])
>>> z = ivy.logit(x, eps=0.2)
>>> print(z)
ivy.array([ 1.38629448,  1.38629448, -1.38629436])
Array.logit(self, /, *, eps=None, complex_mode='jax', out=None)[source]#

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

Parameters:
  • self – Input array.

  • eps (Optional[float], default: None) – When eps is None the function outputs NaN where x < 0 or x > 1. and inf or -inf where x = 1 or x = 0, respectively. Otherwise if eps is defined, x is clamped to [eps, 1 - eps]

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

Return type:

Array

Returns:

ret – Array containing elementwise logits of x.

Examples

>>> x = ivy.array([1, 0, 0.9])
>>> z = x.logit()
>>> print(z)
ivy.array([       inf,       -inf, 2.19722438])
>>> x = ivy.array([1, 2, -0.9])
>>> z = x.logit(eps=0.2)
>>> print(z)
ivy.array([ 1.38629448,  1.38629448, -1.38629436])
Container.logit(self, /, *, eps=None, complex_mode='jax', out=None)[source]#

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

Parameters:
  • self (Union[float, int, Container]) – Input container.

  • eps (Optional[Union[float, Container]], default: None) – When eps is None the function outputs NaN where x < 0 or x > 1. and inf or -inf where x = 1 or x = 0, respectively. Otherwise if eps is defined, x is clamped to [eps, 1 - eps]

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

Return type:

Container

Returns:

ret – Container with logits of the leaves.

Examples

>>> a = ivy.array([1, 0, 0.9])
>>> b = ivy.array([0.1, 2, -0.9])
>>> x = ivy.Container(a=a, b=b)
>>> z = x.logit()
>>> print(z)
{
    a: ivy.array([inf, -inf, 2.19722438]),
    b: ivy.array([-2.19722462, nan, nan])
}
>>> a = ivy.array([0.3, 2, 0.9])
>>> b = ivy.array([0.1, 1.2, -0.9])
>>> x = ivy.Container(a=a, b=b)
>>> z = x.logit(eps=0.2)
>>> print(z)
{
    a: ivy.array([-0.84729779, 1.38629448, 1.38629448]),
    b: ivy.array([-1.38629436, 1.38629448, -1.38629436])
}