Experimental#

class ivy.data_classes.container.experimental.activations._ContainerWithActivationExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_celu(x, /, *, alpha=1.0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax', out=None)[source]#

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

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

  • alpha (Container, default: 1.0) – array or scalar specifying the alpha value for CELU formlation.

  • 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 celu unit function applied element-wise.

Examples

>>> x = x = ivy.Container(a=ivy.array([0.39, -0.85]), b=ivy.array([1., -0.2]))
>>> y = ivy.Container.static_celu(x)
>>> print(y)
{
    a: ivy.array([0.38999999, -0.17]),
    b: ivy.array([1., -0.04])
}
static _static_elu(x, /, *, alpha=1.0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • alpha (Container, default: 1.0) – scaler for controlling the slope of the function for x <= 0 Default: 1.0

  • 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 elu unit function applied element-wise.

Examples

>>> x = x = ivy.Container(a=ivy.array([0.39, -0.85]), b=ivy.array([1., -0.2]))
>>> y = ivy.Container.static_elu(x)
>>> print(y)
{
    a: ivy.array([0.38999999, -0.57]),
    b: ivy.array([1., -0.18])
}
static _static_hardshrink(x, /, *, lambd=0.5, key_chains=None, to_apply=False, prune_unapplied=True, map_sequences=False, out=None)[source]#

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

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

  • lambd (Container, default: 0.5) – Lambda value for hard shrinkage calculation.

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

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

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

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

Return type:

Container

Returns:

ret – Container with hard shrinkage applied to the leaves.

Examples

>>> x = ivy.Container(a=ivy.array([1., -2.]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container._static_hardshrink(x)
>>> print(y)
{
    a: ivy.array([1., -2.]),
    b: ivy.array([0., 0.])
}
static _static_hardsilu(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method which acts as a wrapper for ivy.hardsilu.

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

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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:

  • a container containing the output of the hardsilu/hardswish function applied

  • to each element in x.

Examples

>>> x = ivy.Container(a=ivy.array([-0.5, -1, 0]), b=ivy.array([0.5, 1., 2]))
>>> y = ivy.Container._static_hardsilu(x)
>>> print(y)
{
    a: ivy.array([-0.20833333, -0.33333334, 0.]),
    b: ivy.array([0.29166666, 0.66666669, 1.66666663])
}
static _static_hardtanh(x, /, *, min_val=-1.0, max_val=1.0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.hardtanh.This method simply wrap the function,the docstring for ivy.hardtanh also applies to this method with minimal changes.

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

  • min_val (Container, default: -1.0) – minimum value of the linear region range. Default: -1.

  • max_val (Container, default: 1.0) – maximum value of the linear region range. Default: 1.

  • 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 hardtanh unit function applied element-wise.

Examples

>>> x = x = ivy.Container(a=ivy.array([0.39, -2.0]), b=ivy.array([2., -0.2]))
>>> y = ivy.Container._static_hardtanh(x)
>>> print(y)
{
    a: ivy.array([0.3899, -1.]),
    b: ivy.array([1., -0.2])
}
static _static_scaled_tanh(x, /, *, alpha=1.7159, beta=0.67, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • alpha (Union[float, Container], default: 1.7159) – The scaling parameter for the output. Determines the amplitude of the tanh function. Default: 1.7159

  • beta (Union[float, Container], default: 0.67) – The scaling parameter for the input. Determines the slope of the tanh function. Default: 0.67

  • 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_tanh function applied.

Examples

>>> x = ivy.Container(a=ivy.array([8.931, -0.85]), b=ivy.array([1., -0.2])))
>>> y = ivy.Container._static_scaled_tanh(x)
>>> y
{
    a: ivy.array([1.71587813, -0.88367474]),
    b: ivy.array([1.00376701, -0.2285642])
}
>>> x = ivy.Container(a=ivy.array([8.9, -8.9]), b=ivy.array([3., 33.2]))
>>> y = ivy.Container._static_scaled_tanh(x, alpha=2, beta=2.5)
>>> y
{
    a: ivy.array([2., -2.]),
    b: ivy.array([1.99999881, 2.])
}
>>> x = ivy.Container(a=ivy.array([0.3, -0.3]), b=ivy.array([33.0, -33.0]))
>>> y = ivy.Container._static_scaled_tanh(x, alpha=1.5, beta=25)
>>> y
{
    a: ivy.array([1.49999905, -1.49999905]),
    b: ivy.array([1.5, -1.5])
}
static _static_silu(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, 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 rectified linear activation unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container.static_silu(x)
>>> print(y)
{
    a: ivy.array([0.73105854, -0.27777028]),
    b: ivy.array([0.23947507, -0.0900332])
}
static _static_softshrink(x, /, *, lambd=0.5, key_chains=None, to_apply=False, prune_unapplied=True, map_sequences=False, out=None)[source]#

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

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

  • lambd (Container, default: 0.5) – Lambda value for soft shrinkage calculation.

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

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

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

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

  • 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 – Container with soft shrinkage applied to the leaves.

Examples

>>> x = ivy.Container(a=ivy.array([1., -2.]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container._static_softshrink(x)
>>> print(y)
{
    a: ivy.array([0.5, -1.5]),
    b: ivy.array([0., 0.])
}
static _static_tanhshrink(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, 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 tanhshrink activation unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container._static_tanhshrink(x)
>>> print(y)
{
    a: ivy.array([0.23840582, -0.36634541]),
    b: ivy.array([0.02005103, -0.00262468])
}
static _static_threshold(x, /, *, threshold, value, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • threshold (Container) – threshold value for thresholding operation.

  • value (Container) – value to replace with if thresholding condition is not met.

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

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

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

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

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

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x._static_threshold(threshold=0.5, value=0.0)
>>> print(y)
{
    a: ivy.array([1., 0.]),
    b: ivy.array([0., 0.])
}
celu(*, alpha=1.0, 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.leaky_relu. This method simply wraps the function, and so the docstring for ivy.leaky_relu also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container.

  • alpha (Container, default: 1.0) – array or scalar specifying alpha (negative slope) value for CELU formulation.

  • 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 celu unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([0.39, -0.85]), b=ivy.array([1., -0.2]))
>>> y = x.celu()
>>> print(y)
{
    a: ivy.array([0.38999999, -0.57]),
    b: ivy.array([1., -0.18])
}
elu(*, alpha=1.0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • alpha (Container, default: 1.0) – scaler for controlling the slope of the function for x <= 0 Default: 1.0

  • 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 elu unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([0.39, -0.85]), b=ivy.array([1., -0.2]))
>>> y = x.elu()
>>> print(y)
{
    a: ivy.array([0.38999999, -0.57]),
    b: ivy.array([1., -0.18])
}
hardshrink(*, lambd=0.5, key_chains=None, to_apply=False, prune_unapplied=True, map_sequences=False, out=None)[source]#

Apply the hard shrinkage function element-wise.

Parameters:
  • self (Container) – Input container.

  • lambd (Container, default: 0.5) – Lambda value for hard shrinkage calculation.

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

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

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

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

  • 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 – Container with hard shrinkage applied to the leaves.

Examples

>>> x = ivy.Container(a=ivy.array([1., -2.]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container.hardshrink(x)
>>> print(y)
{
    a: ivy.array([1., -2.]),
    b: ivy.array([0., 0.])
}
hardsilu(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method which acts as a wrapper for ivy.hardsilu.

Parameters:
  • self – input container

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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:

  • a container containing the output of the hardsilu/hardswish function applied

  • to each element in the input container.

Examples

>>> x = ivy.Container(a=ivy.array([-0.5, -1, 0]), b=ivy.array([0.5, 1., 2]))
>>> y = x.hardsilu()
>>> print(y)
{
    a: ivy.array([-0.20833333, -0.33333334, 0.]),
    b: ivy.array([0.29166666, 0.66666669, 1.66666663])
}
hardtanh(*, min_val=-1.0, max_val=1.0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • min_val (Container, default: -1.0) – minimum value of the linear region range. Default: -1.

  • max_val (Container, default: 1.0) – maximum value of the linear region range. Default: 1.

  • 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 hardtanh unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([0.39, -2.0]), b=ivy.array([2., -0.2]))
>>> y = ivy.Container.hardtanh(x)
>>> print(y)
{
    a: ivy.array([0.389999, -1.]),
    b: ivy.array([1., -0.2])
}
logit(*, 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])
}
logsigmoid(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax')[source]#

Apply element-wise Log-sigmoid of x i.e. log(1 / (1 + exp(-x)).

Parameters:
  • self (Container) – Input container.

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

Return type:

Container

Returns:

ret – Container with Log-sigmoid applied to the leaves.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.logsigmoid()
>>> print(y)
{
    a: ivy.array([-0.31326163, -1.46328258]),
    b: ivy.array([-0.51301527, -0.79813886])
}
prelu(slope, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Parameters:
  • slope (Union[float, NativeArray, Array, Container]) –

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) –

  • to_apply (Union[bool, Container], default: True) –

  • prune_unapplied (Union[bool, Container], default: False) –

  • map_sequences (Union[bool, Container], default: False) –

  • out (Optional[Container], default: None) –

Return type:

Container

relu6(*, 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.relu6. This method simply wraps the function, and so the docstring for ivy.relu6 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.

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

Examples

>>> 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.]))
>>> y = x.relu()
>>> print(y)
{
    a: ivy.array([0., 0., 0., 0., 1., 2., 3., 4., 5.]),
    b: ivy.array([1., 2., 3., 4., 5., 6., 7., 8., 9.])
}
scaled_tanh(*, alpha=1.7159, beta=0.67, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – input container.

  • alpha (Union[float, Container], default: 1.7159) – The scaling parameter for the output. Determines the amplitude of the tanh function. Default: 1.7159

  • beta (Union[float, Container], default: 0.67) – The scaling parameter for the input. Determines the slope of the tanh function. Default: 0.67

  • 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_tanh function applied.

Examples

>>> x = ivy.Container(a=ivy.array([2., 3.]), b=ivy.array([1., 2.]))
>>> x.scaled_tanh()
{
    a: ivy.array([1.49570239, 1.65537548]),
    b: ivy.array([1.00376701, 1.49570239])
}
>>> x = ivy.Container(a=ivy.array([1., 1.]), b=ivy.array([1., 1.]))
>>> x.scaled_tanh(alpha=30)
{
    a: ivy.array([17.54939651, 17.54939651]),
    b: ivy.array([17.54939651, 17.54939651])
}
>>> x = ivy.Container(a=ivy.array([20., 21.]), b=ivy.array([3., 1.]))
>>> x.scaled_tanh(alpha=0.1, beta=-0.4)
{
    a: ivy.array([-0.09999998, -0.09999999]),
    b: ivy.array([-0.08336546, -0.0379949])
}
selu(*, 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])
}
silu(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.silu. This method simply wraps the function, and so the docstring for ivy.silu 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 rectified linear activation unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.silu()
>>> print(y)
{
    a: ivy.array([0.73105854, -0.27777028]),
    b: ivy.array([0.23947507, -0.0900332])
}
softshrink(*, lambd=0.5, key_chains=None, to_apply=False, prune_unapplied=True, map_sequences=False, out=None)[source]#

Apply the soft shrinkage function element-wise.

Parameters:
  • self (Container) – Input container.

  • lambd (Container, default: 0.5) – Lambda value for soft shrinkage calculation.

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

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

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

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

  • 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 – Container with soft shrinkage applied to the leaves.

Examples

>>> import ivy.numpy as np
>>> x = ivy.Container(a=np.array([1., -2.]), b=np.array([0.4, -0.2]))
>>> y = ivy.Container.softshrink(x)
>>> print(y)
{
    a: ivy.array([0.5, -1.5]),
    b: ivy.array([0., 0.])
}
static static_logit(x, /, *, eps=None, complex_mode='jax', out=None)[source]#

ivy.Container static 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:
  • x (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 = ivy.Container.static_logit(x)
>>> 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 = ivy.Container.static_logit(x, eps=0.2)
>>> print(z)
{
    a: ivy.array([-0.84729779, 1.38629448, 1.38629448]),
    b: ivy.array([-1.38629436, 1.38629448, -1.38629436])
}
static static_logsigmoid(input, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax')[source]#

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

Parameters:
  • input (Union[Array, NativeArray, 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.

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

Return type:

Container

Returns:

Container with Log-sigmoid applied to 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 = ivy.Container.static_logsigmoid(x)
>>> print(z)
{
    a: ivy.array([-0.31326169, -0.69314718, -0.34115386]),
    b: ivy.array([-0.64439666, -0.126928, -1.24115384])
}
>>> a = ivy.array([0.3, 2.5, 4.9])
>>> b = ivy.array([0.1, 1.2, -9.])
>>> x = ivy.Container(a=a, b=b)
>>> z = ivy.Container.static_logsigmoid(x)
>>> print(z)
{
    a: ivy.array([-0.55435526, -0.07888974, -0.00741899]),
    b: ivy.array([-0.64439666, -0.26328245, -9.00012302])
}
static static_prelu(x, slope, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Parameters:
  • x (Union[NativeArray, Array, Container]) –

  • slope (Union[float, NativeArray, Array, Container]) –

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) –

  • to_apply (Union[bool, Container], default: True) –

  • prune_unapplied (Union[bool, Container], default: False) –

  • map_sequences (Union[bool, Container], default: False) –

  • out (Optional[Container], default: None) –

Return type:

Container

static static_relu6(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax', out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, 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.

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

Examples

>>> 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.]))
>>> y = ivy.Container.static_relu6(x)
>>> print(y)
{
    a: ivy.array([0., 0., 0., 0., 1., 2., 3., 4., 5.]),
    b: ivy.array([1., 2., 3., 4., 5., 6., 6., 6., 6.])
}
static static_selu(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static 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:
  • x (Union[Array, NativeArray, 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 = ivy.Container.static_selu(x)
>>> print(y)
{
    a: ivy.array([1.05070102, -1.22856998]),
    b: ivy.array([0.42028043, -0.31868932])
}
static static_thresholded_relu(x, /, *, threshold=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • threshold (Union[int, float, Container], default: 0) – threshold value above which the activation is linear. Default: 0.

  • 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 rectified linear activation unit function applied element-wise with custom threshold.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = ivy.Container.static_thresholded_relu(x, threshold=0.5)
>>> print(y)
{
    a: ivy.array([1., 0.]),
    b: ivy.array([0., 0.])
}
tanhshrink(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.tanhshrink. This method simply wraps the function, and so the docstring for ivy.tanhshrink 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 tanhshrink activation unit function applied element-wise.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.tanhshrink()
>>> print(y)
{
    a: ivy.array([0.23840582, -0.36634541]),
    b: ivy.array([0.02005103, -0.00262468])
}
threshold(*, threshold, value, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • threshold (Container) – threshold value for thresholding operation.

  • value (Container) – value to replace with if thresholding condition is not met.

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

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

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

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

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

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.threshold(threshold=0.5, value=0.0)
>>> print(y)
{
    a: ivy.array([1., 0.]),
    b: ivy.array([0., 0.])
}
thresholded_relu(*, threshold=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • threshold (Union[int, float, Container], default: 0) – threshold value above which the activation is linear. Default: 0.

  • 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 rectified linear activation unit function applied element-wise with custom threshold.

Examples

>>> x = ivy.Container(a=ivy.array([1.0, -1.2]), b=ivy.array([0.4, -0.2]))
>>> y = x.thresholded_relu(threshold=0.5)
>>> print(y)
{
    a: ivy.array([1., 0.]),
    b: ivy.array([0., 0.])
}
class ivy.data_classes.container.experimental.conversions._ContainerWithConversionExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.creation._ContainerWithCreationExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_trilu(x, /, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, k=0, upper=True, out=None)[source]#
Return type:

Container

blackman_window(periodic=True, dtype=None, *, out=None)[source]#

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

Parameters:
  • self (Container) – input container with window sizes.

  • periodic (bool, default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – The data type to produce. Must be a floating point type.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container containing the Blackman windows.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=3, b=5) >>> ivy.blackman_window(x) {

a: ivy.array([-1.38777878e-17, 6.30000000e-01, 6.30000000e-01]) b: ivy.array([-1.38777878e-17, 2.00770143e-01, 8.49229857e-01,

8.49229857e-01, 2.00770143e-01])

}

eye_like(k=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None, dtype=None, device=None)[source]#

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

Parameters:
  • self (Container) – input array or container from which to derive the output container shape.

  • k (Union[int, Container], default: 0) – index of the diagonal. A positive value refers to an upper diagonal, a negative value to a lower diagonal, and 0 to the main diagonal. Default: 0.

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

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output array data type. If dtype is None, the output container data type must be inferred from self. Default: None.

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to place the created array. If device is None, the output container device must be inferred from self. Default: None.

  • 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 having the same shape as x and filled with ones in diagonal k and zeros elsewhere.

Examples

>>> x = ivy.Container(a=ivy.array([3., 8.]), b=ivy.array([2., 2.]))
>>> y = x.eye_like()
>>> print(y)
{
    a: ivy.array([[1.],
                  [0.]]),
    b: ivy.array([[1.],
                  [0.]])
}
hamming_window(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, periodic=True, alpha=0.54, beta=0.46, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • alpha (Union[float, Container], default: 0.54) – The coefficient alpha in the hamming window equation

  • beta (Union[float, Container], default: 0.46) – The coefficient beta in the hamming window equation

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned arrays.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Hamming windows.

Examples

>>> x = ivy.Container(a=3, b=5))
>>> x.hamming_window(periodic=True, alpha=0.2, beta=2)
{
    a: ivy.array([-1.8000,  1.2000,  1.2000]),
    b: ivy.array([-1.8000, -0.4180,  1.8180,  1.8180, -0.4180])
}
hann_window(periodic=True, dtype=None, *, out=None)[source]#

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

Parameters:
  • self (Container) – input container with window sizes.

  • periodic (Union[bool, Container], default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The data type to produce. Must be a floating point type.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container containing the Hann windows.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=3, b=5)
>>> ivy.hann_window(x)
{
    a: ivy.array([0.0000, 0.7500, 0.7500])
    b: ivy.array([0.0000, 0.3455, 0.9045, 0.9045, 0.3455])
}
kaiser_bessel_derived_window(periodic=True, beta=12.0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a periodic window suitable for use in spectral analysis. If False, returns a symmetric window suitable for use in filter design.

  • beta (Union[float, Container], default: 12.0) – a float used as shape parameter for the window.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned array.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Kaiser Bessel Derived windows.

Examples

>>> x = ivy.Container(a=3, b=5))
>>> x.kaiser_bessel_derived_window(True, 5)
{
    a: ivy.array([0.70710677, 0.70710677]),
    b: ivy.array([0.18493208, 0.9827513 , 0.9827513 , 0.18493208]),
}
kaiser_window(periodic=True, beta=12.0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a periodic window suitable for use in spectral analysis. If False, returns a symmetric window suitable for use in filter design.

  • beta (Union[float, Container], default: 12.0) – a float used as shape parameter for the window.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned array.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Kaiser windows.

Examples

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_kaiser_window(x, True, 5)
{
    a: ivy.array([0.2049, 0.8712, 0.8712]),
    a: ivy.array([0.0367, 0.7753, 0.7753]),
}
mel_weight_matrix(num_mel_bins, dft_length, sample_rate, lower_edge_hertz=0.0, upper_edge_hertz=3000.0)[source]#

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

Parameters:
  • num_mel_bins (int) – The number of bands in the mel spectrum.

  • dft_length (int) – The size of the original DFT obtained from (n_fft / 2 + 1).

  • sample_rate (int) – Samples per second of the input signal.

  • lower_edge_hertz (Optional[float], default: 0.0) – Lower bound on the frequencies to be included in the mel spectrum.

  • upper_edge_hertz (Optional[float], default: 3000.0) – The desired top edge of the highest frequency band.

Returns:

ret – MelWeightMatrix of shape: [frames, num_mel_bins]

polyval(coeffs, x)[source]#

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

Evaluate and return a polynomial at specific given values.

Parameters:
  • self (Container) – Arbitrary input container

  • coeffs (Container) – Polynomial coefficients (including zero) from highest degree to constant term.

  • x (Container) – The value of the indeterminate variable at which to evaluate the polynomial.

Return type:

Container

Returns:

ret – Output container containing simplified result of substituting x in the coefficients - final value of polynomial.

static static_blackman_window(window_length, periodic=True, dtype=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • window_length (Union[int, Container]) – container including multiple window sizes.

  • periodic (bool, default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • dtype (Optional[Union[Dtype, NativeDtype]], default: None) – The data type to produce. Must be a floating point type.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that contains the Blackman windows.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=3, b=5) >>> ivy.Container.static_blackman_window(x) {

a: ivy.array([-1.38777878e-17, 6.30000000e-01, 6.30000000e-01]) b: ivy.array([-1.38777878e-17, 2.00770143e-01, 8.49229857e-01,

8.49229857e-01, 2.00770143e-01])

}

static static_eye_like(x, /, k=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, out=None, dtype=None, device=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array or container from which to derive the output container shape.

  • k (Union[int, Container], default: 0) – index of the diagonal. A positive value refers to an upper diagonal, a negative value to a lower diagonal, and 0 to the main diagonal. Default: 0.

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

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output array data type. If dtype is None, the output container data type must be inferred from self. Default None.

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to place the created array. If device is None, the output container device must be inferred from self. Default: None.

  • 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 having the same shape as x and filled with ones in diagonal k and zeros elsewhere.

Examples

>>> x = ivy.Container(a=ivy.array([0., 2.6, -3.5]),
                      b=ivy.array([4.5, -5.3, -0, -2.3]))
>>> y = ivy.Container.static_eye_like(x)
>>> print(y)
{
    a: ivy.array([[1.]]),
    b: ivy.array([[1.]])
}
static static_hamming_window(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, periodic=True, alpha=0.54, beta=0.46, dtype=None, out=None)[source]#

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

Parameters:
  • x (Union[int, Array, NativeArray, Container]) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • alpha (Union[float, Container], default: 0.54) – The coefficient alpha in the hamming window equation

  • beta (Union[float, Container], default: 0.46) – The coefficient beta in the hamming window equation

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned arrays.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Hamming windows.

Examples

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_hamming_window(x, periodic=True, alpha=0.2, beta=2)
{
    a: ivy.array([-1.8000,  1.2000,  1.2000]),
    b: ivy.array([-1.8000, -0.4180,  1.8180,  1.8180, -0.4180])
}
static static_hann_window(window_length, periodic=True, dtype=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • window_length (Union[int, Container]) – container including multiple window sizes.

  • periodic (Union[bool, Container], default: True) – If True, returns a window to be used as periodic function. If False, return a symmetric window.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The data type to produce. Must be a floating point type.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that contains the Hann windows.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_hann(x)
{
    a: ivy.array([0.0000, 0.7500, 0.7500])
    b: ivy.array([0.0000, 0.3455, 0.9045, 0.9045, 0.3455])
}
static static_kaiser_bessel_derived_window(x, periodic=True, beta=12.0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • x (Union[int, Array, NativeArray, Container]) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a periodic window suitable for use in spectral analysis. If False, returns a symmetric window suitable for use in filter design.

  • beta (Union[float, Container], default: 12.0) – a float used as shape parameter for the window.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned array.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Kaiser Bessel Derived windows.

Examples

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_kaiser_bessel_derived_window(x, True, 5)
{
    a: ivy.array([0.70710677, 0.70710677]),
    b: ivy.array([0.18493208, 0.9827513 , 0.9827513 , 0.18493208]),
}
static static_kaiser_window(window_length, periodic=True, beta=12.0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • window_length (Union[int, Container]) – input container including window lengths.

  • periodic (Union[bool, Container], default: True) – If True, returns a periodic window suitable for use in spectral analysis. If False, returns a symmetric window suitable for use in filter design.

  • beta (Union[float, Container], default: 12.0) – a float used as shape parameter for the window.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned array.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the Kaiser windows.

Examples

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_kaiser_window(x, True, 5)
{
    a: ivy.array([0.2049, 0.8712, 0.8712]),
    a: ivy.array([0.0367, 0.7753, 0.7753]),
}
static static_mel_weight_matrix(num_mel_bins, dft_length, sample_rate, lower_edge_hertz=0.0, upper_edge_hertz=3000.0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • num_mel_bins (Union[int, Container]) – The number of bands in the mel spectrum.

  • dft_length (Union[int, Container]) – The size of the original DFT obtained from (n_fft / 2 + 1).

  • sample_rate (Union[int, Container]) – Samples per second of the input signal.

  • lower_edge_hertz (Optional[Union[float, Container]], default: 0.0) – Lower bound on the frequencies to be included in the mel spectrum.

  • upper_edge_hertz (Optional[Union[float, Container]], default: 3000.0) – The desired top edge of the highest frequency band.

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

Return type:

Container

Returns:

ret – MelWeightMatrix of shape: [frames, num_mel_bins]

static static_polyval(coeffs, x, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Evaluate and return a polynomial at specific given values.

Parameters:
  • coeffs (Container) – Polynomial coefficients (including zero) from highest degree to constant term.

  • x (Union[Container, int, float]) – The value of the indeterminate variable at which to evaluate the polynomial.

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

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

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

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

Return type:

Container

Returns:

ret – Output container containing simplified result of substituting x in the coefficients - final value of polynomial.

static static_tril_indices(n_rows, n_cols=None, k=0, /, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, device=None)[source]#
Return type:

Container

static static_unsorted_segment_mean(data, segment_ids, num_segments, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

Compute the mean of values in the input data based on segment identifiers.

Parameters:
  • data (ivy.Container) – Input array or container from which to gather the input.

  • segment_ids (ivy.Container) – An array of integers indicating the segment identifier for each element in ‘data’.

  • num_segments (Union[int, ivy.Container]) – An integer or array representing the total number of distinct segment IDs.

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

  • to_apply (Union[bool, ivy.Container], optional) – If True, the method will be applied to key-chains, otherwise key-chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, ivy.Container], optional) – Whether to prune key-chains for which the function was not applied. Default is False.

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

Return type:

Container

Returns:

ivy.Container – A container representing the result of a segmented mean operation. For each segment, it computes the mean of values in ‘data’ where ‘segment_ids’ equals the segment ID.

static static_unsorted_segment_min(data, segment_ids, num_segments, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Note

If the given segment ID i is negative, then the corresponding value is dropped, and will not be included in the result.

Parameters:
  • data (Container) – input array or container from which to gather the input.

  • segment_ids (Container) – Must be in the same size with the first dimension of data. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of data.

  • num_segments (Union[int, Container]) – An integer or array representing the total number of distinct segment IDs.

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

Return type:

Container

Returns:

ret – A container, representing the result of a segmented min operation. For each segment, it computes the min value in data where segment_ids equals to segment ID.

static static_unsorted_segment_sum(data, segment_ids, num_segments, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • data (Container) – input array or container from which to gather the input.

  • segment_ids (Container) – Must be in the same size with the first dimension of data. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of data.

  • num_segments (Union[int, Container]) – An integer or array representing the total number of distinct segment IDs.

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

Return type:

Container

Returns:

ret – A container, representing the result of a segmented sum operation. For each segment, it computes the sum of values in data where segment_ids equals to segment ID.

static static_vorbis_window(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • x (Union[int, Array, NativeArray, Container]) – input container including window lengths.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned arrays.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the vorbis windows.

Examples

>>> x = ivy.Container(a=3, b=5)
>>> ivy.Container.static_vorbis_window(x)
{
    a: ivy.array([0., 0.38268343, 0.92387953, 1., 0.92387953,
                  0.38268343]),
    b: ivy.array([0., 0.14943586, 0.51644717, 0.85631905, 0.98877142,
                  1., 0.98877142, 0.85631905, 0.51644717, 0.14943586])
}
tril_indices(n_rows, n_cols=None, k=0, /, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, device=None)[source]#
Return type:

Container

trilu(key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, *, k=0, upper=True, out=None)[source]#
Return type:

Container

unsorted_segment_mean(segment_ids, num_segments)[source]#

Compute the mean of values in the input array or container based on segment identifiers.

Parameters:
  • self (ivy.Container) – Input array or container from which to gather the input.

  • segment_ids (ivy.Container) – An array of integers indicating the segment identifier for each element in ‘self’.

  • num_segments (Union[int, ivy.Container]) – An integer or array representing the total number of distinct segment IDs.

Return type:

Container

Returns:

ivy.Container – A container representing the result of a segmented mean operation. For each segment, it computes the mean of values in ‘self’ where ‘segment_ids’ equals the segment ID.

Example

>>> data = ivy.Container(a=ivy.array([0., 1., 2., 4.]),
...                      b=ivy.array([3., 4., 5., 6.]))
>>> segment_ids = ivy.array([0, 0, 1, 1])
>>> num_segments = 2
>>> result = ivy.unsorted_segment_mean(data, segment_ids, num_segments)
>>> print(result)
{
    a: ivy.array([0.5, 3.0]),
    b: ivy.array([3.5, 5.5])
}
>>> data = ivy.Container(a=ivy.array([0., 1., 2., 4., 5., 6.]),
...                      b=ivy.array([3., 4., 5., 6., 7., 8.]))
>>> segment_ids = ivy.array([0, 0, 1, 1, 2, 2])
>>> num_segments = 3
>>> result = ivy.unsorted_segment_mean(data, segment_ids, num_segments)
>>> print(result)
{
    a: ivy.array([0.5, 3.0, 5.5]),
    b: ivy.array([3.5, 5.5, 7.5])
}
unsorted_segment_min(segment_ids, num_segments)[source]#

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

Note

If the given segment ID i is negative, then the corresponding value is dropped, and will not be included in the result.

Parameters:
  • self (Container) – input array or container from which to gather the input.

  • segment_ids (Container) – Must be in the same size with the first dimension of self. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of self.

  • num_segments (Union[int, Container]) – An integer or array representing the total number of distinct segment IDs.

Returns:

ret – A container, representing the result of a segmented min operation. For each segment, it computes the min value in self where segment_ids equals to segment ID.

unsorted_segment_sum(segment_ids, num_segments)[source]#

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

Parameters:
  • self (Container) – input array or container from which to gather the input.

  • segment_ids (Container) – Must be in the same size with the first dimension of self. Has to be of integer data type. The index-th element of segment_ids array is the segment identifier for the index-th element of self.

  • num_segments (Union[int, Container]) – An integer or array representing the total number of distinct segment IDs.

Returns:

ret – A container, representing the result of a segmented sum operation. For each segment, it computes the sum of values in self where segment_ids equals to segment ID.

vorbis_window(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – input container including window lengths.

  • dtype (Optional[Union[Array, NativeArray, Container]], default: None) – data type of the returned arrays.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The container that includes the vorbis windows.

Examples

>>> x = ivy.Container(a=3, b=5))
>>> x.vorbis_window()
{
    a: ivy.array([0., 0.38268343, 0.92387953, 1., 0.92387953,
                  0.38268343]),
    b: ivy.array([0., 0.14943586, 0.51644717, 0.85631905, 0.98877142,
                  1., 0.98877142, 0.85631905, 0.51644717, 0.14943586])
}
class ivy.data_classes.container.experimental.data_type._ContainerWithData_typeExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.device._ContainerWithDeviceExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.elementwise._ContainerWithElementWiseExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
allclose(x2, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • x2 (Container) – Input container containing second input array.

  • rtol (Union[float, Container], default: 1e-05) – The relative tolerance parameter.

  • atol (Union[float, Container], default: 1e-08) – The absolute tolerance parameter.

  • equal_nan (Union[bool, Container], default: False) – Whether to compare NaN’s as equal. If True, NaN’s in x1 will be considered equal to NaN’s in x2 in the output array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new container holding the result is returned unless out is specified, in which it is returned.

Examples

>>> x1 = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([1., 2., 3.]))
>>> x2 = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([1., 2., 3.]))
>>> y = x1.allclose(x2)
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(True)
}
>>> x1 = ivy.Container(a=ivy.array([1., 2., 3.]),
...                         b=ivy.array([1., 2., 3.]))
>>> x2 = ivy.Container(a=ivy.array([1., 2., 3.0003]),
...                         b=ivy.array([1.0006, 2., 3.]))
>>> y = x1.allclose(x2, rtol=1e-3)
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(True)
}
amax(*, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container. Should have a real-valued data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – axis or axes along which maximum values must be computed. By default, the maximum value must be computed over the entire array. If a tuple of integers, maximum values must be computed over multiple axes. Default: None.

  • keepdims (Union[bool, Container], default: False) – optional boolean, if True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/ latest/API_specification/ broadcasting.html#broadcasting>`_). Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – container, if the maximum value was computed over the entire array, a zero-dimensional array containing the maximum value; otherwise, a non-zero-dimensional array containing the maximum values. The returned array must have the same data type as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]),
...                   b=ivy.array([2, 3, 4]))
>>> y = x.amax()
>>> print(y)
{
    a: ivy.array(3),
    b: ivy.array(4)
}
>>> x = ivy.Container(a=ivy.array([[1, 2, 3], [-1, 0, 2]]),
...                   b=ivy.array([[2, 3, 4], [0, 1, 2]]))
>>> y = x.amax(axis=1)
>>> print(y)
{
    a:ivy.array([3, 2]),
    b:ivy.array([4, 2])
}
amin(*, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container. Should have a real-valued data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – axis or axes along which minimum values must be computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default: None.

  • keepdims (Union[bool, Container], default: False) – optional boolean, if True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/latest/ API_specification/broadcasting.html#broadcasting>`_). Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – container, if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]),
...                   b=ivy.array([2, 3, 4]))
>>> y = x.amin()
>>> print(y)
{
    a: ivy.array(1),
    b: ivy.array(2)
}
>>> x = ivy.Container(a=ivy.array([[1, 2, 3], [-1, 0, 2]]),
...                   b=ivy.array([[2, 3, 4], [0, 1, 2]]))
>>> y = x.amin(axis=1)
>>> print(y)
{
    a:ivy.array([1, -1]),
    b:ivy.array([2, 0])
}
binarizer(*, threshold=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Map the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.

Parameters:
  • threshold (Union[float, Container], default: 0) – Values greater than this are mapped to 1, others to 0.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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 – Binarized output data

conj(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.conj. This method simply wraps the function, and so the docstring for ivy.conj 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 containing output array(s) of the same dtype as the input array(s) with the complex conjugates of the complex values present in the input array. If x is a container of scalar(s) then a container of scalar(s) will be returned.

Examples

>>> x = ivy.Container(a=ivy.array([-1j, 0.335+2.345j, 1.23+7j]),                          b=ivy.array([0.0, 1.2+3.3j, 1+0j]))
>>> x.conj()
{
    a: ivy.array([1j, 0.335-2345j, 1.23-7j]),
    b: ivy.array([0.0, 1.2-3.3j, 1-0j])
}
copysign(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – Container to change the sign of

  • x2 (Container) – Container from which the new signs are applied Unsigned zeroes are considered positive.

  • out (Optional[Container], default: None) – optional output Container, for writing the result to.

Return type:

Container

Returns:

ret – x1 with the signs of x2. This is a scalar if both x1 and x2 are scalars.

Examples

>>> x1 = ivy.Container(a=ivy.array([0,1,2]), b=ivy.array(-1))
>>> x2 = ivy.Container(a=-1, b=ivy.array(10))
>>> x1.copysign(x2)
{
    a: ivy.array([-0., -1., -2.]),
    b: ivy.array(1.)
}
>>> x1.copysign(-1)
{
    a: ivy.array([-0., -1., -2.]),
    b: ivy.array(-1.)
}
count_nonzero(*, axis=None, keepdims=False, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – container with the base input arrays.

  • axis (Optional[Union[int, Tuple[int, ...], Container]], default: None) – optional axis or tuple of axes along which to count non-zeros. Default is None, meaning that non-zeros will be counted along a flattened version of the input array.

  • keepdims (Union[bool, Container], default: False) – optional, if this is set to True, the axes that are counted are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – optional output dtype. Default is of type integer.

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

Return type:

Container

Returns:

ret – Container including number of non-zero values in the array along a given axis. Otherwise, container with the total number of non-zero values in the array is returned.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> x.count_nonzero()
{
    a: ivy.array(7),
    b: ivy.array(7)
}
>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> x.count_nonzero(axis=0)
{
    a: ivy.array([1, 2, 2, 2]),
    b: ivy.array([[1, 2],
                  [2, 2]])
}
>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> x.count_nonzero(axis=(0,1), keepdims=True)
{
    a: ivy.array([[7]]),
    b: ivy.array([[[3, 4]]])
}
diff(*, n=1, axis=-1, prepend=None, append=None, out=None)[source]#

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

Parameters:
  • self (Container) – input container with array-like items.

  • n (Union[int, Container], default: 1) – The number of times values are differenced. If zero, the input is returned as-is.

  • axis (Union[int, Container], default: -1) – The axis along which the difference is taken, default is the last axis.

  • prepend (Optional[Union[Array, NativeArray, int, list, tuple, Container]], default: None) – Values to prepend/append to x along given axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.

  • append (Optional[Union[Array, NativeArray, int, list, tuple, Container]], default: None) – Values to prepend/append to x along given axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with the n-th discrete difference along the given axis.

Examples

>>> x = ivy.Container(a=ivy.array([1, 2, 4, 7, 0]),
                      b=ivy.array([1, 2, 4, 7, 0]))
>>> x.diff()
{
    a: ivy.array([1, 2, 3, -7]),
    b: ivy.array([1, 2, 3, -7])
}
digamma(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Note

The Ivy version only accepts real-valued inputs.

Parameters:
  • self (Container) – Input container containing input arrays.

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

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

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

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

  • out (Optional[Container], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the digamma function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([1, 0.5]), b=ivy.array([2.0, 3.0])
>>> x.digamma()
{
    a: ivy.array([-0.5772, -1.9635]),
    b: ivy.array([0.4228, 0.9228])
}
erfc(*, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose array contains real or complex valued argument.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container with values of the complementary error function.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([-1., -2., -3.])) >>> x.erfc() {

a: ivy.array([1.57299206e-01, 4.67773480e-03, 2.20904985e-05]), b: ivy.array([1.84270084, 1.99532223, 1.99997795])

}

erfinv(*, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose array contains real or complex valued argument.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container with values of the inverse error function.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([-1., -2., -3.])) >>> x.erfinv() {

a: ivy.array([1.57299206e-01, 4.67773480e-03, 2.20904985e-05]), b: ivy.array([1.84270084, 1.99532223, 1.99997795])

}

fix(*, out=None)[source]#

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

Parameters:
  • self (Container) – input container with array items.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise rounding of input arrays elements.

Examples

>>> x = ivy.Container(a=ivy.array([2.1, 2.9, -2.1]),                               b=ivy.array([3.14]))
>>> x.fix()
{
    a: ivy.array([ 2.,  2., -2.])
    b: ivy.array([ 3.0 ])
}
float_power(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – container with the base input arrays.

  • x2 (Container) – container with the exponent input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with base arrays raised to the powers of exponents arrays, element-wise .

Examples

>>> x1 = ivy.Container(a=ivy.array([1, 2, 3]),                               b=ivy.array([2, 10]))
>>> x2 = ivy.Container(a=ivy.array([1, 3, 1]), b=0)
>>> x1.float_power(x2)
{
    a: ivy.array([1,  8,  3])
    b: ivy.array([1, 1])
}
fmax(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – container with the first input arrays.

  • x2 (Container) – container with the second input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise maximums.

Examples

>>> x1 = ivy.Container(a=ivy.array([2, 3, 4]),                               b=ivy.array([ivy.nan, 0, ivy.nan]))
>>> x2 = ivy.Container(a=ivy.array([1, 5, 2]),                               b=ivy.array([0, ivy.nan, ivy.nan]))
>>> x1.fmax(x2)
{
    a: ivy.array([ 2.,  5.,  4.])
    b: ivy.array([ 0,  0,  nan])
}
fmod(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – container with the first input arrays.

  • x2 (Container) – container with the second input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise remainder of divisions.

Examples

>>> x1 = ivy.Container(a=ivy.array([2, 3, 4]),                               b=ivy.array([ivy.nan, 0, ivy.nan]))
>>> x2 = ivy.Container(a=ivy.array([1, 5, 2]),                               b=ivy.array([0, ivy.nan, ivy.nan]))
>>> x1.fmod(x2)
{
    a: ivy.array([ 0,  3,  0])
    b: ivy.array([ nan,  nan,  nan])
}
frexp(*, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose arrays should be split into mantissa and exponent.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the mantissa and exponent of x.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x.frexp() {

a: (ivy.array([0.5, 0.5, 0.75]), ivy.array([1, 1, 2])), b: (ivy.array([0.5, 0.625, 0.625]), ivy.array([1, 3, 4]))

}

gradient(*, spacing=1, edge_order=1, axis=None)[source]#

Calculate gradient of x with respect to (w.r.t.) spacing.

Parameters:
  • x – input array representing outcomes of the function spacing if not given, indices of x will be used if scalar indices of x will be scaled with this value if array gradient of x w.r.t. spacing

  • edge_order (Union[int, Container], default: 1) – 1 or 2, for ‘frist order’ and ‘second order’ estimation of boundary values of gradient respectively.

  • axis (Optional[Union[int, list, tuple, Container]], default: None) – dimension(s) to approximate the gradient over. By default, partial gradient is computed in every dimension

Return type:

Container

Returns:

ret – Array with values computed from gradient function from inputs

Examples

>>> coordinates = ivy.Container(
>>>     a=(ivy.array([-2., -1., 1., 4.]),),
>>>     b=(ivy.array([2., 1., -1., -4.]),)
>>> )
>>> values = ivy.Container(
>>>     a=ivy.array([4., 1., 1., 16.]),
>>>     b=ivy.array([4., 1., 1., 16.])
>>> )
>>> ivy.gradient(values, spacing=coordinates)
{
    a: ivy.array([-3., -2., 2., 5.]),
    b: ivy.array([3., 2., -2., -5.])
}
>>> values = ivy.Container(
>>>     a=ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]),
>>>     b=ivy.array([[-1, -2, -4, -8], [-10, -20, -40, -80]])
>>> )
>>> ivy.gradient(values)
[{
    a: ivy.array([[9., 18., 36., 72.],
                  [9., 18., 36., 72.]]),
    b: ivy.array([[-9., -18., -36., -72.],
                  [-9., -18., -36., -72.]])
}, {
    a: ivy.array([[1., 1.5, 3., 4.],
                  [10., 15., 30., 40.]]),
    b: ivy.array([[-1., -1.5, -3., -4.],
                  [-10., -15., -30., -40.]])
}]
>>> values = ivy.Container(
>>>     a=ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]),
>>>     b=ivy.array([[-1, -2, -4, -8], [-10, -20, -40, -80]])
>>> )
>>> ivy.gradient(values, spacing=2.0)
[{
    a: ivy.array([[4.5, 9., 18., 36.],
                  [4.5, 9., 18., 36.]]),
    b: ivy.array([[-4.5, -9., -18., -36.],
                  [-4.5, -9., -18., -36.]])
}, {
    a: ivy.array([[0.5, 0.75, 1.5, 2.],
                  [5., 7.5, 15., 20.]]),
    b: ivy.array([[-0.5, -0.75, -1.5, -2.],
                  [-5., -7.5, -15., -20.]])
}]
>>> values = ivy.Container(
>>>     a=ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]),
>>>     b=ivy.array([[-1, -2, -4, -8], [-10, -20, -40, -80]])
>>> )
>>> ivy.gradient(values, axis=1)
{
    a: ivy.array([[1., 1.5, 3., 4.],
                  [10., 15., 30., 40.]]),
    b: ivy.array([[-1., -1.5, -3., -4.],
                  [-10., -15., -30., -40.]])
}
>>> values = ivy.Container(
>>>     a=ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]),
>>>     b=ivy.array([[-1, -2, -4, -8], [-10, -20, -40, -80]])
>>> )
>>> ivy.gradient(values, spacing = [3., 2.])
[{
    a: ivy.array([[3., 6., 12., 24.],
                  [3., 6., 12., 24.]]),
    b: ivy.array([[-3., -6., -12., -24.],
                  [-3., -6., -12., -24.]])
}, {
    a: ivy.array([[0.5, 0.75, 1.5, 2.],
                  [5., 7.5, 15., 20.]]),
    b: ivy.array([[-0.5, -0.75, -1.5, -2.],
                  [-5., -7.5, -15., -20.]])
}]
>>> coords = ivy.Container(
>>>    a=(ivy.array([0, 2]), ivy.array([0, 3, 6, 9])),
>>>    b=(ivy.array([0, -2]), ivy.array([0, -3, -6, -9]))
>>>)
>>> values = ivy.Container(
>>>     a=ivy.array([[1, 2, 4, 8], [10, 20, 40, 80]]),
>>>     b=ivy.array([[-1, -2, -4, -8], [-10, -20, -40, -80]])
>>>)
>>> ivy.gradient(values, spacing = coords)
[{
    a: ivy.array([[4.5, 9., 18., 36.],
                  [4.5, 9., 18., 36.]]),
    b: ivy.array([[4.5, 9., 18., 36.],
                  [4.5, 9., 18., 36.]])
}, {
    a: ivy.array([[0.33333333, 0.5, 1., 1.33333333],
                  [3.33333333, 5., 10., 13.33333333]]),
    b: ivy.array([[0.33333333, 0.5, 1., 1.33333333],
                  [3.33333333, 5., 10., 13.33333333]])
}]
hypot(x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • x2 (Container) – Input container containing second input array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the hypot function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([2.0]),        ...                         b=ivy.array([3.0]))
>>> y = ivy.Container(a=ivy.array([3.0]),                                    b=ivy.array([4.0]))
>>> x.hypot(y)
{
    a: ivy.array([3.6055]),
    b: ivy.array([5.])
}
isclose(b, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • b (Container) – Input container containing second input array.

  • rtol (Union[float, Container], default: 1e-05) – The relative tolerance parameter.

  • atol (Union[float, Container], default: 1e-08) – The absolute tolerance parameter.

  • equal_nan (Union[bool, Container], default: False) – Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new array holding the result is returned unless out is specified, in which it is returned.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1.0, ivy.nan]), b=ivy.array([1.0, ivy.nan])) >>> y = ivy.Container(a=ivy.array([1.0, ivy.nan]), b=ivy.array([1.0, ivy.nan])) >>> x.isclose(y) {

a: ivy.array([True, False]), b: ivy.array([True, False])

} >>> x.isclose(y, equal_nan=True) {

a: ivy.array([True, True]), b: ivy.array([True, True])

} >>> x = ivy.Container(a=ivy.array([1.0, 2.0]), b=ivy.array([1.0, 2.0])) >>> y = ivy.Container(a=ivy.array([1.0, 2.001]), b=ivy.array([1.0, 2.0])) >>> x.isclose(y, atol=0.0) {

a: ivy.array([True, False]), b: ivy.array([True, True])

} >>> x.isclose(y, rtol=0.01, atol=0.0) {

a: ivy.array([True, True]), b: ivy.array([True, True])

}

ldexp(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose arrays should be multiplied by 2**x2.

  • x2 (Union[Array, NativeArray, Container]) – The container whose arrays should be used to multiply x1 by 2**x2.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including x1 * 2**x2.

Examples

With one ivy.Container input: >>> x1 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x2 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x1.ldexp(x2) {

a: ivy.array([2, 8, 24]), b: ivy.array([2, 160, 10240])

}

lerp(end, weight, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose arrays should be used as parameter: input

  • end (Union[Array, NativeArray, Container]) – The container whose arrays should be used as parameter: end

  • weight (Union[Array, NativeArray, float, Container]) – The container whose arrays or scalar should be used as parameter: weight

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including input + ((end - input) * weight)

Examples

With one ivy.Container input: >>> input = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> end = ivy.Container(a=ivy.array([10, 10, 10]), b=ivy.array([20, 20, 20])) >>> weight = ivy.Container(a=ivy.array(0.5), b=ivy.array([0.4, 0.5, 0.6])) >>> input.lerp(end, weight) {

a: ivy.array([5.5, 6., 6.5]), b: ivy.array([8.60000038, 12.5, 16.])

}

modf(*, out=None)[source]#

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

Parameters:
  • self (Container) – The container whose arrays should be split into the fractional and integral parts.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the fractional and integral parts of x.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1.2, 2.7, 3.9]), >>> b = ivy.array([-1.5, 5.3, -10.7])) >>> x.modf() {

a: (ivy.array([0.2, 0.7, 0.9]), ivy.array([1.0, 2.0, 3.0])), b: (ivy.array([-0.5, 0.3, -0.7]), ivy.array([-1.0, 5.0, -10.0]))

}

nansum(*, axis=None, dtype=None, keepdims=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • axis (Optional[Union[tuple, int, Container]], default: None) – Axis or axes along which the sum is computed. The default is to compute the sum of the flattened array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of input is used.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

  • out (Optional[Container], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new array holding the result is returned unless out is specified, in which it is returned.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([[10, 7, 4], [3, 2, 1]]), b=ivy.array([[1, 4, 2], [ivy.nan, ivy.nan, 0]])) >>> x.nansum(axis=0) {

a: ivy.array([13, 9, 5]), b: ivy.array([1., 4., 2.])

} >>> x.nansum(axis=1) {

a: ivy.array([21, 6]), b: ivy.array([7., 0.])

}

nextafter(x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • x2 (Container) – Input container containing second input array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the next representable values of input container’s arrays, element-wise

Examples

>>> x1 = ivy.Container(a=ivy.array([1.0e-50, 2.0e+50]),        ...                         b=ivy.array([2.0, 1.0])
>>> x2 = ivy.Container(a=ivy.array([5.5e-30]),        ...                         b=ivy.array([-2.0]))
>>> x1.nextafter(x2)
{
    a: ivy.array([1.4013e-45., 3.4028e+38]),
    b: ivy.array([5.5e-30])
}
signbit(*, out=None)[source]#

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

Parameters:
  • self (Container) – input container with array-like items.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise signbit of input arrays.

Examples

>>> x = ivy.Container(a=ivy.array([1, -2, 3]),                               b=-5)
>>> x.signbit()
{
    a: ivy.array([False, True, False])
    b: ivy.array([True])
}
sinc(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container whose elements are each expressed in radians. Should have a floating-point data type.

  • 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 containing the sinc of each element in self. The returned container must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.Container(a=ivy.array([0.5, 1.5, 2.5]),
...                   b=ivy.array([3.5, 4.5, 5.5]))
>>> y = x.sinc()
>>> print(y)
{
    a: ivy.array([0.637,-0.212,0.127]),
    b: ivy.array([-0.0909,0.0707,-0.0579])
}
sparsify_tensor(card, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.sparsify_tensor.

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

Return type:

Container

static static_allclose(x1, x2, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Container, Array, NativeArray]) – Input container containing first input array.

  • x2 (Union[Container, Array, NativeArray]) – Input container containing second input array.

  • rtol (Union[float, Container], default: 1e-05) – The relative tolerance parameter.

  • atol (Union[float, Container], default: 1e-08) – The absolute tolerance parameter.

  • equal_nan (Union[bool, Container], default: False) – Whether to compare NaN’s as equal. If True, NaN’s in x1 will be considered equal to NaN’s in x2 in the output array.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new container holding the result is returned unless out is specified, in which it is returned.

Examples

>>> x1 = ivy.Container(a=ivy.array([1., 2., 3.]),        ...                         b=ivy.array([1., 2., 3.]))
>>> x2 = ivy.Container(a=ivy.array([1., 2., 3.]),        ...                         b=ivy.array([1., 2., 3.]))
>>> y = ivy.Container.static_allclose(x1, x2)
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(True)
}
>>> x1 = ivy.Container(a=ivy.array([1., 2., 3.]),        ...                         b=ivy.array([1., 2., 3.]))
>>> x2 = ivy.Container(a=ivy.array([1., 2., 3.0003]),        ...                         b=ivy.array([1.0006, 2., 3.]))
>>> y = ivy.Container.static_allclose(x1, x2, rtol=1e-3)
>>> print(y)
{
    a: ivy.array(True),
    b: ivy.array(True)
}
static static_amax(x, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – input container. Should have a real-valued data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – axis or axes along which maximum values must be computed. By default, the maximum value must be computed over the entire array. If a tuple of integers, maximum values must be computed over multiple axes. Default: None.

  • keepdims (Union[bool, Container], default: False) – optional boolean, if True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/ latest/API_specification/ broadcasting.html#broadcasting>`_). Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – container, if the maximum value was computed over the entire array, a zero-dimensional array containing the maximum value; otherwise, a non-zero-dimensional array containing the maximum values. The returned array must have the same data type as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]),
...                   b=ivy.array([2, 3, 4]))
>>> y = ivy.Container.static_amax(x)
>>> print(y)
{
    a: ivy.array(3),
    b: ivy.array(4)
}
>>> x = ivy.Container(a=ivy.array([[1, 2, 3], [-1, 0, 2]]),
...                   b=ivy.array([[2, 3, 4], [0, 1, 2]]))
>>> y = ivy.Container.static_amax(x, axis=1)
>>> print(y)
{
    a:ivy.array([3, 2]),
    b:ivy.array([4, 2])
}
static static_amin(x, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – input container. Should have a real-valued data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – axis or axes along which minimum values must be computed. By default, the minimum value must be computed over the entire array. If a tuple of integers, minimum values must be computed over multiple axes. Default: None.

  • keepdims (Union[bool, Container], default: False) – optional boolean, if True, the reduced axes (dimensions) must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see `broadcasting<https://data-apis.org/array-api/latest/ API_specification/broadcasting.html#broadcasting>`_). Otherwise, if False, the reduced axes (dimensions) must not be included in the result. Default: False.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – container, if the minimum value was computed over the entire array, a zero-dimensional array containing the minimum value; otherwise, a non-zero-dimensional array containing the minimum values. The returned array must have the same data type as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]),
...                   b=ivy.array([2, 3, 4]))
>>> y = ivy.Container.static_amin(x)
>>> print(y)
{
    a: ivy.array(1),
    b: ivy.array(2)
}
>>> x = ivy.Container(a=ivy.array([[1, 2, 3], [-1, 0, 2]]),
...                   b=ivy.array([[2, 3, 4], [0, 1, 2]]))
>>> y = ivy.Container.static_amin(x, axis=1)
>>> print(y)
{
    a:ivy.array([1, -1]),
    b:ivy.array([2, 0])
}
static static_binarizer(x, /, *, threshold=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Map the values of the input tensor to either 0 or 1, element-wise, based on the outcome of a comparison against a threshold value.

Parameters:
  • self – input container. Should have a real-valued floating-point data type.

  • threshold (Union[float, Container], default: 0) – Values greater than this are mapped to 1, others to 0.

  • 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 – Binarized output data

static static_conj(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – 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 containing output array(s) of the same dtype as the input array(s) with the complex conjugates of the complex values present in the input array. If x is a container of scalar(s) then a container of scalar(s) will be returned.

Examples

>>> x = ivy.Container(a=ivy.array([-1+5j, 0-0j, 1.23j]),
...                   b=ivy.array([7.9, 0.31+3.3j, -4.2-5.9j]))
>>> z = ivy.Container.static_conj(x)
>>> print(z)
{
    a: ivy.array([-1-5j, 0+0j, -1.23j]),
    b: ivy.array([7.9, 0.31-3.3j, -4.2+5.9j])
}
static static_copysign(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container, Number]) – Container, Array, or scalar to change the sign of

  • x2 (Union[Array, NativeArray, Container, Number]) – Container, Array, or scalar from which the new signs are applied Unsigned zeroes are considered positive.

  • out (Optional[Container], default: None) – optional output Container, for writing the result to.

Return type:

Container

Returns:

ret – x1 with the signs of x2. This is a scalar if both x1 and x2 are scalars.

Examples

>>> x1 = ivy.Container(a=ivy.array([0,1,2]), b=ivy.array(-1))
>>> x2 = ivy.Container(a=-1, b=ivy.array(10))
>>> ivy.Container.static_copysign(x1, x2)
{
    a: ivy.array([-0., -1., -2.]),
    b: ivy.array(1.)
}
>>> ivy.Container.static_copysign(23, x1)
{
    a: ivy.array([23., 23., 23.]),
    b: ivy.array(-23.)
}
static static_count_nonzero(a, /, *, axis=None, keepdims=False, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Array, NativeArray, Container]) – container with the base input arrays.

  • axis (Optional[Union[int, Tuple[int, ...], Container]], default: None) – optional axis or tuple of axes along which to count non-zeros. Default is None, meaning that non-zeros will be counted along a flattened version of the input array.

  • keepdims (Union[bool, Container], default: False) – optional, if this is set to True, the axes that are counted are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the input array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – optional output dtype. Default is of type integer.

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

Return type:

Container

Returns:

ret – Container including number of non-zero values in the array along a given axis. Otherwise, container with the total number of non-zero values in the array is returned.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> ivy.Container.static_count_nonzero(x)
{
    a: ivy.array(7),
    b: ivy.array(7)
}
>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> ivy.Container.static_count_nonzero(x, axis=0)
{
    a: ivy.array([1, 2, 2, 2]),
    b: ivy.array([[1, 2],
                  [2, 2]])
}
>>> x = ivy.Container(a=ivy.array([[0, 1, 2, 3],[4, 5, 6, 7]]),                        b=ivy.array([[[0,1],[2,3]],[[4,5],[6,7]]]))
>>> ivy.Container.static_count_nonzero(x, axis=(0,1), keepdims=True)
{
    a: ivy.array([[7]]),
    b: ivy.array([[[3, 4]]])
}
static static_diff(x, /, *, n=1, axis=-1, prepend=None, append=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – input container with array-like items.

  • n (Union[int, Container], default: 1) – The number of times values are differenced. If zero, the input is returned as-is.

  • axis (Union[int, Container], default: -1) – The axis along which the difference is taken, default is the last axis.

  • prepend (Optional[Union[Array, NativeArray, int, list, tuple, Container]], default: None) – Values to prepend/append to x along given axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.

  • append (Optional[Union[Array, NativeArray, int, list, tuple, Container]], default: None) – Values to prepend/append to x along given axis prior to performing the difference. Scalar values are expanded to arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match x except along axis.

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

Return type:

Container

Returns:

ret – Container including arrays with the n-th discrete difference along the given axis.

Examples

>>> x = ivy.Container(a=ivy.array([1, 2, 4, 7, 0]),
                      b=ivy.array([1, 2, 4, 7, 0]))
>>> ivy.Container.static_diff(x)
{
    a: ivy.array([ 1,  2,  3, -7]),
    b: ivy.array([ 1,  2,  3, -7])
}
static static_digamma(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Note

The Ivy version only accepts real-valued inputs.

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input container containing input arrays.

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

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

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

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

  • out (Optional[Array], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the digamma function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([1, 0.5]),        ...                         b=ivy.array([-2.0, 3.0]))
>>> ivy.Container.static_digamma(x)
{
    a: ivy.array([-0.57721537, -1.96351004]),
    b: ivy.array([nan, 0.92278427])
}
static static_erfc(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – The container whose array contains real or complex valued argument.

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

Return type:

Container

Returns:

ret – container with values of the complementary error function.

Examples

>>> x = ivy.Container(a=ivy.array([1., 2.]), b=ivy.array([-3., -4.]))
>>> ivy.Container.static_erfc(x)
{
    a: ivy.array([0.15729921, 0.00467773]),
    b: ivy.array([1.99997795, 2.])
}
static static_erfinv(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – The container whose array contains real or complex valued argument.

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

Return type:

Container

Returns:

ret – container with values of the inverse error function.

Examples

>>> x = ivy.Container(a=ivy.array([1., 2.]), b=ivy.array([-3., -4.]))
>>> ivy.Container.static_erfinv(x)
{
    a: ivy.array([0.15729921, 0.00467773]),
    b: ivy.array([1.99997795, 2.])
}
static static_fix(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise rounding of input arrays elements.

Examples

>>> x = ivy.Container(a=ivy.array([2.1, 2.9, -2.1]),                               b=ivy.array([3.14]))
>>> ivy.Container.static_fix(x)
{
    a: ivy.array([ 2.,  2., -2.])
    b: ivy.array([ 3.0 ])
}
static static_float_power(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container, float, list, tuple]) – container with the base input arrays.

  • x2 (Union[Array, NativeArray, Container, float, list, tuple]) – container with the exponent input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with base arrays raised to the powers of exponents arrays, element-wise .

Examples

>>> x1 = ivy.Container(a=ivy.array([1, 2, 3]),                               b=ivy.array([2, 10]))
>>> x2 = ivy.Container(a=ivy.array([1, 3, 1]), b=0)
>>> ivy.Container.static_float_power(x1, x2)
{
    a: ivy.array([1,  8,  3])
    b: ivy.array([1, 1])
}
static static_fmax(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – container with the first input arrays.

  • x2 (Union[Array, NativeArray, Container]) – container with the second input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise maximums.

Examples

>>> x1 = ivy.Container(a=ivy.array([2, 3, 4]),                               b=ivy.array([ivy.nan, 0, ivy.nan]))
>>> x2 = ivy.Container(a=ivy.array([1, 5, 2]),                               b=ivy.array([0, ivy.nan, ivy.nan]))
>>> ivy.Container.static_fmax(x1, x2)
{
    a: ivy.array([ 2.,  5.,  4.])
    b: ivy.array([ 0,  0,  nan])
}
static static_fmod(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – container with the first input arrays.

  • x2 (Union[Array, NativeArray, Container]) – container with the second input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise remainder of divisions.

Examples

>>> x1 = ivy.Container(a=ivy.array([2, 3, 4]),                               b=ivy.array([ivy.nan, 0, ivy.nan]))
>>> x2 = ivy.Container(a=ivy.array([1, 5, 2]),                               b=ivy.array([0, ivy.nan, ivy.nan]))
>>> ivy.Container.static_fmod(x1, x2)
{
    a: ivy.array([ 0,  3,  0])
    b: ivy.array([ nan,  nan,  nan])
}
static static_frexp(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – The container whose arrays should be split into mantissa and exponent.

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

Return type:

Container

Returns:

ret – container including the mantissa and exponent of x.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> ivy.Container.static_frexp(x) {

a: (ivy.array([0.5, 0.5, 0.75]), ivy.array([1, 1, 2])), b: (ivy.array([0.5, 0.625, 0.625]), ivy.array([1, 3, 4]))

}

static static_gradient(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, spacing=1, edge_order=1, axis=None)[source]#
Return type:

Container

static static_hypot(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Container, Array, NativeArray]) – Input container containing first input array.

  • x2 (Union[Container, Array, NativeArray]) – Input container containing second input array.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the hypot function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([2.0]),        ...                         b=ivy.array([3.0]))
>>> y = ivy.Container(a=ivy.array([3.0]),                                    b=ivy.array([4.0]))
>>> ivy.Container.static_hypot(x, y)
{
    a: ivy.array([3.6055]),
    b: ivy.array([5.])
}
static static_isclose(a, b, /, *, rtol=1e-05, atol=1e-08, equal_nan=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Container, Array, NativeArray]) – Input container containing first input array.

  • b (Union[Container, Array, NativeArray]) – Input container containing second input array.

  • rtol (Union[float, Container], default: 1e-05) – The relative tolerance parameter.

  • atol (Union[float, Container], default: 1e-08) – The absolute tolerance parameter.

  • equal_nan (Union[bool, Container], default: False) – Whether to compare NaN’s as equal. If True, NaN’s in a will be considered equal to NaN’s in b in the output array.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new array holding the result is returned unless out is specified, in which it is returned.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1.0, ivy.nan]), b=ivy.array([1.0, ivy.nan])) >>> y = ivy.Container(a=ivy.array([1.0, ivy.nan]), b=ivy.array([1.0, ivy.nan])) >>> ivy.Container.static_isclose(x, y) {

a: ivy.array([True, False]), b: ivy.array([True, False])

} >>> ivy.Container.static_isclose(x, y, equal_nan=True) {

a: ivy.array([True, True]), b: ivy.array([True, True])

} >>> x = ivy.Container(a=ivy.array([1.0, 2.0]), b=ivy.array([1.0, 2.0])) >>> y = ivy.Container(a=ivy.array([1.0, 2.001]), b=ivy.array([1.0, 2.0])) >>> ivy.Container.static_isclose(x, y, atol=0.0) {

a: ivy.array([True, False]), b: ivy.array([True, True])

} >>> ivy.Container.static_isclose(x, y, rtol=0.01, atol=0.0) {

a: ivy.array([True, True]), b: ivy.array([True, True])

}

static static_ldexp(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – The container whose arrays should be multiplied by 2**i.

  • x2 (Union[Array, NativeArray, Container]) – The container whose arrays should be used to multiply x by 2**i.

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

Return type:

Container

Returns:

ret – container including x1 * 2**x2.

Examples

With one ivy.Container input: >>> x1 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> x2 = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([1, 5, 10])) >>> ivy.Container.static_ldexp(x1, x2) {

a: ivy.array([2, 8, 24]), b: ivy.array([2, 160, 10240])

}

static static_lerp(input, end, weight, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Union[Array, NativeArray, Container]) – The container whose arrays should be used as parameter: input

  • end (Union[Array, NativeArray, Container]) – The container whose arrays should be used as parameter: end

  • weight (Union[Array, NativeArray, float, Container]) – The container whose arrays or scalar should be used as parameter: weight

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

Return type:

Container

Returns:

ret – container including input + ((end - input) * weight)

Examples

With one ivy.Container input: >>> input = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.])) >>> end = ivy.array([10.]) >>> weight = 1.1 >>> y = ivy.Container.static_lerp(input, end, weight) >>> print(y) {

a: ivy.array([11., 10.90000057, 10.80000019]), b: ivy.array([10.70000076, 10.60000038, 10.5])

} >>> input = ivy.Container(a=ivy.array([10.1, 11.1]), b=ivy.array([10, 11])) >>> end = ivy.Container(a=ivy.array([5])) >>> weight = ivy.Container(a=0.5) >>> y = ivy.Container.static_lerp(input, end, weight) >>> print(y) {

a: ivy.array([7.55000019, 8.05000019]), b: {

a: ivy.array([7.5, 8.])

}

}

static static_modf(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – The container whose arrays should be split into the fractional and integral parts.

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

Return type:

Container

Returns:

ret – container including the fractional and integral parts of x.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1.2, 2.7, 3.9]), >>> b = ivy.array([-1.5, 5.3, -10.7])) >>> ivy.Container.static_modf(x) {

a: (ivy.array([0.2, 0.7, 0.9]), ivy.array([1.0, 2.0, 3.0])), b: (ivy.array([-0.5, 0.3, -0.7]), ivy.array([-1.0, 5.0, -10.0]))

}

static static_nansum(x, /, *, axis=None, dtype=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

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

  • axis (Optional[Union[tuple, int, Container]], default: None) – Axis or axes along which the sum is computed. The default is to compute the sum of the flattened array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The type of the returned array and of the accumulator in which the elements are summed. By default, the dtype of input is used.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

  • out (Optional[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – A new array holding the result is returned unless out is specified, in which it is returned.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([[10, 7, 4], [3, 2, 1]]), b=ivy.array([[1, 4, 2], [ivy.nan, ivy.nan, 0]])) >>> ivy.Container.static_nansum(x) {

a: 27, b: 7.0

} >>> ivy.Container.static_nansum(x, axis=0) {

a: ivy.array([13, 9, 5]), b: ivy.array([1., 4., 2.])

} >>> ivy.Container.static_nansum(x, axis=1) {

a: ivy.array([21, 6]), b: ivy.array([7., 0.])

}

static static_nextafter(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Container, Array, NativeArray]) – Input container containing first input arrays.

  • x2 (Union[Container, Array, NativeArray]) – Input container containing second input arrays.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the next representable values of input container’s arrays, element-wise

Examples

>>> x1 = ivy.Container(a=ivy.array([1.0e-50, 2.0e+50]),        ...                         b=ivy.array([2.0, 1.0])
>>> x2 = ivy.Container(a=ivy.array([5.5e-30]),        ...                         b=ivy.array([-2.0]))
>>> ivy.Container.static_nextafter(x1, x2)
{
    a: ivy.array([1.4013e-45., 3.4028e+38]),
    b: ivy.array([5.5e-30])
}
static static_signbit(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container, float, int, list, tuple]) – input container with array-like items.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with element-wise signbit of input arrays.

Examples

>>> x = ivy.Container(a=ivy.array([1, -2, 3]),                               b=-5)
>>> ivy.Container.static_signbit(x)
{
    a: ivy.array([False, True, False])
    b: ivy.array([True])
}
static static_sinc(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – input container whose elements are each expressed in radians. Should have a floating-point data type.

  • 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 containing the sinc of each element in x. The returned container must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.Container(a=ivy.array([0.5, 1.5, 2.5]),
...                   b=ivy.array([3.5, 4.5, 5.5]))
>>> y = ivy.Container.static_sinc(x)
>>> print(y)
{
    a: ivy.array([0.636, -0.212, 0.127]),
    b: ivy.array([-0.090, 0.070, -0.057])
}
static static_sparsify_tensor(x, card, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input container containing input arrays.

  • card (Union[int, Container]) – The number of values to keep in each tensor.

  • key_chains (Optional[Union[List[str], Dict[str, str]]], 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) – Alternate output container in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the sparsified tensor computed element-wise

Examples

>>> x = ivy.Container(
        a=ivy.reshape(ivy.arange(100), (10, 10)),
        b=ivy.reshape(ivy.arange(100), (10, 10)),
    )
>>> ivy.Container.static_sparsify_tensor(x, 10)
    {
        a: (<class ivy.data_classes.array.array.Array> shape=[10, 10]),
        b: (<class ivy.data_classes.array.array.Array> shape=[10, 10])
    }
static static_xlogy(x, y, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input container containing first input arrays.

  • y (Union[Container, Array, NativeArray]) – Input container containing second input arrays.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the next representable values of input container’s arrays, element-wise

Examples

>>> x = ivy.Container(a=ivy.zeros(3)),        ...                         b=ivy.array([1.0, 2.0, 3.0]))
>>> y = ivy.Container(a=ivy.array([-1.0, 0.0, 1.0]),        ...                         b=ivy.array([3.0, 2.0, 1.0]))
>>> ivy.Container.static_xlogy(x, y)
{
    a: ivy.array([0.0, 0.0, 0.0]),
    b: ivy.array([1.0986, 1.3863, 0.0000])
}
static static_zeta(x, q, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input container containing first input arrays.

  • q (Union[Container, Array, NativeArray]) – Input container containing second input arrays.

  • 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[Union[Array, Container]], default: None) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the zeta function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([5.0, 3.0]),        ...                         b=ivy.array([2.0, 1.0])
>>> q = ivy.Container(a=ivy.array([2.0]),        ...                         b=ivy.array([5.0]))
>>> ivy.Container.static_zeta(x1, x2)
{
    a: ivy.array([0.0369, 0.2021]),
    b: ivy.array([0.0006, 0.0244])
}
xlogy(y, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • y (Container) – Input container containing second input array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the next representable values of input container’s arrays, element-wise

Examples

>>> x = ivy.Container(a=ivy.zeros(3)),        ...                         b=ivy.array([1.0, 2.0, 3.0]))
>>> y = ivy.Container(a=ivy.array([-1.0, 0.0, 1.0]),        ...                         b=ivy.array([3.0, 2.0, 1.0]))
>>> x.xlogy(y)
{
    a: ivy.array([0.0, 0.0, 0.0]),
    b: ivy.array([1.0986, 1.3863, 0.0000])
}
zeta(q, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container containing first input array.

  • q (Container) – Input container containing second input array.

  • 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) – Alternate output array in which to place the result. The default is None.

Return type:

Container

Returns:

ret – container including the zeta function computed element-wise

Examples

>>> x = ivy.Container(a=ivy.array([5.0, 3.0]),        ...                         b=ivy.array([2.0, 1.0])
>>> q = ivy.Container(a=ivy.array([2.0]),        ...                         b=ivy.array([5.0]))
>>> x.zeta(q)
{
    a: ivy.array([0.0369, 0.2021]),
    b: ivy.array([0.0006, 0.0244])
}
class ivy.data_classes.container.experimental.general._ContainerWithGeneralExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_reduce(operand, init_value, computation, /, *, axes=0, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • operand (Union[Container, Array, NativeArray]) – The array to act on.

  • init_value (Union[int, float, Container]) – The value with which to start the reduction.

  • computation (Union[Callable, Container]) – The reduction function.

  • axes (Union[int, Sequence[int], Container], default: 0) – The dimensions along which the reduction is performed.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

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

Return type:

Container

Returns:

ret – The reduced array.

Examples

>>> x = ivy.Container(
>>>     a=ivy.array([[1, 2, 3], [4, 5, 6]]),
>>>     b=ivy.native_array([[7, 8, 9], [10, 5, 1]])
>>> )
>>> y = ivy.Container.static_reduce(x, 0, ivy.add)
>>> print(y)
{
    a: ivy.array([6, 15]),
    b: ivy.array([24, 16])
}
reduce(init_value, computation, /, *, axes=0, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – The array to act on.

  • init_value (Union[int, float, Container]) – The value with which to start the reduction.

  • computation (Union[Callable, Container]) – The reduction function.

  • axes (Union[int, Sequence[int], Container], default: 0) – The dimensions along which the reduction is performed.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

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

Return type:

Container

Returns:

ret – The reduced array.

Examples

>>> x = ivy.Container(
...     a=ivy.array([[1, 2, 3], [4, 5, 6]]),
...     b=ivy.native_array([[7, 8, 9], [10, 5, 1]]))
>>> y = x.reduce(0, ivy.add)
>>> print(y)
{
    a: ivy.array([5, 7, 9]),
    b: ivy.array([17, 13, 10])
}
class ivy.data_classes.container.experimental.gradients._ContainerWithGradientsExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.image._ContainerWithImageExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.layers._ContainerWithLayersExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_fft(x, dim, /, *, norm='backward', n=None, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Container containing input volumes […,d_in,…], where d_in indicates the dimension that needs FFT.

  • dim (Union[int, Container]) – The dimension along which to take the one dimensional FFT.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

  • n (Optional[Union[int, Tuple[int], Container]], default: None) – Optional argument indicating the sequence length, if given, the input would be padded with zero or truncated to length n before performing FFT. Should be a integer greater than 1.

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

Return type:

Container

Returns:

ret – The transformed input.

Examples

>>> a = ivy.array(np.array([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j]))
>>> b = ivy.array(np.exp(2j * np.pi * np.arange(8) / 8))
>>> c = ivy.Container(a=a, b=b)
>>> dims = ivy.Container(a=0, b=0)
>>> ivy.Container.static_fft(c, dims)
{
a: ivy.array([0.+0.j, 12.+0.j, 8.+0.j, 4.+0.j]),
b: ivy.array([-3.44509285e-16+1.14423775e-17j, 8.00000000e+00-8.11483250e-16j,
               2.33486982e-16+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j,
               9.95799250e-17+2.33486982e-16j, 0.00000000e+00+7.66951701e-17j,
               1.14423775e-17+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j])
}
static _static_sliding_window(input, window_size, /, *, stride=1, dilation=1, padding='VALID', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input (Union[Array, NativeArray, Container]) – An array representing the base area on which the window is going to slide over.

  • window_size (Union[int, Tuple[int, int], Tuple[int, int, int], Container]) – Size of the sliding window for each dimension of the input.

  • stride (Union[int, Tuple[int, int], Container], default: 1) – The stride of the sliding window for each dimension of input

  • padding (Union[str, int, Sequence[Tuple[int, int]], Container], default: 'VALID') – Either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.

  • dilation (Union[int, Tuple[int, int], Container], default: 1) – The stride between elements within a sliding window, must be > 0.

Return type:

Container

Returns:

ret – The result of the sliding window operation.

Examples

>>> x = ivy.Container(
...     a=ivy.array([[1, 2, 3, 4],
...                  [5, 6, 7, 8],
...                  [9, 10, 11, 12]]),
...     b=ivy.array([[13, 14, 15, 16],
...                  [17, 18, 19, 20],
...                  [21, 22, 23, 24]])
... )
>>> result = ivy.Container._static_sliding_window(x, (2, 2))
>>> print(result)
{
    a: ivy.array([[[ 1,  2,  5,  6],
                   [ 2,  3,  6,  7],
                   [ 3,  4,  7,  8]],

[[ 5, 6, 9, 10], [ 6, 7, 10, 11], [ 7, 8, 11, 12]]]),

b: ivy.array([[[13, 14, 17, 18],

[14, 15, 18, 19], [15, 16, 19, 20]],

[[17, 18, 21, 22], [18, 19, 22, 23], [19, 20, 23, 24]]])

}

adaptive_avg_pool1d(output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

Apply a 1D adaptive average pooling over an input signal composed of several input planes.

Parameters:
  • self (Container) – Input container.

  • output_size (Union[int, Container]) – Spatial output size.

Return type:

Container

Returns:

The result of the pooling operation.

adaptive_avg_pool2d(output_size, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, data_format='NHWC')[source]#

Apply a 2D adaptive average pooling over an input signal composed of several input planes.

Parameters:
  • self (Container) – Input container.

  • output_size (Union[int, Container]) – Spatial output size.

  • data_format (str, default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

Return type:

Container

Returns:

The result of the pooling operation.

adaptive_max_pool2d(output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

Apply a 2D adaptive maximum pooling over an input signal composed of several input planes.

Parameters:
  • self (Container) – Input container.

  • output_size (Union[int, Container]) – Spatial output size.

Return type:

Container

Returns:

The result of the pooling operation.

adaptive_max_pool3d(output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
Return type:

Container

avg_pool1d(kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Container of input images [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int], Container]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NWC') – NWC” or “NCW”. Defaults to “NWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12.).reshape((2,2,3))
>>> b = ivy.arange(24.).reshape((2,3,4))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(x.avg_pool1d(2, 2, "VALID"))
{
    a: ivy.array([[[1.5, 2.5, 3.5]],
                  [[7.5, 8.5, 9.5]]]),
    b: ivy.array([[[2., 3., 4., 5.]],
                  [[14., 15., 16., 17.]]])
}
avg_pool2d(kernel, strides, padding, /, *, data_format='NHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – Input image [batch_size,h,w,d_in].

  • kernel (Union[int, Tuple[int], Tuple[int, int], Container]) – The size of the window to take a max over.

  • strides (Union[int, Tuple[int], Tuple[int, int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • divisor_override (Optional[Union[int, Container]], default: None) – If specified, it will be used as divisor, otherwise kernel_size will be used.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12).reshape((2, 1, 3, 2))
>>> b = ivy.arange(48).reshape((2, 4, 3, 2))
>>> x = ivy.Container({'a': a, 'b': b})
>>> y = x.avg_pool2d(2, 1, "SAME")
>>> print(y)
{
    a: (<class ivy.data_classes.array.array.Array> shape=[2, 1, 3, 2]),
    b: (<class ivy.data_classes.array.array.Array> shape=[2, 4, 3, 2])
}
avg_pool3d(kernel, strides, padding, /, *, data_format='NDHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – Input volume [batch_size,d,h,w,d_in].

  • kernel (Union[int, Tuple[int], Tuple[int, int, int], Container]) – Convolution filters [d,h,w].

  • strides (Union[int, Tuple[int], Tuple[int, int, int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NDHWC') – NDHWC” or “NCDHW”. Defaults to “NDHWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • divisor_override (Optional[Union[int, Container]], default: None) – If specified, it will be used as the divisor, otherwise

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(24.).reshape((1, 2, 3, 4, 1))
>>> b = ivy.arange(48.).reshape((2, 4, 3, 2, 1))
>>> x = ivy.Container(a=a, b=b)
>>> print(x.avg_pool3d(2, 1, "VALID"))
{
    a: ivy.array([[[[[8.5],
                     [9.5],
                     [10.5]],
                    [[12.5],
                     [13.5],
                     [14.5]]]]]),
    b: (<class ivy.data_classes.array.array.Array> shape=[2, 3, 2, 1, 1])
}
dct(*, type=2, n=None, axis=-1, norm=None, out=None)[source]#

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

Parameters:
  • self (Container) – Container with the input signals.

  • type (Union[Literal[1, 2, 3, 4], Container], default: 2) – The type of the dct. Must be 1, 2, 3 or 4.

  • n (Optional[Union[int, Container]], default: None) – The length of the transform. If n is less than the input signal length, then x is truncated, if n is larger then x is zero-padded.

  • norm (Optional[Union[Literal['ortho'], Container]], default: None) – The type of normalization to be applied. Must be either None or “ortho”.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The transformed input.

Examples

>>> x = ivy.Container(a=ivy.array([8, 16, 24, 32, 40, 48, 56, 64]),
...                   b=ivy.array([1,  2,  3,  4,  5,  6,  7,  8]))
>>> x.dct(type=2, norm='ortho')
{
    a: ivy.array([102., -51.5, 0., -5.39, 0., -1.61, 0.,
                -0.406]),
    b: ivy.array([12.7, -6.44, 0., -0.673, 0., -0.201, 0.,
                -0.0507])
}
dft(*, axis=1, inverse=False, onesided=False, dft_length=None, norm='backward', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Parameters:
  • axis (Union[int, Container], default: 1) –

  • inverse (Union[bool, Container], default: False) –

  • onesided (Union[bool, Container], default: False) –

  • dft_length (Optional[Union[int, Tuple[int], Container]], default: None) –

  • norm (Union[str, Container], default: 'backward') –

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) –

  • to_apply (Union[bool, Container], default: True) –

  • prune_unapplied (Union[bool, Container], default: False) –

  • map_sequences (Union[bool, Container], default: False) –

  • out (Optional[Union[Array, Container]], default: None) –

Return type:

Container

embedding(indices, /, *, max_norm=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

fft(dim, /, *, norm='backward', n=None, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – Container containing input volumes […,d_in,…], where d_in indicates the dimension that needs FFT.

  • dim (Union[int, Container]) – The dimension along which to take the one dimensional FFT.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

  • n (Optional[Union[int, Tuple[int], Container]], default: None) – Optional argument indicating the sequence length, if given, the input would be padded with zero or truncated to length n before performing FFT. Should be a integer greater than 1.

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

Return type:

Container

Returns:

ret – Container containing the transformed inputs.

Examples

>>> a = ivy.array(np.array([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j]))
>>> b = ivy.array(np.exp(2j * np.pi * np.arange(8) / 8))
>>> c = ivy.Container(a=a, b=b)
>>> dims = ivy.Container(a=0, b=0)
>>> c.fft(dims)
{
a: ivy.array([0.+0.j, 12.+0.j, 8.+0.j, 4.+0.j]),
b: ivy.array([-3.44509285e-16+1.14423775e-17j, 8.00000000e+00-8.11483250e-16j,
               2.33486982e-16+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j,
               9.95799250e-17+2.33486982e-16j, 0.00000000e+00+7.66951701e-17j,
               1.14423775e-17+1.22464680e-16j, 0.00000000e+00+1.22464680e-16j])
}
idct(*, type=2, n=None, axis=-1, norm=None, out=None)[source]#

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

Parameters:
  • self (Container) – Container with the input signals.

  • type (Union[Literal[1, 2, 3, 4], Container], default: 2) – The type of the idct. Must be 1, 2, 3 or 4.

  • n (Optional[Union[int, Container]], default: None) – The length of the transform. If n is less than the input signal length, then x is truncated, if n is larger then x is zero-padded.

  • norm (Optional[Union[Literal['ortho'], Container]], default: None) – The type of normalization to be applied. Must be either None or “ortho”.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The transformed input.

Examples

>>> x = ivy.Container(a=ivy.array([8, 16, 24, 32, 40, 48, 56, 64]),
...                   b=ivy.array([1,  2,  3,  4,  5,  6,  7,  8]))
>>> x.idct(type=2, norm='ortho')
{
    a: ivy.array([79.49862671, -70.37691498, 30.00390816, -23.58938599,
          13.92713165, -10.078475, 5.19664812, -1.95411837]),
    b: ivy.array([9.94, -8.79711437, 3.76, -2.94867325, 1.74089146,
          -1.25980937, 0.64958102, -0.2442648])
}
ifft(dim, *, norm='backward', n=None, out=None)[source]#

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

Parameters:
  • self (Container) – Container containing input volumes […,d_in,…], where d_in indicates the dimension that needs IFFT.

  • dim (Union[int, Container]) – The dimension along which to take the one dimensional IFFT.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

  • n (Optional[Union[int, Tuple[int], Container]], default: None) – Optional argument indicating the sequence length, if given, the input would be padded with zero or truncated to length n before performing IFFT. Should be a integer greater than 1.

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

Returns:

ret – Container containing the transformed inputs.

Examples

>>> a = ivy.array(np.array([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j]))
>>> b = ivy.array(np.exp(2j * np.pi * np.arange(8) / 8))
>>> c = ivy.Container(a=a, b=b)
>>> dims = ivy.Container(a=0, b=0)
>>> c.ifft(dims)
{
a: ivy.array([0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j]),
b: ivy.array([-4.30636606e-17+1.43029718e-18j, 0.00000000e+00+1.53080850e-17j,
               1.43029718e-18+1.53080850e-17j, 0.00000000e+00+9.58689626e-18j,
               1.24474906e-17+2.91858728e-17j, 0.00000000e+00+1.53080850e-17j,
               2.91858728e-17+1.53080850e-17j, 1.00000000e+00-1.01435406e-16j])
}
ifftn(s=None, axes=None, *, norm='backward', out=None)[source]#

ivy.Container static method variant of ivy.ifftn.

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

Parameters:
  • x – Input array of complex numbers.

  • s (Optional[Union[int, Tuple[int, ...], Container]], default: None) – sequence of ints, optional Shape (length of transformed axis) of the output (s[0] refers to axis 0, s[1] to axis 1, etc.). If given shape is smaller than that of the input, the input is cropped. If larger, input is padded with zeros. If s is not given, shape of input along axes specified by axes is used.

  • axes (Optional[Union[int, Tuple[int, ...], Container]], default: None) – axes over which to compute the IFFT. If not given, last len(s) axes are used, or all axes if s is also not specified. Repeated indices in axes means inverse transform over that axis is performed multiple times.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

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

Returns:

ret – Container containing the transformed inputs

Examples

>>> x = ivy.Container(
...         a=ivy.array([[0.247306+0.908323j, 0.494955+0.90395j,
...                       0.98193269+0.49560517j],
...                      [0.93280757+0.48075343j, 0.28526384+0.3351205j,
...                       0.2343787 +0.83528011j],
...                      [0.18791352+0.30690572j, 0.82115787+0.96195183j,
...                       0.44719226+0.72654048j]]),
...         b=ivy.array([[0.24730653+0.90832391j, 0.49495562+0.9039565j,
...                       0.98193269+0.49560517j],
...                      [0.93280757+0.48075343j, 0.28526384+0.3351205j,
...                       0.2343787 +0.83528011j],
...                      [0.18791352+0.30690572j, 0.82115787+0.96195183j,
...                       0.44719226+0.72654048j]]),
...     )
>>> y = x.ifftn(s=[2, 1], axes=[0, 1], norm='ortho')
>>> print(y)
{
    a: ivy.array([[0.8344667+0.98222595j],
                  [-0.48472244+0.30233797j]]),
    b: ivy.array([[0.8344667+0.98222595j],
                  [-0.48472244+0.30233797j]])
}
interpolate(size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.

Parameters:
  • x – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].

  • size (Union[Sequence[int], int, Container]) – Output size.

  • mode (Union[Literal['linear', 'bilinear', 'trilinear', 'nearest', 'area', 'nearest_exact', 'tf_area', 'bicubic'], Container], default: 'linear') – Interpolation mode. Can be one of the following: - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

  • scale_factor (Optional[Union[int, Sequence[int], Container]], default: None) – Multiplier for spatial size that defines the output size (overwriting size).

  • align_corners (Optional[Union[bool, Container]], default: None) – If True, the corner pixels of the input and output tensors are aligned, and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: False

  • antialias (Union[bool, Container], default: False) – If True, antialiasing is applied when downsampling an image. Supported modes: ‘bilinear’, ‘bicubic’.

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

Return type:

Container

Returns:

resized array

max_pool1d(kernel, strides, padding, /, *, data_format='NWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – Container of input images [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NWC') – “NWC” or “NCW”. Defaults to “NWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12.).reshape((2,2,3))
>>> b = ivy.arange(24.).reshape((2,3,4))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(x.max_pool1d(2, 2, "VALID"))
{
    a: ivy.array([[[3., 4., 5.]],
                  [[9., 10., 11.]]]),
    b: ivy.array([[[4., 5., 6., 7.]],
                  [[16., 17., 18., 19.]]])
}
max_pool2d(kernel, strides, padding, /, *, data_format='NHWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – Input image [batch_size,h,w,d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – The size of the window to take a max over.

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(24.).reshape((1, 2, 3, 4))
>>> b = ivy.arange(48.).reshape((2, 4, 3, 2))
>>> x = ivy.Container(a=a, b=b)
>>> y = x.max_pool2d(3, 1, "VALID")
>>> print(y)
{
    a: ivy.array([], shape=(1, 0, 1, 4)),
    b: ivy.array([[[[16., 17.]],
                   [[22., 23.]]],
                 [[[40., 41.]],
                   [[46., 47.]]]])
}
max_pool3d(kernel, strides, padding, /, *, data_format='NDHWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – Input volume [batch_size,d,h,w,d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – Convolution filters [d,h,w].

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NDHWC') – “NDHWC” or “NCDHW”. Defaults to “NDHWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(24.).reshape((1, 2, 3, 4, 1))
>>> b = ivy.arange(48.).reshape((2, 4, 3, 2, 1))
>>> x = ivy.Container(a=a, b=b)
>>> print(x.max_pool3d(3, 1, "VALID"))
{
    a: ivy.array([], shape=(1, 0, 1, 2, 1)),
    b: ivy.array([], shape=(2, 2, 1, 0, 1))
}
max_unpool1d(indices, kernel_size, /, *, strides=None, padding=0, data_format='NCW')[source]#

Compute a 1-D max unpooling given the 1-D pooled input x and its indices.

Parameters:
  • self – Pooled input image [batch_size, w, d_in].

  • indices (Union[Array, NativeArray, Container]) – Indices obtained from the corresponding max pooling operation.

  • kernel_size (Union[Tuple[int], int]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Optional[Union[int, Tuple[int]]], default: None) – The stride of the sliding window for each dimension of input.

  • padding (Union[int, Tuple[int]], default: 0) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Optional[str], default: 'NCW') – NWC” or “NCW”. Defaults to “NCW”.

Return type:

Container

Returns:

ret – The result of the unpooling operation.

rfft(*, n=None, axis=-1, norm='backward', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – input array. Must have a real-valued floating-point data type.

  • n (Optional[Union[int, Container]], default: None) – length of the transformed axis of the input. If - n is greater than the length of the input array, the input array is zero-padded to length n. - n is less than the length of the input array, the input array is trimmed to length n. - n is not provided, the length of the transformed axis of the output must equal the length of the input along the axis specified by axis. Default is None.

  • axis (Union[int, Container], default: -1) – axis (dimension) over which to compute the Fourier transform. If not set, the last axis (dimension) is used. Default is -1.

  • norm (Union[Literal['backward', 'ortho', 'forward'], Container], default: 'backward') – normalization mode. Should be one of the following modes: - ‘backward’: no normalization. - ‘ortho’: normalize by 1/sqrt(n) (i.e., make the FFT orthonormal). - ‘forward’: normalize by 1/n. Default is backward.

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

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

Returns:

ret – an array transformed along the axis (dimension) indicated by axis. The returned array must have a complex-valued floating-point data type determined by Type Promotion Rules.

Examples

>>> x = ivy.Container(a=ivy.array([0.,1.,2.]),
...                   b=ivy.array([3.,4.,5.]))
>>> y = x.rfft()
>>> print(y)
{
    a: ivy.array([3.+0.j, -1.5+0.8660254j]),
    b: ivy.array([12.+0.j, -1.5+0.8660254j])
}
rfftn(s=None, axes=None, *, norm='backward', out=None)[source]#

Compute the n-dimensional discrete Fourier Transform for real input.

Parameters:
  • axes (int or tuple of ints, optional) – Axes over which to compute the FFT. If not given, the last n axes are used.

  • s (sequence of ints, optional) – Shape (length of each transformed axis) of the output. Along each axis, if the given shape is smaller than that of the input, the input is cropped. If it is larger, the input is padded with zeros.

  • norm ({'backward', 'ortho', 'forward'}, optional) – Normalization mode. Default is ‘backward’.

  • out (array-like, optional) – Output array. Must have the same shape and type as the expected output.

Return type:

Container

Returns:

transformed (Container) – The n-dimensional discrete Fourier Transform of the input.

sliding_window(window_size, /, *, stride=1, dilation=1, padding='VALID', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input – An array representing the base area on which the window is going to slide over.

  • window_size (Union[int, Tuple[int, int], Tuple[int, int, int], Container]) – Size of the sliding window for each dimension of the input.

  • stride (Union[int, Tuple[int, int], Container], default: 1) – The stride of the sliding window for each dimension of input

  • padding (Union[str, int, Sequence[Tuple[int, int]], Container], default: 'VALID') – Either the string ‘SAME’ (padding with zeros evenly), the string ‘VALID’ (no padding), or a sequence of n (low, high) integer pairs that give the padding to apply before and after each spatial dimension.

  • dilation (Union[int, Tuple[int, int], Container], default: 1) – The stride between elements within a sliding window, must be > 0.

Return type:

Container

Returns:

ret – The result of the sliding window operation.

Examples

>>> x = ivy.Container(
...     a=ivy.array([[1, 2, 3, 4],
...                  [5, 6, 7, 8],
...                  [9, 10, 11, 12]]),
...     b=ivy.array([[13, 14, 15, 16],
...                  [17, 18, 19, 20],
...                  [21, 22, 23, 24]])
... )
>>> x.sliding_window((2, 2))
{
    a: ivy.array([[[ 1,  2,  5,  6],
                   [ 2,  3,  6,  7],
                   [ 3,  4,  7,  8]],
                   [[ 5,  6,  9, 10],
                   [ 6,  7, 10, 11],
                   [ 7,  8, 11, 12]]]),
    b: ivy.array([[[13, 14, 17, 18],
                    [14, 15, 18, 19],
                    [15, 16, 19, 20]],
                    [[17, 18, 21, 22],
                    [18, 19, 22, 23],
                    [19, 20, 23, 24]]])
}
static static_adaptive_avg_pool1d(input, output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input (Union[Array, NativeArray, Container]) – Input array. Must have shape (N, C, L_in) or (C, L_in) where N is the batch dimension, C is the feature dimension, and L_in is the spatial dimension.

  • output_size (Union[int, Container]) – Spatial output size.

Return type:

Container

Returns:

The result of the pooling operation. Will have shape (N, C, L_out) or (C, L_out), where L_out = output_size

static static_adaptive_avg_pool2d(input, output_size, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, data_format='NHWC')[source]#

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

Parameters:
  • input (Union[Array, NativeArray, Container]) – A 3D or 4D input array. Should have a floating-point data type.

  • output_size (Union[Sequence[int], int, Container]) – Spatial output size.

  • data_format (str, default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

Return type:

Container

Returns:

The result of the pooling operation. Will have shape (N, C, S_0, S_1) or (C, S_0, S_1), where S = output_size

static static_adaptive_max_pool2d(input, output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input (Union[Array, NativeArray, Container]) – Input array. Must have shape (N, C, H_in, W_in) or (C, H_in, W_in) where N is the batch dimension, C is the feature dimension, and H_in and W_in are the 2 spatial dimensions.

  • output_size (Union[Sequence[int], int, Container]) – Spatial output size.

Return type:

Container

Returns:

The result of the pooling operation. Will have shape (N, C, S_0, S_1) or (C, S_0, S_1), where S = output_size

static static_adaptive_max_pool3d(input, output_size, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#
Return type:

Container

static static_avg_pool1d(x, kernel, strides, padding, /, *, data_format='NWC', count_include_pad=False, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Container of input images [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int], Container]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NWC') – NWC” or “NCW”. Defaults to “NWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12.).reshape((2,2,3))
>>> b = ivy.arange(24.).reshape((2,3,4))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(ivy.Container.static_avg_pool1d(x,2, 2, "VALID"))
{
    a: ivy.array([[[1.5, 2.5, 3.5]],
                  [[7.5, 8.5, 9.5]]]),
    b: ivy.array([[[2., 3., 4., 5.]],
                  [[14., 15., 16., 17.]]])
}
static static_avg_pool2d(x, kernel, strides, padding, /, *, data_format='NHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input image [batch_size,h,w,d_in].

  • kernel (Union[int, Tuple[int], Tuple[int, int], Container]) – The size of the window to take a max over.

  • strides (Union[int, Tuple[int], Tuple[int, int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • divisor_override (Optional[Union[int, Container]], default: None) – If specified, it will be used as divisor, otherwise kernel_size will be used.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12).reshape((2, 1, 3, 2))
>>> b = ivy.arange(48).reshape((2, 4, 3, 2))
>>> x = ivy.Container({'a': a, 'b': b})
>>> y = ivy.Container.static_avg_pool2d(x, (2, 2), (1, 1), "SAME")
>>> print(y)
{
    a: (<class ivy.data_classes.array.array.Array> shape=[2, 1, 3, 2]),
    b: (<class ivy.data_classes.array.array.Array> shape=[2, 4, 3, 2])
}
static static_avg_pool3d(x, kernel, strides, padding, /, *, data_format='NDHWC', count_include_pad=False, ceil_mode=False, divisor_override=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input volume [batch_size,d,h,w,d_in].

  • kernel (Union[int, Tuple[int], Tuple[int, int, int], Container]) – Convolution filters [d,h,w].

  • strides (Union[int, Tuple[int], Tuple[int, int, int], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NDHWC') – NDHWC” or “NCDHW”. Defaults to “NDHWC”.

  • count_include_pad (Union[bool, Container], default: False) – Whether to include padding in the averaging calculation.

  • ceil_mode (Union[bool, Container], default: False) – Whether to use ceil or floor for creating the output shape.

  • divisor_override (Optional[Union[int, Container]], default: None) – If specified, it will be used as the divisor, otherwise

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12).reshape((1, 2, 1, 3, 2))
>>> b = ivy.arange(48).reshape((2, 2, 2, 3, 2))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(ivy.Container.static_avg_pool3d(x, 2, 1, "VALID"))
{
    a: ivy.array([], shape=(1, 1, 0, 2, 2)),
    b: ivy.array([[[[[10., 11.],
                     [12., 13.]]]],
               [[[[34., 35.],
                     [36., 37.]]]]])
}
static static_dct(x, /, *, type=2, n=None, axis=-1, norm=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – Container with the input signals.

  • type (Union[Literal[1, 2, 3, 4], Container], default: 2) – The type of the dct. Must be 1, 2, 3 or 4.

  • n (Optional[Union[int, Container]], default: None) – The length of the transform. If n is less than the input signal length, then x is truncated, if n is larger than x is zero-padded.

  • norm (Optional[Union[Literal['ortho'], Container]], default: None) – The type of normalization to be applied. Must be either None or “ortho”.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The transformed input.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([8, 16, 24, 32, 40, 48, 56, 64]),
...                   b=ivy.array([1,  2,  3,  4,  5,  6,  7,  8]))
>>> ivy.Container.static_dct(x, type=2, norm='ortho')
{
    a: ivy.array([102., -51.5, 0., -5.39, 0., -1.61, 0.,
                -0.406]),
    b: ivy.array([12.7, -6.44, 0., -0.673, 0., -0.201, 0.,
                -0.0507])
}

With multiple ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([  8, 16,  24,  32,   40,   48,   56,   64]),
...                   b=ivy.array([11., 54, 23., 13., 255., 255., 132., 182.]))
>>> n = ivy.Container(a=9, b=5)
>>> type = ivy.Container(a=2, b=4)
>>> norm = ivy.Container(a="ortho", b=None)
>>> ivy.Container.static_dct(x, type=type, n=n, norm=norm)
{
    a: ivy.array([96., -28.2, -31.9, 22.9, -26., 19.8, -17., 10.9,
                -5.89]),
    b: ivy.array([242., -253., 286., -515., 467.])
}
static static_dft(x, /, *, axis=1, inverse=False, onesided=False, dft_length=None, norm='backward', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Parameters:
  • x (Union[Array, NativeArray, Container]) –

  • axis (Union[int, Container], default: 1) –

  • inverse (Union[bool, Container], default: False) –

  • onesided (Union[bool, Container], default: False) –

  • dft_length (Optional[Union[int, Tuple[int], Container]], default: None) –

  • norm (Union[str, Container], default: 'backward') –

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) –

  • to_apply (Union[bool, Container], default: True) –

  • prune_unapplied (Union[bool, Container], default: False) –

  • map_sequences (Union[bool, Container], default: False) –

  • out (Optional[Union[Array, Container]], default: None) –

Return type:

Container

static static_embedding(weight, indices, /, *, max_norm=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static static_idct(x, /, *, type=2, n=None, axis=-1, norm=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – Container with the input signals.

  • type (Union[Literal[1, 2, 3, 4], Container], default: 2) – The type of the dct. Must be 1, 2, 3 or 4.

  • n (Optional[Union[int, Container]], default: None) – The length of the transform. If n is less than the input signal length, then x is truncated, if n is larger than x is zero-padded.

  • norm (Optional[Union[Literal['ortho'], Container]], default: None) – The type of normalization to be applied. Must be either None or “ortho”.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – The transformed input.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([8, 16, 24, 32, 40, 48, 56, 64]),
...                   b=ivy.array([1,  2,  3,  4,  5,  6,  7,  8]))
>>> ivy.Container.static_idct(x, type=2, norm='ortho')
{
    a: ivy.array([79.49862671, -70.37691498, 30.00390816, -23.58938599,
                  13.92713165, -10.078475, 5.19664812, -1.95411837]),
    b: ivy.array([9.93732834, -8.79711437, 3.75048852, -2.94867325, 1.74089146,
                  -1.25980937, 0.64958102, -0.2442648])
}

With multiple ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([  8, 16,  24,  32,   40,   48,   56,   64]),
...                   b=ivy.array([11., 54, 23., 13., 255., 255., 132., 182.]))
>>> n = ivy.Container(a=9, b=5)
>>> type = ivy.Container(a=2, b=4)
>>> norm = ivy.Container(a="ortho", b=None)
>>> ivy.Container.static_idct(x, type=type, n=n, norm=norm)
{
    a: ivy.array([86.29723358, -66.6950531, 9.93914509, 2.88008738,
                  -16.18951225, 18.06697273, -17.57439804, 11.68861485,
                  -4.41308832]),
    b: ivy.array([242.0700836, -253.2449036, 285.6711426, -514.501709,
                  467.4924011])
}
static static_ifft(x, dim, *, norm='backward', n=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – Container containing input volumes […,d_in,…], where d_in indicates the dimension that needs IFFT.

  • dim (Union[int, Container]) – The dimension along which to take the one dimensional IFFT.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

  • n (Optional[Union[int, Tuple[int], Container]], default: None) – Optional argument indicating the sequence length, if given, the input would be padded with zero or truncated to length n before performing IFFT. Should be a integer greater than 1.

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

Returns:

ret – The transformed input.

Examples

>>> a = ivy.array(np.array([ 6.+0.j, -2.+2.j, -2.+0.j, -2.-2.j]))
>>> b = ivy.array(np.exp(2j * np.pi * np.arange(8) / 8))
>>> c = ivy.Container(a=a, b=b)
>>> dims = ivy.Container(a=0, b=0)
>>> ivy.Container.static_ifft(c, dims)
{
a: ivy.array([0.+0.j, 1.+0.j, 2.+0.j, 3.+0.j]),
b: ivy.array([-4.30636606e-17+1.43029718e-18j, 0.00000000e+00+1.53080850e-17j,
               1.43029718e-18+1.53080850e-17j, 0.00000000e+00+9.58689626e-18j,
               1.24474906e-17+2.91858728e-17j, 0.00000000e+00+1.53080850e-17j,
               2.91858728e-17+1.53080850e-17j, 1.00000000e+00-1.01435406e-16j])
}
static static_ifftn(x, s=None, axes=None, *, norm='backward', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.ifftn.

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

Parameters:
  • x (Container) – Input array of complex numbers.

  • s (Optional[Union[int, Tuple[int, ...], Container]], default: None) – sequence of ints, optional Shape (length of transformed axis) of the output (s[0] refers to axis 0, s[1] to axis 1, etc.). If given shape is smaller than that of the input, the input is cropped. If larger, input is padded with zeros. If s is not given, shape of input along axes specified by axes is used.

  • axes (Optional[Union[int, Tuple[int, ...], Container]], default: None) – axes over which to compute the IFFT. If not given, last len(s) axes are used, or all axes if s is also not specified. Repeated indices in axes means inverse transform over that axis is performed multiple times.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

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

Returns:

ret – The truncated or zero-padded input, transformed along the axes indicated by axes, or by a combination of s or x, as explained in the parameters section above.

static static_interpolate(x, size, /, *, mode='linear', scale_factor=None, recompute_scale_factor=None, align_corners=None, antialias=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Down/up samples the input to the given size. The algorithm used for interpolation is determined by mode.

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input array, Must have the shape [batch x channels x [optional depth] x [optional height] x width].

  • size (Union[Sequence[int], int, Container]) – Output size.

  • mode (Union[Literal['linear', 'bilinear', 'trilinear', 'nearest', 'area', 'nearest_exact', 'tf_area', 'bicubic'], Container], default: 'linear') – Interpolation mode. Can be one of the following: - linear - bilinear - trilinear - nearest - area - tf_area - bicubic - mitchellcubic - lanczos3 - lanczos5 - gaussian

  • scale_factor (Optional[Union[int, Sequence[int], Container]], default: None) – Multiplier for spatial size that defines the output size (overwriting size).

  • align_corners (Optional[Union[bool, Container]], default: None) – If True, the corner pixels of the input and output tensors are aligned, and thus preserving the values at the corner pixels. If False, the corner pixels are not aligned, and the interpolation uses edge value padding for out-of-boundary values. only has an effect when mode is ‘linear’, ‘bilinear’, ‘bicubic’ or ‘trilinear’. Default: False

  • antialias (Union[bool, Container], default: False) – If True, antialiasing is applied when downsampling an image. Supported modes: ‘bilinear’, ‘bicubic’.

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

Return type:

Container

Returns:

resized array

static static_max_pool1d(x, kernel, strides, padding, /, *, data_format='NWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Container of input images [batch_size, w, d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NWC') – “NWC” or “NCW”. Defaults to “NWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12.).reshape((2,2,3))
>>> b = ivy.arange(24.).reshape((2,3,4))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(ivy.Container.static_max_pool1d(x,2, 2, "VALID"))
{
    a: ivy.array([[[3., 4., 5.]],
                  [[9., 10., 11.]]]),
    b: ivy.array([[[4., 5., 6., 7.]],
                  [[16., 17., 18., 19.]]])
}
static static_max_pool2d(x, kernel, strides, padding, /, *, data_format='NHWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input image [batch_size,h,w,d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – The size of the window to take a max over.

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – “SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NHWC') – “NHWC” or “NCHW”. Defaults to “NHWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12).reshape((2, 1, 3, 2))
>>> b = ivy.arange(48).reshape((2, 4, 3, 2))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(ivy.Container.static_max_pool2d(x, (2, 2), (1, 1), "SAME"))
{
    a: (<class ivy.array.array.Array> shape=[2, 1, 3, 2]),
    b: (<class ivy.array.array.Array> shape=[2, 4, 3, 2])
}
static static_max_pool3d(x, kernel, strides, padding, /, *, data_format='NDHWC', dilation=1, ceil_mode=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input volume [batch_size,d,h,w,d_in].

  • kernel (Union[int, Tuple[int, ...], Container]) – Convolution filters [d,h,w].

  • strides (Union[int, Tuple[int, ...], Container]) – The stride of the sliding window for each dimension of input.

  • padding (Union[str, int, Tuple[int], List[Tuple[int, int]], Container]) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NDHWC') – “NDHWC” or “NCDHW”. Defaults to “NDHWC”.

  • dilaton – The stride between elements within a sliding window, must be > 0.

  • ceil_mode (Union[bool, Container], default: False) – If True, ceil is used instead of floor to compute the output shape. This ensures that every element is covered by a sliding window.

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

Return type:

Container

Returns:

ret – The result of the pooling operation.

Examples

>>> a = ivy.arange(12).reshape((1, 2, 1, 3, 2))
>>> b = ivy.arange(48).reshape((2, 2, 2, 3, 2))
>>> x = ivy.Container({'a': a, 'b': b})
>>> print(ivy.Container.static_max_pool3d(x, 2, 1, "VALID"))
{
    a: ivy.array([], shape=(1, 1, 0, 2, 2)),
    b: ivy.array([[[[[20, 21],
                     [22, 23]]]],
               [[[[44, 45],
                     [46, 47]]]]])
}
static static_max_unpool1d(input, indices, kernel_size, /, *, strides=None, padding=0, data_format='NCW', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.max_unpool1d.

Parameters:
  • input (Container) – Pooled input image [batch_size, w, d_in].

  • indices (Container) – Indices obtained from the corresponding max pooling operation.

  • kernel_size (Union[Tuple[int], int]) – Size of the kernel i.e., the sliding window for each dimension of input. [w].

  • strides (Optional[Union[int, Tuple[int]]], default: None) – The stride of the sliding window for each dimension of input.

  • padding (Union[int, Tuple[int]], default: 0) – SAME” or “VALID” indicating the algorithm, or list indicating the per-dimension paddings.

  • data_format (Union[str, Container], default: 'NCW') – NWC” or “NCW”. Defaults to “NCW”.

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

Return type:

Container

Returns:

ret – The result of the unpooling operation.

static static_rfft(x, /, *, n=None, axis=-1, norm='backward', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.rfft.

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

Parameters:
  • x (Container) – input array. Must have a real-valued floating-point data type.

  • n (Optional[Union[int, Container]], default: None) – length of the transformed axis of the input. If - n is greater than the length of the input array, the input array is zero-padded to length n. - n is less than the length of the input array, the input array is trimmed to length n. - n is not provided, the length of the transformed axis of the output must equal the length of the input along the axis specified by axis. Default is None.

  • axis (Union[int, Container], default: -1) – axis (dimension) over which to compute the Fourier transform. If not set, the last axis (dimension) is used. Default is -1.

  • norm (Union[Literal['backward', 'ortho', 'forward'], Container], default: 'backward') – normalization mode. Should be one of the following modes: - ‘backward’: no normalization. - ‘ortho’: normalize by 1/sqrt(n) (i.e., make the FFT orthonormal). - ‘forward’: normalize by 1/n. Default is backward.

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

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

Return type:

Container

Returns:

ret – an array transformed along the axis (dimension) indicated by axis. The returned array must have a complex-valued floating-point data type determined by Type Promotion Rules.

Examples

>>> x = ivy.Container(a=ivy.array([0.,1.,2.]),
...                   b=ivy.array([3.,4.,5.]))
>>> y =  ivy.Container.static_rfft(x)
>>> print(y)
{
    a: ivy.array([3.+0.j, -1.5+0.8660254j]),
    b: ivy.array([12.+0.j, -1.5+0.8660254j])
}
static static_rfftn(x, s=None, axes=None, *, norm='backward', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.rfftn.

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

Parameters:
  • x (Container) – Input array of real numbers.

  • s (Optional[Union[int, Tuple[int, ...], Container]], default: None) – sequence of ints, optional Shape (length of transformed axis) to use from the input (s[0] refers to axis 0,`s[1]` to axis 1, etc.). The final element of s corresponds to n for rfft(x, n), while for the remaining axes, it corresponds to n for fft(x, n). Along any axis, if the given shape is smaller than that of the input, the input is cropped. If it is larger,the input is padded with zeros. If s is not given, the shape of the input along the axes specified by axes is used.

  • axes (Optional[Union[int, Tuple[int, ...], Container]], default: None) – sequence of ints, optional Axes over which to compute the FFT. If not given, the last len(s) axes are used, or all axes if s is also not specified.

  • norm (Union[str, Container], default: 'backward') – Optional argument, “backward”, “ortho” or “forward”. Defaults to be “backward”. “backward” indicates no normalization. “ortho” indicates normalization by 1/sqrt(n). “forward” indicates normalization by 1/n.

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

Return type:

Container

Returns:

ret – The truncated or zero-padded input, transformed along the axes indicated by axes or by a combination of s or x, as explained in the parameters section above.

static static_rnn(step_function, inputs, initial_states, /, *, go_backwards=False, mask=None, constants=None, unroll=False, input_length=None, time_major=False, zero_output_for_mask=False, return_all_outputs=True)[source]#

ivy.Container static method variant of ivy.rnn.

Parameters:
  • step_function (Callable) – RNN step function.

  • inputs (Array) – Array of temporal data of shape (samples, time, …).

  • initial_states (List[Array]) – Array with shape (samples, state_size).

  • go_backwards (bool, default: False) – If True, do the iteration over the time dimension in reverse order and return the reversed sequence.

  • mask (Optional[Array], default: None) – Binary array with shape (samples, time, 1), with a zero for every element that is masked.

  • constants (Optional[Array], default: None) – List of constant values passed at each step.

  • unroll (bool, default: False) – Whether to use a pythonic while loop or ivy.while_loop

  • input_length (Optional[int], default: None) – An integer or 1-D array, depending on whether the time dimension is fixed-length. In case of variable length input, it is used for masking in case there is no mask specified.

  • time_major (bool, default: False) – If True, the inputs and outputs will be in shape (timesteps, batch, …) whereas in the False case, it will be (batch, timesteps, …).

  • zero_output_for_mask (bool, default: False) – If True, the otput for masked timestep will be zeros, whereas in the False case, output from previous timestep is returned

  • return_all_outputs (bool, default: True) – If True, return the recurrent outputs for all timesteps in the sequence. If False, only return the output for the last timestep.

Return type:

Container

Returns:

ret – A tuple of - the latest output of the rnn of shape (samples, …) - the output of the rnn of shape (samples, time, …) if

return_all_outputs=True else (samples, 1, …)

  • list of tensors, latest states returned by the step funciton, of shape (samples, …)

static static_stft(signals, frame_length, frame_step, /, *, fft_length=None, window_fn=None, pad_end=False, name=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.stft.

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

Parameters:
  • signals (Container) – Input Arrays.

  • frame_length (Union[int, Container]) – An integer scalar Tensor. The window length in samples.

  • frame_step (Union[int, Container]) – An integer scalar Tensor. The number of samples to step.

  • fft_length (Optional[Union[int, Container]], default: None) – An integer scalar Tensor. The size of the FFT to apply. If not provided, uses the smallest power of 2 enclosing frame_length.

  • optional – An integer scalar Tensor. The size of the FFT to apply. If not provided, uses the smallest power of 2 enclosing frame_length.

  • window_fn (Optional[Union[Callable, Container]], default: None) – A callable that takes a window length and a dtype keyword argument and returns a [window_length] Tensor of samples in the provided datatype. If set to None, no windowing is used.

  • optional – A callable that takes a window length and a dtype keyword argument and returns a [window_length] Tensor of samples in the provided datatype. If set to None, no windowing is used.

  • pad_end (Optional[Union[bool, Container]], default: False) – Whether to pad the end of signals with zeros when the provided frame length and step produces a frame that lies partially past its end.

  • optional – Whether to pad the end of signals with zeros when the provided frame length and step produces a frame that lies partially past its end.

  • name (Optional[Union[str, Container]], default: None) – An optional name for the operation.

  • optional – An optional name for the operation.

  • out (Optional[Container], default: None) – Optional output array for writing the result.

  • optional – Optional output array for writing the result.

Return type:

Container

Returns:

ret – A […, frames, fft_unique_bins] Tensor of complex64/complex128 STFT values where fft_unique_bins is fft_length // 2 + 1 (the unique components of the FFT).

stft(frame_length, frame_step, /, *, fft_length=None, window_fn=None, pad_end=False, name=None, out=None)[source]#

Compute the Short-time Fourier Transform of signals.

Parameters:
  • self (Union[Array, NativeArray, Container]) – Input Arrays.

  • frame_length (Union[int, Container]) – An integer scalar Tensor. The window length in samples.

  • frame_step (Union[int, Container]) – An integer scalar Tensor. The number of samples to step.

  • fft_length (Optional[Union[int, Container]], default: None) – An integer scalar Tensor. The size of the FFT to apply. If not provided, uses the smallest power of 2 enclosing frame_length.

  • window_fn (Optional[Union[Callable, Container]], default: None) – A callable that takes a window length and a dtype keyword argument and returns a [window_length] Tensor of samples in the provided datatype. If set to None, no windowing is used.

  • pad_end (Optional[Union[bool, Container]], default: False) – Whether to pad the end of signals with zeros when the provided frame length and step produces a frame that lies partially past its end.

  • name (Optional[Union[str, Container]], default: None) – An optional name for the operation.

  • out (Optional[Union[Array, Container]], default: None) – Optional output array for writing the result.

Return type:

Container

Returns:

ret – A […, frames, fft_unique_bins] Tensor of complex64/complex128 STFT values where fft_unique_bins is fft_length // 2 + 1 (the unique components of the FFT).

class ivy.data_classes.container.experimental.linear_algebra._ContainerWithLinearAlgebraExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
adjoint(*, key_chains=None, to_apply=True, out=None)[source]#

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

Examples

>>> x = np.array([[1.-1.j, 2.+2.j],
                  [3.+3.j, 4.-4.j]])
>>> c = ivy.Container(a=ivy.array(x))
>>> c.adjoint()
{
    a: ivy.array([[1.+1.j, 3.-3.j],
                  [2.-2.j, 4.+4.j]])
}
batched_outer(tensors, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

tensors (Sequence[Union[Container, Array, NativeArray]]) – list of tensors of shape (n_samples, J1, …, JN) , (n_samples, K1, …, KM) …

Return type:

Container

Returns:

outer product of tensors – of shape (n_samples, J1, …, JN, K1, …, KM, …)

Examples

>>> a = ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
>>> b = ivy.array([[[.1, .2], [.3, .4]], [[.5, .6], [.7, .8]]])
>>> result = ivy.batched_outer(a, b)
>>> print(result)
ivy.array([[[[[0.1, 0.2],
      [0.30000001, 0.40000001]],
     [[0.2       , 0.40000001],
      [0.60000002, 0.80000001]]],
    [[[0.3       , 0.60000001],
      [0.90000004, 1.20000002]],
     [[0.40000001, 0.80000001],
      [1.20000005, 1.60000002]]]],
   [[[[2.5       , 3.00000012],
      [3.49999994, 4.00000006]],
     [[3.        , 3.60000014],
      [4.19999993, 4.80000007]]],
    [[[3.5       , 4.20000017],
      [4.89999992, 5.60000008]],
     [[4.        , 4.80000019],
      [5.5999999 , 6.4000001 ]]]]])
cond(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, p=None)[source]#

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

Parameters:
  • self (Container) – container with input arrays.

  • p (Optional[Union[int, float, Container]], default: None) – order of the norm of the matrix (see ivy.norm).

Returns:

ret

container including array corresponding to condition number of input array

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container(a=x)
>>> c.cond()
ivy.array(14.933034)
>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container(a=x)
>>> c.cond(p=1)
ivy.array(21.0)

With ivy.Container input:

>>> a = ivy.Container(x=ivy.arange(2 * 3).reshape((2, 3)),
...                   y=ivy.arange(2 * 3).reshape((2, 3)))
>>> a.cond()
{
    x: ivy.array(14.933034),
    y: ivy.array(14.933034)
}
diagflat(*, offset=0, padding_value=0, align='RIGHT_LEFT', num_rows=-1, num_cols=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

>>> x = ivy.Container(a=[1,2])
>>> ivy.diagflat(x, k=1)
{
    a: ivy.array([[0, 1, 0],
                  [0, 0, 2],
                  [0, 0, 0]])
}
dot(b, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

Compute the dot product between two arrays a and b using the current backend’s implementation. The dot product is defined as the sum of the element- wise product of the input arrays.

Parameters:
  • self (Union[Array, NativeArray, Container]) – First input array.

  • b (Union[Array, NativeArray, Container]) – Second input array.

  • out (Optional[Union[Array, Container]], default: None) – Optional output array. If provided, the output array to store the result.

Return type:

Union[Array, Container]

Returns:

ret – The dot product of the input arrays.

Examples

With ivy.Array inputs:

>>> a = ivy.array([1, 2, 3])
>>> b = ivy.array([4, 5, 6])
>>> result = ivy.dot(a, b)
>>> print(result)
ivy.array(32)
>>> a = ivy.array([[1, 2], [3, 4]])
>>> b = ivy.array([[5, 6], [7, 8]])
>>> c = ivy.empty_like(a)
>>> ivy.dot(a, b, out=c)
>>> print(c)
ivy.array([[19, 22],
    [43, 50]])
>>> a = ivy.array([[1.1, 2.3, -3.6]])
>>> b = ivy.array([[-4.8], [5.2], [6.1]])
>>> c = ivy.zeros((1, 1))
>>> ivy.dot(a, b, out=c)
>>> print(c)
ivy.array([[-15.28]])
eig(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

x – container with input arrays.

Return type:

Container

Returns:

ret

container including arrays corresponding eigenvealues and eigenvectors of input arrays

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container({'x':{'xx':x}})
>>> c.eig()
{
    x:  {
            xx: (tuple(2), <class ivy.array.array.Array>, shape=[2, 2])
        }
}
>>>c.eig()['x']['xx']
(
    ivy.array([-0.37228107+0.j,  5.3722816 +0.j]),
    ivy.array([
            [-0.8245648 +0.j, -0.41597357+0.j],
            [0.56576747+0.j, -0.9093767 +0.j]
        ])
)
eigh_tridiagonal(beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – A container of real or complex arrays each of shape (n), the diagonal elements of the matrix.

  • beta (Union[Array, NativeArray, Container]) – An array or a container of real or complex arrays each of shape (n-1), containing the elements of the first super-diagonal of the matrix.

  • eigvals_only (Union[bool, Container], default: True) – If False, both eigenvalues and corresponding eigenvectors are computed. If True, only eigenvalues are computed. Default is True.

  • select (Union[str, Container], default: 'a') – Optional string with values in {‘a’, ‘v’, ‘i’} (default is ‘a’) that determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.

  • select_range (Optional[Union[Tuple[int, int], List[int], Array, NativeArray, Container]], default: None) – Size 2 tuple or list or array specifying the range of eigenvalues to compute together with select. If select is ‘a’, select_range is ignored.

  • tol (Optional[Union[float, Container]], default: None) – Optional scalar. Ignored when backend is not Tensorflow. The absolute tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.

Return type:

Union[Container, Tuple[Container, Container]]

Returns:

  • eig_vals – The eigenvalues of the matrix in non-decreasing order.

  • eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.

Examples

>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.array([0.,2.])
>>> y = alpha.eigh_tridiagonal(beta)
>>> print(y)
{
    a: ivy.array([-0.56155, 0., 3.56155]),
    b: ivy.array([0., 2., 4.])
}
>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.Container(a=ivy.array([0.,2.]), b=ivy.array([2.,2.]))
>>> y = alpha.eigh_tridiagonal(beta)
>>> print(y)
{
    a: ivy.array([-0.56155, 0., 3.56155]),
    b: ivy.array([-0.82842, 2., 4.82842])
}
eigvals(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

x – container with input arrays.

Return type:

Container

Returns:

ret

container including array corresponding to eigenvalues of input array

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container({'x':{'xx':x}})
>>> c.eigvals()
{
    x: {
        xx: ivy.array([-0.37228132+0.j, 5.37228132+0.j])
    }
}
>>> c.eigvals()['x']['xx']
ivy.array([-0.37228132+0.j,  5.37228132+0.j])
higher_order_moment(order, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x – matrix of size (n_samples, n_features) or tensor of size(n_samples, D1, …, DN)

  • order (Union[Sequence[int], Container]) – number of the higher-order moment to compute

Return type:

Container

Returns:

tensor – if tensor is a matrix of size (n_samples, n_features), tensor of size (n_features, )*order

Examples

>>> a = ivy.array([[1, 2], [3, 4]])
>>> result = ivy.higher_order_moment(a, 3)
>>> print(result)
ivy.array([[
    [14, 19],
    [19, 26]],
   [[19, 26],
    [26, 36]
]])
initialize_tucker(rank, modes, /, *, init='svd', seed=None, svd='truncated_svd', non_negative=False, mask=None, svd_mask_repeats=5, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x – input tensor

  • rank (Union[Sequence[int], Container]) – number of components

  • modes (Union[Sequence[int], Container]) – modes to consider in the input tensor

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – initialization scheme for tucker decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – function to use to compute the SVD

  • non_negative (Optional[Union[bool, Container]], default: False) – if True, non-negative factors are returned

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

Return type:

Tuple[Container, Sequence[Container]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

kron(b, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

>>> a = ivy.Container(x=ivy.array([1,2]), y=ivy.array([50]))
>>> b = ivy.Container(x=ivy.array([3,4]), y=ivy.array(9))
>>> a.kron(b)
{
    a: ivy.array([3, 4, 6, 8])
    b: ivy.array([450])
}
make_svd_non_negative(U, S, V, /, *, nntype='nndsvd', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – tensor being decomposed.

  • U (Union[Array, NativeArray, Container]) – left singular matrix from SVD.

  • S (Union[Array, NativeArray, Container]) – diagonal matrix from SVD.

  • V (Union[Array, NativeArray, Container]) – right singular matrix from SVD.

  • nntype (Optional[Union[Literal['nndsvd', 'nndsvda'], Container]], default: 'nndsvd') – whether to fill small values with 0.0 (nndsvd), or the tensor mean (nndsvda, default).

  • [1] (Boutsidis & Gallopoulos. Pattern Recognition, 41(4): 1350-1362, 2008.) –

Return type:

Tuple[Container, Container]

matrix_exp(*, key_chains=None, to_apply=True, out=None)[source]#

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

Return type:

Container

Examples

>>> x = ivy.array([[[1., 0.],
                    [0., 1.]],
                    [[2., 0.],
                    [0., 2.]]])
>>> ivy.matrix_exp(x)
ivy.array([[[2.7183, 1.0000],
            [1.0000, 2.7183]],
            [[7.3891, 1.0000],
            [1.0000, 7.3891]]])
mode_dot(matrix_or_vector, mode, transpose=False, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x – tensor of shape (i_1, ..., i_k, ..., i_N)

  • matrix_or_vector (Union[Array, NativeArray, Container]) – 1D or 2D array of shape (J, i_k) or (i_k, ) matrix or vectors to which to n-mode multiply the tensor

  • mode (Union[int, Container]) – int in the range(1, N)

  • transpose (Optional[Union[bool, Container]], default: False) – If True, the matrix is transposed. For complex tensors, the conjugate transpose is used.

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

Returns:

ivy.Containermode-mode product of tensor by matrix_or_vector * of shape \((i_1, ..., i_{k-1}, J, i_{k+1}, ..., i_N)\) if matrix_or_vector is a matrix * of shape \((i_1, ..., i_{k-1}, i_{k+1}, ..., i_N)\) if matrix_or_vector is a vector

multi_dot(arrays, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=True, out=None)[source]#

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

Return type:

Container

Examples

>>> a = ivy.Container(x=ivy.arange(2 * 3).reshape((2, 3)),
...                   y=ivy.arange(2 * 3).reshape((2, 3)))
>>> b = ivy.Container(x=ivy.arange(3 * 2).reshape((3, 2)),
...                   y=ivy.arange(3 * 2).reshape((3, 2)))
>>> c = ivy.Container(x=ivy.arange(2 * 2).reshape((2, 2)),
...                   y=ivy.arange(2 * 2).reshape((2, 2)))
>>> a.multi_dot((b, c))
{
    x: ivy.array([[26, 49],
                  [80, 148]]),
    y: ivy.array([[26, 49],
                  [80, 148]])
}
multi_mode_dot(mat_or_vec_list, /, modes=None, skip=None, transpose=False, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – the input tensor

  • mat_or_vec_list (Sequence[Union[Container, Array, NativeArray]]) – sequence of matrices or vectors of length tensor.ndim

  • modes (Optional[Union[Sequence[int], Container]], default: None) – None or int list, optional, default is None

  • skip (Optional[Union[Sequence[int], Container]], default: None) – None or int, optional, default is None If not None, index of a matrix to skip.

  • transpose (Optional[Union[bool, Container]], default: False) – If True, the matrices or vectors in in the list are transposed. For complex tensors, the conjugate transpose is used.

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

Return type:

Container

Returns:

ivy.Container – tensor times each matrix or vector in the list at mode mode

partial_tucker(rank, modes, /, *, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – input tensor

  • rank (Union[Sequence[int], Container]) – number of components

  • modes (Union[Sequence[int], Container]) – modes to consider in the input tensor

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – initialization scheme for tucker decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – function to use to compute the SVD

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

Return type:

Tuple[Container, Sequence[Container]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

static static_adjoint(x, /, *, key_chains=None, to_apply=True, out=None)[source]#

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

Parameters:
  • x (Container) – container with input arrays of dimensions greater than 1.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Returns:

ret – container including arrays corresponding to the conjugate transpose of the arrays in the input container

Examples

>>> x = np.array([[1.-1.j, 2.+2.j],
                  [3.+3.j, 4.-4.j]])
>>> y = np.array([[1.-2.j, 3.+4.j],
                  [1.-0.j, 2.+6.j]])
>>> c = ivy.Container(a=ivy.array(x), b=ivy.array(y))
>>> ivy.Container.static_adjoint(c)
{
    a: ivy.array([[1.+1.j, 3.-3.j],
                  [2.-2.j, 4.+4.j]]),
    b: ivy.array([[1.+2.j, 1.-0.j],
                  [3.-4.j, 2.-6.j]])
}
static static_batched_outer(tensors, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

tensors (Sequence[Union[Container, Array, NativeArray]]) – list of tensors of shape (n_samples, J1, …, JN) , (n_samples, K1, …, KM) …

Return type:

Container

Returns:

outer product of tensors – of shape (n_samples, J1, …, JN, K1, …, KM, …)

Examples

>>> a = ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
>>> b = ivy.array([[[.1, .2], [.3, .4]], [[.5, .6], [.7, .8]]])
>>> result = ivy.batched_outer(a, b)
>>> print(result)
ivy.array([[[[[0.1, 0.2],
      [0.30000001, 0.40000001]],
     [[0.2       , 0.40000001],
      [0.60000002, 0.80000001]]],
    [[[0.3       , 0.60000001],
      [0.90000004, 1.20000002]],
     [[0.40000001, 0.80000001],
      [1.20000005, 1.60000002]]]],
   [[[[2.5       , 3.00000012],
      [3.49999994, 4.00000006]],
     [[3.        , 3.60000014],
      [4.19999993, 4.80000007]]],
    [[[3.5       , 4.20000017],
      [4.89999992, 5.60000008]],
     [[4.        , 4.80000019],
      [5.5999999 , 6.4000001 ]]]]])
static static_cond(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, p=None, out=None)[source]#

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

Parameters:
  • x (Container) – container with input arrays.

  • p (Optional[Union[int, float, Container]], default: None) – order of the norm of the matrix (see ivy.norm).

Returns:

ret

container including array corresponding to condition number of input array

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> ivy.Container.static_cond(x)
ivy.array(14.933034)
static static_diagflat(x, /, *, offset=0, padding_value=0, align='RIGHT_LEFT', num_rows=-1, num_cols=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static static_dot(a, b, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

Compute the dot product between two arrays a and b using the current backend’s implementation. The dot product is defined as the sum of the element- wise product of the input arrays.

Parameters:
  • a (Union[Array, NativeArray, Container]) – First input array.

  • b (Union[Array, NativeArray, Container]) – Second input array.

  • out (Optional[Union[Array, Container]], default: None) – Optional output array. If provided, the output array to store the result.

Return type:

Union[Array, Container]

Returns:

ret – The dot product of the input arrays.

Examples

With ivy.Array inputs:

>>> a = ivy.array([1, 2, 3])
>>> b = ivy.array([4, 5, 6])
>>> result = ivy.dot(a, b)
>>> print(result)
ivy.array(32)
>>> a = ivy.array([[1, 2], [3, 4]])
>>> b = ivy.array([[5, 6], [7, 8]])
>>> c = ivy.empty_like(a)
>>> ivy.dot(a, b, out=c)
>>> print(c)
ivy.array([[19, 22],
    [43, 50]])
>>> a = ivy.array([[1.1, 2.3, -3.6]])
>>> b = ivy.array([[-4.8], [5.2], [6.1]])
>>> c = ivy.zeros((1, 1))
>>> ivy.dot(a, b, out=c)
>>> print(c)
ivy.array([[-15.28]])
static static_eig(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

x (Union[Array, NativeArray, Container]) – container with input arrays.

Return type:

Container

Returns:

ret

container including tuple of arrays corresponding to eigenvealues and eigenvectors of input array

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container({'x':{'xx':x}})
>>> ivy.Container.eig(c)
{
    x:  {
            xx: (tuple(2), <class ivy.array.array.Array>, shape=[2, 2])
        }
}
>>> ivy.Container.eig(c)['x']['xx']
(
    ivy.array([-0.37228107+0.j,  5.3722816 +0.j]),
    ivy.array([
            [-0.8245648 +0.j, -0.41597357+0.j],
            [0.56576747+0.j, -0.9093767 +0.j]
        ])
)
static static_eigh_tridiagonal(alpha, beta, /, *, eigvals_only=True, select='a', select_range=None, tol=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • alpha (Union[Array, NativeArray, Container]) – An array or a container of real or complex arrays each of shape (n), the diagonal elements of the matrix.

  • beta (Union[Array, NativeArray, Container]) – An array or a container of real or complex arrays each of shape (n-1), containing the elements of the first super-diagonal of the matrix.

  • eigvals_only (Union[bool, Container], default: True) – If False, both eigenvalues and corresponding eigenvectors are computed. If True, only eigenvalues are computed. Default is True.

  • select (Union[str, Container], default: 'a') – Optional string with values in {‘a’, ‘v’, ‘i’} (default is ‘a’) that determines which eigenvalues to calculate: ‘a’: all eigenvalues. ‘v’: eigenvalues in the interval (min, max] given by select_range. ‘i’: eigenvalues with indices min <= i <= max.

  • select_range (Optional[Union[Tuple[int, int], List[int], Array, NativeArray, Container]], default: None) – Size 2 tuple or list or array specifying the range of eigenvalues to compute together with select. If select is ‘a’, select_range is ignored.

  • tol (Optional[Union[float, Container]], default: None) – Optional scalar. Ignored when backend is not Tensorflow. The absolute tolerance to which each eigenvalue is required. An eigenvalue (or cluster) is considered to have converged if it lies in an interval of this width. If tol is None (default), the value eps*|T|_2 is used where eps is the machine precision, and |T|_2 is the 2-norm of the matrix T.

Return type:

Union[Container, Tuple[Container, Container]]

Returns:

  • eig_vals – The eigenvalues of the matrix in non-decreasing order.

  • eig_vectors – If eigvals_only is False the eigenvectors are returned in the second output argument.

Examples

With ivy.Container input:

>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.array([0.,2.])
>>> y = ivy.Container.static_eigh_tridiagonal(alpha, beta)
>>> print(y)
{
    a: ivy.array([-0.56155, 0., 3.56155]),
    b: ivy.array([0., 2., 4.])
}
>>> alpha = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([2., 2., 2.]))
>>> beta = ivy.Container(a=ivy.array([0.,2.]), b=ivy.array([2.,2.]))
>>> y = ivy.Container.static_eigh_tridiagonal(alpha, beta)
>>> print(y)
{
    a: ivy.array([-0.56155, 0., 3.56155]),
    b: ivy.array([-0.82842, 2., 4.82842])
}
static static_eigvals(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:

x (Union[Array, NativeArray, Container]) – container with input arrays.

Return type:

Container

Returns:

ret

container including array corresponding to eigenvalues of input array

Examples

>>> x = ivy.array([[1,2], [3,4]])
>>> c = ivy.Container({'x':{'xx':x}})
>>> ivy.Container.eigvals(c)
{
    x: {
        xx: ivy.array([-0.37228132+0.j, 5.37228132+0.j])
    }
}
>>> ivy.Container.eigvals(c)['x']['xx']
ivy.array([-0.37228132+0.j,  5.37228132+0.j])
static static_higher_order_moment(x, order, /, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – matrix of size (n_samples, n_features) or tensor of size(n_samples, D1, …, DN)

  • order (Union[Sequence[int], Container]) – number of the higher-order moment to compute

Return type:

Container

Returns:

tensor – if tensor is a matrix of size (n_samples, n_features), tensor of size (n_features, )*order

static static_initialize_tucker(x, rank, modes, /, *, init='svd', seed=None, svd='truncated_svd', non_negative=False, mask=None, svd_mask_repeats=5, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

  • rank (Union[Sequence[int], Container]) – number of components

  • modes (Union[Sequence[int], Container]) – modes to consider in the input tensor

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – initialization scheme for tucker decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – function to use to compute the SVD

  • non_negative (Optional[Union[bool, Container]], default: False) – if True, non-negative factors are returned

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

Return type:

Tuple[Container, Sequence[Container]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

static static_kron(a, b, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Array, NativeArray, Container]) – first container with input arrays.

  • b (Union[Array, NativeArray, Container]) – second container with input arrays

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays corresponding to the Kronecker product of the arrays in the input containers, computed element-wise

Examples

>>> a = ivy.Container(x=ivy.array([1,2]), y=ivy.array(50))
>>> b = ivy.Container(x=ivy.array([3,4]), y=ivy.array(9))
>>> ivy.Container.static_kron(a, b)
{
    a: ivy.array([3, 4, 6, 8])
    b: ivy.array([450])
}
static static_make_svd_non_negative(x, U, S, V, /, *, nntype='nndsvd', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – tensor being decomposed.

  • U (Union[Array, NativeArray, Container]) – left singular matrix from SVD.

  • S (Union[Array, NativeArray, Container]) – diagonal matrix from SVD.

  • V (Union[Array, NativeArray, Container]) – right singular matrix from SVD.

  • nntype (Optional[Union[Literal['nndsvd', 'nndsvda'], Container]], default: 'nndsvd') – whether to fill small values with 0.0 (nndsvd), or the tensor mean (nndsvda, default).

  • [1] (Boutsidis & Gallopoulos. Pattern Recognition, 41(4): 1350-1362, 2008.) –

Return type:

Tuple[Container, Container]

static static_matrix_exp(x, /, *, key_chains=None, to_apply=True, out=None)[source]#
Return type:

Container

static static_mode_dot(x, /, matrix_or_vector, mode, transpose=False, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – tensor of shape (i_1, ..., i_k, ..., i_N)

  • matrix_or_vector (Union[Array, NativeArray, Container]) – 1D or 2D array of shape (J, i_k) or (i_k, ) matrix or vectors to which to n-mode multiply the tensor

  • mode (Union[int, Container]) – int in the range(1, N)

  • transpose (Optional[Union[bool, Container]], default: False) – If True, the matrix is transposed. For complex tensors, the conjugate transpose is used.

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

Return type:

Container

Returns:

ivy.Containermode-mode product of tensor by matrix_or_vector * of shape \((i_1, ..., i_{k-1}, J, i_{k+1}, ..., i_N)\) if matrix_or_vector is a matrix * of shape \((i_1, ..., i_{k-1}, i_{k+1}, ..., i_N)\) if matrix_or_vector is a vector

static static_multi_dot(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Sequence[Union[Container, Array, NativeArray]]) – sequence of matrices to multiply.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a valid shape, i.e. the resulting shape after applying regular matrix multiplication to the inputs.

Return type:

Container

Returns:

ret – dot product of the arrays.

Examples

With ivy.Container input:

>>> a = ivy.Container(x=ivy.arange(2 * 3).reshape((2, 3)),
...                   y=ivy.arange(2 * 3).reshape((2, 3)))
>>> b = ivy.Container(x=ivy.arange(3 * 2).reshape((3, 2)),
...                   y=ivy.arange(3 * 2).reshape((3, 2)))
>>> c = ivy.Container(x=ivy.arange(2 * 2).reshape((2, 2)),
...                   y=ivy.arange(2 * 2).reshape((2, 2)))
>>> ivy.Container.static_multi_dot((a, b, c))
{
    x: ivy.array([[26, 49],
                  [80, 148]]),
    y: ivy.array([[26, 49],
                  [80, 148]])
}
static static_multi_mode_dot(x, mat_or_vec_list, /, modes=None, skip=None, transpose=False, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – the input tensor

  • mat_or_vec_list (Sequence[Union[Container, Array, NativeArray]]) – sequence of matrices or vectors of length tensor.ndim

  • skip (Optional[Union[Sequence[int], Container]], default: None) – None or int, optional, default is None If not None, index of a matrix to skip.

  • modes (Optional[Union[Sequence[int], Container]], default: None) – None or int list, optional, default is None

  • transpose (Optional[Union[bool, Container]], default: False) – If True, the matrices or vectors in in the list are transposed. For complex tensors, the conjugate transpose is used.

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

Return type:

Container

Returns:

ivy.Container – tensor times each matrix or vector in the list at mode mode

static static_partial_tucker(x, rank, modes, /, *, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

  • rank (Union[Sequence[int], Container]) – number of components

  • modes (Union[Sequence[int], Container]) – modes to consider in the input tensor

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – initialization scheme for tucker decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – function to use to compute the SVD

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

Return type:

Tuple[Container, Sequence[Container]]

Returns:

  • core – initialized core tensor

  • factors – list of factors

static static_svd_flip(U, V, /, u_based_decision=True, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • U (Union[Array, NativeArray, Container]) – left singular matrix output of SVD

  • V (Union[Array, NativeArray, Container]) – right singular matrix output of SVD

  • u_based_decision (Optional[Union[bool, Container]], default: True) – If True, use the columns of u as the basis for sign flipping. Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent.

Return type:

Tuple[Container, Container]

Returns:

u_adjusted, v_adjusted (container with the same dimensions as the input.)

static static_tensor_train(input_tensor, rank, /, *, svd='truncated_svd', verbose=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input_tensor (Union[Array, NativeArray, Container]) – tensor to be decomposed.

  • rank (Union[Sequence[int], Container]) – maximum allowable TT-ranks of the decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – SVD method to use.

  • verbose (Optional[Union[bool, Container]], default: False) – level of verbosity.

Return type:

Tuple[Container, Sequence[Container]]

static static_truncated_svd(x, /, compute_uv=True, n_eigenvecs=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Container of 2D-arrays

  • compute_uv (Union[bool, Container], default: True) – If True then left and right singular vectors will be computed and returned in U and Vh, respectively. Otherwise, only the singular values will be computed, which can be significantly faster.

  • n_eigenvecs (Optional[Union[int, Container]], default: None) – if specified, number of eigen[vectors-values] to return else full matrices will be returned

Return type:

Union[Container, Tuple[Container, Container, Container]]

Returns:

ret – a namedtuple (U, S, Vh) Each returned container must have the same

floating-point data type as x.

static static_tt_matrix_to_tensor(tt_matrix, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • tt_matrix (Union[Array, NativeArray, Container]) – array of 4D-arrays TT-Matrix factors (known as core) of shape (rank_k, left_dim_k, right_dim_k, rank_{k+1})

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

output_tensor – tensor whose TT-Matrix decomposition was given by ‘factors’

Examples

>>> x = ivy.Container(a=ivy.array([[[[[0.49671414],
...                      [-0.1382643]],
...
...                     [[0.64768857],
...                      [1.5230298]]]],
...                   [[[[-0.23415337],
...                      [-0.23413695]],
...
...                     [[1.57921278],
...                      [0.76743472]]]]])))
>>> y = ivy.Container.static_tt_matrix_to_tensor(x)
>>> print(y["a"])
ivy.array([[[[-0.1163073 , -0.11629914],
[ 0.03237505,  0.03237278]],

[[ 0.78441733, 0.38119566], [-0.21834874, -0.10610882]]],

[[[-0.15165846, -0.15164782], [-0.35662258, -0.35659757]],

[[ 1.02283812, 0.49705869], [ 2.40518808, 1.16882598]]]])

static static_tucker(x, rank, /, *, fixed_factors=None, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

  • rank (Union[Sequence[int], Container]) – size of the core tensor, (len(ranks) == tensor.ndim) if int, the same rank is used for all modes

  • fixed_factors (Optional[Union[Sequence[int], Container]], default: None) – if not None, list of modes for which to keep the factors fixed. Only valid if a Tucker tensor is provided as init.

  • n_iter_max (Optional[Union[int, Container]], default: 100) – maximum number of iteration

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – {‘svd’, ‘random’}, or TuckerTensor optional if a TuckerTensor is provided, this is used for initialization

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – str, default is ‘truncated_svd’ function to use to compute the SVD,

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

  • tol (Optional[Union[float, Container]], default: 0.0001) – tolerance: the algorithm stops when the variation in the reconstruction error is less than the tolerance

  • verbose (Optional[Union[bool, Container]], default: False) – if True, different in reconstruction errors are returned at each iteration.

  • return_errors (Optional[Union[bool, Container]], default: False) – Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

Return type:

Tuple[Container, Sequence[Container]]

Returns:

Container of ivy.TuckerTensors or ivy.TuckerTensors and container of reconstruction errors if return_errors is True.

References

SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.

svd_flip(V, /, u_based_decision=True, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – left singular matrix output of SVD

  • V (Union[Array, NativeArray, Container]) – right singular matrix output of SVD

  • u_based_decision (Optional[Union[bool, Container]], default: True) – If True, use the columns of u as the basis for sign flipping. Otherwise, use the rows of v. The choice of which variable to base the decision on is generally algorithm dependent.

Return type:

Tuple[Container, Container]

Returns:

u_adjusted, v_adjusted (container with the same dimensions as the input.)

tensor_train(rank, /, *, svd='truncated_svd', verbose=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input_tensor – tensor to be decomposed.

  • rank (Union[Sequence[int], Container]) – maximum allowable TT-ranks of the decomposition.

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – SVD method to use.

  • verbose (Optional[Union[bool, Container]], default: False) – level of verbosity.

Return type:

Tuple[Container, Sequence[Container]]

truncated_svd(compute_uv=True, n_eigenvecs=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x – Container of 2D-arrays

  • compute_uv (Union[bool, Container], default: True) – If True then left and right singular vectors will be computed and returned in U and Vh respectively. Otherwise, only the singular values will be computed, which can be significantly faster.

  • n_eigenvecs (Optional[Union[int, Container]], default: None) – if specified, number of eigen[vectors-values] to return else full matrices will be returned

Return type:

Union[Container, Tuple[Container, Container, Container]]

Returns:

ret – a namedtuple (U, S, Vh) Each returned container must have the same floating-point data type as x.

tt_matrix_to_tensor(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • tt_matrix – array of 4D-arrays TT-Matrix factors (known as core) of shape (rank_k, left_dim_k, right_dim_k, rank_{k+1})

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

output_tensor – tensor whose TT-Matrix decomposition was given by ‘factors’

Examples

>>> x = ivy.Container(a=ivy.array([[[[[0.49671414],
...                      [-0.1382643]],
...
...                     [[0.64768857],
...                      [1.5230298]]]],
...                   [[[[-0.23415337],
...                      [-0.23413695]],
...
...                     [[1.57921278],
...                      [0.76743472]]]]])))
>>> y = ivy.Container.tt_matrix_to_tensor(x)
>>> print(y["a"])
ivy.array([[[[-0.1163073 , -0.11629914],
[ 0.03237505,  0.03237278]],

[[ 0.78441733, 0.38119566], [-0.21834874, -0.10610882]]],

[[[-0.15165846, -0.15164782], [-0.35662258, -0.35659757]],

[[ 1.02283812, 0.49705869], [ 2.40518808, 1.16882598]]]])

tucker(rank, /, *, fixed_factors=None, n_iter_max=100, init='svd', svd='truncated_svd', seed=None, mask=None, svd_mask_repeats=5, tol=0.0001, verbose=False, return_errors=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x – input tensor

  • rank (Union[Sequence[int], Container]) – size of the core tensor, (len(ranks) == tensor.ndim) if int, the same rank is used for all modes

  • fixed_factors (Optional[Union[Sequence[int], Container]], default: None) – if not None, list of modes for which to keep the factors fixed. Only valid if a Tucker tensor is provided as init.

  • n_iter_max (Optional[Union[int, Container]], default: 100) – maximum number of iteration

  • init (Optional[Union[Literal['svd', 'random'], TuckerTensor, Container]], default: 'svd') – {‘svd’, ‘random’}, or TuckerTensor optional if a TuckerTensor is provided, this is used for initialization

  • svd (Optional[Union[Literal['truncated_svd'], Container]], default: 'truncated_svd') – str, default is ‘truncated_svd’ function to use to compute the SVD,

  • seed (Optional[Union[int, Container]], default: None) – Used to create a random seed distribution when init == ‘random’

  • mask (Optional[Union[Array, NativeArray, Container]], default: None) – array of booleans with the same shape as tensor should be 0 where the values are missing and 1 everywhere else. Note: if tensor is sparse, then mask should also be sparse with a fill value of 1 (or True).

  • svd_mask_repeats (Optional[Union[int, Container]], default: 5) – number of iterations for imputing the values in the SVD matrix when mask is not None

  • tol (Optional[Union[float, Container]], default: 0.0001) – tolerance: the algorithm stops when the variation in the reconstruction error is less than the tolerance

  • verbose (Optional[Union[bool, Container]], default: False) – if True, different in reconstruction errors are returned at each iteration.

  • return_errors (Optional[Union[bool, Container]], default: False) – Indicates whether the algorithm should return all reconstruction errors and computation time of each iteration or not Default: False

Return type:

Tuple[Container, Sequence[Container]]

Returns:

Container of ivy.TuckerTensors or ivy.TuckerTensors and container of reconstruction errors if return_errors is True.

References

SIAM REVIEW, vol. 51, n. 3, pp. 455-500, 2009.

class ivy.data_classes.container.experimental.losses._ContainerWithLossesExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_hinge_embedding_loss(input, target, *, margin=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.hinge_embedding_loss. This method simplywraps the function, and so the docstring for ivy.hinge_embedding_loss also applies to this method with minimal changes.

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the target labels.

  • margin ([typing.Union[float, ivy.Container]], default: 1.0) – Sets the hyperparameter margin. Determines the necessary input size for hinge_embedding_loss calculations when label is -1. Inputs smaller than the margin are minimized with hinge_embedding_loss. Default is 1.0.

  • reduction ([typing.Union[str, ivy.Container]], default: 'mean') – Specifies how to aggregate the loss across the batch. Options are: - 'none': Returns the unreduced loss. - 'mean': Returns the mean loss. - 'sum': Returns the summed loss. Default is 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

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

  • Shape

  • -----

    • Input: \((*)\) where \(*\) means, any number of dimensions.

    The sum operation operates over all the elements. - Target: \((*)\), same shape as the input - Output: scalar. If reduction is 'none', then same shape as the input

Return type:

Container

Returns:

ret – Hinge embedding loss calculated from the input and label, shaped based on the reduction method.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[1, 0, 2]], dtype=ivy.float32),
...             b=ivy.array([[-1, 1, 1]], dtype=ivy.float32))
>>> y = ivy.Container(a=ivy.array([[0.6, 0.2, 0.3]], dtype=ivy.float32),
...            b=ivy.array([[1, 1, 1]], dtype=ivy.float32))
>>> z = ivy.Container._static_hinge_embedding_loss(x, y, reduction="none")
>>> z
{
    a: ivy.array([[0., 0., 0.]]),
    b: ivy.array([[-1., 1., 1.]])
}

With a mix of ivy.Array and ivy.Container inputs:

>>> x = ivy.array([[10, 20, 32]], dtype=ivy.float32)
>>> y = ivy.Container(a=ivy.array([[-1, -1, -1]], dtype=ivy.float32),
...           b=ivy.array([[1, 1, 1]], dtype=ivy.float32))
>>> z = ivy.Container._static_hinge_embedding_loss(x, y,
...                             reduction="sum", margin=2.0)
>>> z
{
    a: ivy.array(0.),
    b: ivy.array(62.)
}
static _static_huber_loss(true, pred, /, *, delta=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • true (Union[Container, Array, NativeArray]) – true array or container containing true labels.

  • pred (Union[Container, Array, NativeArray]) – true array or container containing the predicted labels.

  • delta (Optional[Union[float, Container]], default: 1.0) – The threshold parameter that determines the point where the loss transitions from squared error to absolute error. Default is 1.0.

  • reduction (str, optional) – The type of reduction to apply to the loss. Possible values are “mean” (default) and “sum”.

  • 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 true broadcast to.

Return type:

Container

Returns:

ret – The Huber loss between the true and predicted values.

Examples

With ivy.Container trues:

>>> x = ivy.Container(a=ivy.array([1, 0, 3]), b=ivy.array([0, 0, 2]))
>>> y = ivy.Container(a=ivy.array([1.5, 0.2, 2.8]), b=ivy.array([0.5, 0.2, 1.9])
)
>>> z = ivy.Container.static_huber_loss(x, y, delta=1.0)
>>> print(z)
{
    a: ivy.array(0.0575),
    b: ivy.array(0.005)
}

With a mix of ivy.Array and ivy.Container trues:

>>> x = ivy.array([1, 0, 3])
>>> y = ivy.Container(a=ivy.array([1.5, 0.2, 2.8]), b=ivy.array([0.5, 0.2, 1.9])
)
>>> z = ivy.Container.static_huber_loss(x, y, delta=1.0)
>>> print(z)
{
    a: ivy.array(0.0575),
    b: ivy.array(0.005)
}
static _static_kl_div(input, target, /, *, reduction='mean', log_target=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container containing input distribution.

  • target (Union[Container, Array, NativeArray]) – input array or container containing target distribution.

  • reduction (Optional[Union[str, Container]], default: 'mean') – the reduction method. Default: “mean”.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The Kullback-Leibler divergence loss between the given distributions.

static _static_l1_loss(input, target, /, *, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeted values.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'mean': The output will be averaged. 'sum': The output will be summed. 'none': No reduction will be applied to the output. Default: 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The L1 loss between the input array and the targeted values.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = ivy.Container.static_l1_loss(x, y)
>>> print(z)
{
    a: ivy.array(1.),
    b: ivy.array(0.)
}

With a mix of ivy.Array and ivy.Container inputs:

>>> x = ivy.array([1, 2, 3])
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = ivy.Container.static_l1_loss(x, y)
>>> print(z)
{
    a: ivy.array(1.),
    b: ivy.array(4.)
}
static _static_log_poisson_loss(input, target, /, *, compute_full_loss=False, axis=-1, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeted values.

  • compute_full_loss (bool, default: False) – whether to compute the full loss. If false, a constant term is dropped in favor of more efficient optimization. Default: False.

  • axis (int, default: -1) – the axis along which to compute the log-likelihood loss. If axis is -1, the log-likelihood loss will be computed along the last dimension. Default: -1.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'mean': The output will be averaged. 'sum': The output will be summed. 'none': No reduction will be applied to the output. 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The L1 loss between the input array and the targeted values.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = ivy.Container.static_log_poisson_loss(x, y, reduction='mean')
>>> print(z)
{
    a: ivy.array(1.),
    b: ivy.array(0.)
}

With a mix of ivy.Array and ivy.Container inputs:

>>> x = ivy.array([1, 2, 3])
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = ivy.Container.static_log_poisson_loss(x, y, reduction='mean')
>>> print(z)
{
    a: ivy.array(1.),
    b: ivy.array(4.)
}
static _static_poisson_nll_loss(input, target, *, log_input=True, full=False, eps=1e-08, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.poisson_nll_loss. This method simplywraps the function, and so the docstring for ivy.poisson_nll_loss also applies to this method with minimal changes.

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the target labels.

  • log_input ([typing.Union[bool, ivy.Container]], default: True) – If True, the loss is computed as \(exp(input) - target * input\). If False, the loss is computed as \(input - target * log(input + eps)\). Default is True.

  • full ([typing.Union[bool, ivy.Container]], default: False) – Whether to compute the full loss, i.e., to add the Stirling approximation term \(target * log(target) - target + 0.5 * log(2 * pi * target)\). Default is False.

  • eps ([typing.Union[float, ivy.Container]], default: 1e-08) – Small value to prevent evaluation of log(0) when log_input is False. Default is 1e-8.

  • reduction ([typing.Union[str, ivy.Container]], default: 'mean') – Specifies the reduction applied to the output. Options are ‘none’, ‘mean’, or ‘sum’. ‘none’: no reduction will be applied. ‘mean’: the output will be averaged. ‘sum’: the output will be summed. Default is ‘mean’.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

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

Return type:

Container

Returns:

ret – An array of the same shape as input representing the Poisson Negative Log Likelihood Loss.

Raises:

ValueError – If the input and target tensors do not have the same shape.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[0.6, 0.2, 0.3]], dtype=ivy.float32),
...                   b=ivy.array([[0.8, 0.2, 0.2]], dtype=ivy.float32))
>>> y = ivy.Container(a=ivy.array([[1, 0, 2]], dtype=ivy.float32),
...                   b=ivy.array([[3, 2, 1]], dtype=ivy.float32))
>>> z = ivy.Container._static_poisson_nll_loss(x,y)
>>> print(z)
{
    a: ivy.array(1.06446016),
    b: ivy.array(0.55611551)
}

With a mix of ivy.Array and ivy.Container inputs:

>>> x = ivy.array([[1, 0, 2]], dtype=ivy.float32)
>>> y = ivy.Container(a=ivy.array([[0.6, 0.2, 0.3]], dtype=ivy.float32),
...             b=ivy.array([[0.8, 0.2, 0.2]], dtype=ivy.float32))
>>> z = ivy.Container._static_poisson_nll_loss(x, y)
>>> print(z)
{
    a: ivy.array(3.30244565),
    b: ivy.array(3.30244565)
}
static _static_smooth_l1_loss(input, target, /, *, beta=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted labels.

  • beta (Optional[Union[float, Container]], default: 1.0) – a positive float value that sets the smoothness threshold. Default: 1.0.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'none': No reduction will be applied to the output. 'mean': The output will be averaged. 'sum': The output will be summed. Default: 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The smooth L1 loss between the input array and the targeticted labels.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([1, 0, 2]), b=ivy.array([3, 2, 1]))
>>> y = ivy.Container(a=ivy.array([0.6, 0.2, 0.3]),
b=ivy.array([0.8, 0.2, 0.2]))
>>> z = ivy.Container.static_smooth_l1_loss(x, y)
>>> print(z)
{
    a: ivy.array(0.9),
    b: ivy.array(0.25)
}

With a mix of ivy.Array and ivy.Container inputs:

>>> x = ivy.array([1 , 0, 2])
>>> y = ivy.Container(a=ivy.array([0.6, 0.2, 0.3]),
b=ivy.array([0.8, 0.2, 0.2]))
>>> z = ivy.Container.static_smooth_l1_loss(x, y)
>>> print(z)
{
    a: ivy.array(0.9),
    b: ivy.array(0.25)
}
static _static_soft_margin_loss(input, target, /, *, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

# Insert the docstring here

Parameters:
  • input (Union[Container, Array, NativeArray]) – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted labels.

  • reduction (Optional[Union[str, Container]], default: 'mean') – the reduction method. Default: “mean”.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The soft margin loss between the given distributions.

hinge_embedding_loss(target, *, margin=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • input – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the target labels.

  • margin ([typing.Union[float, ivy.Container]], default: 1.0) – Sets the hyperparameter margin. Determines the necessary input size for hinge_embedding_loss calculations when label is -1. Inputs smaller than the margin are minimized with hinge_embedding_loss. Default is 1.0.

  • reduction ([typing.Union[str, ivy.Container]], default: 'mean') – Specifies how to aggregate the loss across the batch. Options are: - 'none': Returns the unreduced loss. - 'mean': Returns the mean loss. - 'sum': Returns the summed loss. Default is 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

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

  • Shape

  • -----

    • Input: \((*)\) where \(*\) means, any number of dimensions.

    The sum operation operates over all the elements. - Target: \((*)\), same shape as the input - Output: scalar. If reduction is 'none', then same shape as the input

Return type:

Container

Returns:

ret – Hinge embedding loss calculated from the input and label, shaped based on the reduction method.

Examples

>>> x = ivy.Container(a=ivy.array([[1, 0, 2]], dtype=ivy.float32),
...              b=ivy.array([[3, 2, 1]], dtype=ivy.float32))
>>> y = ivy.Container(a=ivy.array([[-1, -1, -1]], dtype=ivy.float32),
...              b=ivy.array([[1, 1, 1]], dtype=ivy.float32))
>>> x.hinge_embedding_loss(y, reduction="none", margin=0.5)
{
    a: ivy.array([[0., 0.5, 0.]]),
    b: ivy.array([[3., 2., 1.]])
}
huber_loss(pred, /, *, delta=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – true container containing true labels.

  • pred (Union[Container, Array, NativeArray]) – true array or container containing the predicted labels.

  • delta (Optional[Union[float, Container]], default: 1.0) – The threshold parameter that determines the point where the loss transitions from squared error to absolute error. Default is 1.0.

  • reduction (str, optional) – The type of reduction to apply to the loss. Possible values are “mean” (default) and “sum”.

  • 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 trues broadcast to.

Return type:

Container

Returns:

ret – The Huber loss between the true and predicted values.

Examples

>>> x = ivy.Container(a=ivy.array([1, 0, 3]), b=ivy.array([0, 0, 2]))
>>> y = ivy.Container(a=ivy.array([1.5, 0.2, 2.8]), b=ivy.array([0.5, 0.2, 1.9])
)
>>> z = x.huber_loss(y, delta=1.0)
>>> print(z)
{
    a: ivy.array(0.0575),
    b: ivy.array(0.005)
}
kl_div(target, /, *, reduction='mean', log_target=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container containing input distribution.

  • target (Union[Container, Array, NativeArray]) – input array or container containing target distribution.

  • reduction (Optional[Union[str, Container]], default: 'mean') – the reduction method. Default: “mean”.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The Kullback-Leibler divergence loss between the given distributions.

l1_loss(target, /, *, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted values.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'mean': The output will be averaged. 'sum': The output will be summed. 'none': No reduction will be applied to the output. Default: 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The L1 loss between the input array and the targeticted values.

Examples

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = x.l1_loss(y)
>>> print(z)
{
    a: ivy.array(0.),
    b: ivy.array(0.)
}
log_poisson_loss(target, /, *, compute_full_loss=False, axis=-1, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted values.

  • compute_full_loss (bool, default: False) – whether to compute the full loss. If false, a constant term is dropped in favor of more efficient optimization. Default: False.

  • axis (int, default: -1) – the axis along which to compute the log-likelihood loss. If axis is -1, the log-likelihood loss will be computed along the last dimension. Default: -1.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'mean': The output will be averaged. 'sum': The output will be summed. 'none': No reduction will be applied to the output. 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The L1 loss between the input array and the targeticted values.

Examples

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))
>>> y = ivy.Container(a=ivy.array([2, 2, 2]), b=ivy.array([5, 5, 5]))
>>> z = x.log_poisson_loss(y)
>>> print(z)
{
    a: ivy.array(3.3890561),
    b: ivy.array(123.413159)
}
poisson_nll_loss(target, *, log_input=True, full=False, eps=1e-08, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – input array or container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the target labels.

  • log_input ([typing.Union[bool, ivy.Container]], default: True) – If True, the loss is computed as \(exp(input) - target * input\). If False, the loss is computed as \(input - target * log(input + eps)\). Default is True.

  • full ([typing.Union[bool, ivy.Container]], default: False) – Whether to compute the full loss, i.e., to add the Stirling approximation term \(target * log(target) - target + 0.5 * log(2 * pi * target)\). Default is False.

  • eps ([typing.Union[float, ivy.Container]], default: 1e-08) – Small value to prevent evaluation of log(0) when log_input is False. Default is 1e-8.

  • reduction ([typing.Union[str, ivy.Container]], default: 'mean') – Specifies the reduction applied to the output. Options are ‘none’, ‘mean’, or ‘sum’. ‘none’: no reduction will be applied. ‘mean’: the output will be averaged. ‘sum’: the output will be summed. Default is ‘mean’.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

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

Return type:

Container

Returns:

ret – An array of the same shape as input representing the Poisson Negative Log Likelihood Loss.

Raises:

ValueError – If the input and target tensors do not have the same shape.

Examples

>>> x = ivy.Container(a=ivy.array([[1, 0, 2]], dtype=ivy.float32),
...              b=ivy.array([[3, 2, 1]], dtype=ivy.float32))
>>> y = ivy.Container(a=ivy.array([[0.6, 0.2, 0.3]], dtype=ivy.float32),
...              b=ivy.array([[0.8, 0.2, 0.2]], dtype=ivy.float32))
>>> z = x.poisson_nll_loss(y)
>>> print(z)
{
    a: ivy.array(3.30244565),
    b: ivy.array(9.06429195)
}
smooth_l1_loss(target, /, *, beta=1.0, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted labels.

  • beta (Optional[Union[float, Container]], default: 1.0) – a positive float value that sets the smoothness threshold. Default: 1.0.

  • reduction (Optional[Union[str, Container]], default: 'mean') – 'none': No reduction will be applied to the output. 'mean': The output will be averaged. 'sum': The output will be summed. Default: 'mean'.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The smooth L1 loss between the input array and the targeticted labels.

Examples

>>> x = ivy.Container(a=ivy.array([1, 0, 2]), b=ivy.array([3, 2, 1]))
>>> y = ivy.Container(a=ivy.array([0.6, 0.2, 0.3]),
...                   b=ivy.array([0.8, 0.2, 0.2]))
>>> z = x.smooth_l1_loss(y)
>>> print(z)
{
    a: ivy.array(0.43333333),
    b: ivy.array(1.10666666)
}
soft_margin_loss(target, /, *, reduction='mean', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

# Insert the docstring here

Parameters:
  • self (Container) – input container containing input labels.

  • target (Union[Container, Array, NativeArray]) – input array or container containing the targeticted labels.

  • reduction (Optional[Union[str, Container]], default: 'mean') – the reduction method. Default: “mean”.

  • 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 input, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is input.

  • 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 – The soft margin loss between the given distributions.

class ivy.data_classes.container.experimental.manipulation._ContainerWithManipulationExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_fill_diagonal(a, v, /, *, wrap=False)[source]#

ivy.Container static method variant of ivy.fill_diagonal.

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

Return type:

Container

static _static_put_along_axis(arr, indices, values, axis, /, *, mode='replace', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.put_along_axis.

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

Return type:

Container

static _static_take(x, indices, /, *, axis=None, mode='fill', fill_value=None, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.take.

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

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

  • indices (Union[int, Array, NativeArray, Container]) – array indices. Must have an integer data type.

  • axis (Optional[Union[int, Container]], default: None) – axis over which to select values. If axis is negative, the function must determine the axis along which to select values by counting from the last dimension. By default, the flattened input array is used.

  • mode (Union[str, Container], default: 'fill') – specifies how out-of-bounds indices will behave. - ‘raise’ – raise an error - ‘wrap’ – wrap around - ‘clip’ – clip to the range (all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers.) - ‘fill’ (default) = returns invalid values (e.g. NaN) for out-of bounds indices (see also fill_value below)

  • fill_value (Optional[Union[Number, Container]], default: None) – fill value to return for out-of-bounds slices (Defaults to NaN for inexact types, the largest negative value for signed types, the largest positive value for unsigned types, and True for booleans.)

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

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

Return type:

Container

Returns:

ret

an array having the same data type as x. The output array must have the same rank (i.e., number of dimensions) as x and must have the same shape as x, except for the axis specified by axis whose size must equal the number of elements in indices.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([True,False,False]),
...                     b=ivy.array([2.3,4.5,6.7]),
...                     c=ivy.array([1,2,3]))
>>> indices = ivy.array([[1,9,2]])
>>> y = ivy.Container._static_take(x, indices)
>>> print(y)
{
    a: ivy.array([[False, True, False]]),
    b: ivy.array([[4.5, nan, 6.69999981]]),
    c: ivy.array([[2, -2147483648, 3]])
}
static _static_trim_zeros(a, /, *, trim='fb')[source]#

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

Parameters:
  • self (1-D array) – Input array.

  • trim (str, optional) – A string with ‘f’ representing trim from front and ‘b’ to trim from back. Default is ‘fb’, trim zeros from both front and back of the array.

Return type:

Container

Returns:

1-D array The result of trimming the input. The input data type is preserved.

Examples

>>> a = ivy.array([0, 0, 0, 0, 8, 3, 0, 0, 7, 1, 0])
>>> ivy.trim_zeros(a)
array([8, 3, 0, 0, 7, 1])
>>> ivy.trim_zeros(a, 'b')
array([0, 0, 0, 0, 8, 3, 0, 0, 7, 1])
>>> ivy.trim_zeros([0, 8, 3, 0, 0])
[8, 3]
static _static_unflatten(x, /, shape, dim=0, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

  • shape (Union[Tuple[int], Array, NativeArray, Container]) – array indices. Must have an integer data type.

  • dim (Optional[Union[int, Container]], default: 0) – axis over which to select values. If axis is negative, the function must determine the axis along which to select values by counting from the last dimension. By default, the flattened input array is used.

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

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

Return type:

Container

Returns:

ret

an array having the same data type as x. The output array must have the same rank (i.e., number of dimensions) as x and must have the same shape as x, except for the axis specified by axis whose size must equal the number of elements in indices.

Examples

With ‘ivy.Container’ input:

>>> x = ivy.Container(a = ivy.array([[True, False, False, True],
                                    [False, True, False, True]])),
...                     b = ivy.array([[1.2, 2.3, 3.4, 4.5],
                                    [5.6, 6.7, 7.8, 8.9]]),
...                     c = ivy.array([[1, 2, 3, 4],
                                    [5, 6, 7, 8]]))
>>> dim = 1
>>> shape = (2, 2)
>>> y = ivy.Container._static_unflatten(x, shape=shape, dim=dim)
>>> print(y)
{
    a: ivy.array([[[True, False], [False, True]],
                [[False, True], [False, True]]])
    b: ivy.array([[[1.2, 2.3], [3.4, 4.5]], [[5.6, 6.7], [7.8, 8.9]]])
    c: ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
}
static _static_unique_consecutive(x, /, *, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.unique_consecutive.

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

Return type:

Container

as_strided(shape, strides, /)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – Input container.

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – The shape of the new arrays.

  • strides (Union[Sequence[int], Container]) – The strides of the new arrays (specified in bytes).

Return type:

Container

Returns:

ret – Output container.

associative_scan(fn, /, *, reverse=False, axis=0)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – The Container to scan over.

  • fn (Union[Callable, Container]) – The associative function to apply.

  • reverse (Union[bool, Container], default: False) – Whether to scan in reverse with respect to the given axis.

  • axis (Union[int, Container], default: 0) – The axis to scan over.

Return type:

Container

Returns:

ret – The result of the scan.

atleast_1d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – the container with array inputs.

  • arys (Union[Container, Array, NativeArray, bool, Number]) – one or more container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 1d. Copies are made only if necessary.

Examples

>>> ary1 = ivy.Container(a=ivy.array(1), b=ivy.array([3,4]),                            c=ivy.array([[5]]))
>>> ary2 = ivy.Container(a=ivy.array(9), b=ivy.array(2),                            c=ivy.array(3))
>>> ary1.atleast_1d(ary2)
[{
    a: ivy.array([1]),
    b: ivy.array([3, 4]),
    c: ivy.array([[5]])
}, {
    a: ivy.array([9]),
    b: ivy.array([2]),
    c: ivy.array([3])
}]
atleast_2d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – container with array inputs.

  • arys (Union[Container, Array, NativeArray]) – one or more container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 2D. Copies are made only if necessary.

Examples

>>> ary1 = ivy.Container(a=ivy.array(1), b=ivy.array([3,4]),                            c=ivy.array([[5]]))
>>> ary2 = ivy.Container(a=ivy.array(9), b=ivy.array(2),                            c=ivy.array(3))
>>> ary1.atleast_2d(ary2)
[{
    a: ivy.array([[1]]),
    b: ivy.array([[3, 4]]),
    c: ivy.array([[5]])
}, {
    a: ivy.array([[9]]),
    b: ivy.array([[2]]),
    c: ivy.array([[3]])
}]
atleast_3d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – container with array inputs.

  • arys (Union[Container, Array, NativeArray, bool, Number]) – one or more container with array inputs.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 3D. Copies are made only if necessary. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).

Examples

>>> ary1 = ivy.Container(a=ivy.array(1), b=ivy.array([3,4]),                            c=ivy.array([[5]]))
>>> ary2 = ivy.Container(a=ivy.array(9), b=ivy.array(2),                            c=ivy.array(3))
>>> ary1.atleast_3d(ary2)
[{
    a: ivy.array([[[1]]]),
    b: ivy.array([[[3],
                   [4]]]),
    c: ivy.array([[[5]]])
}, {
    a: ivy.array([[[9]]]),
    b: ivy.array([[[2]]]),
    c: ivy.array([[[3]]])
}]
broadcast_shapes(*, out=None)[source]#

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

Parameters:

self (Container) – the container with shapes to broadcast.

Return type:

Container

Returns:

ret – Container with broadcasted shapes.

Examples

>>> shapes = ivy.Container(a = (2, 3, 5),
...                        b = (2, 3, 1))
>>> z = shapes.broadcast_shapes()
>>> print(z)
{
    a: [2, 3, 5],
    b: [2, 3, 1]
}
column_stack(xs, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.column_stack.

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

Parameters:
  • self (Container) – Container with leaves to stack with leaves of other arrays/containers.

  • xs (Sequence[Union[Container, Array, NativeArray]]) – Container with other leaves to join.

  • 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 array, for writing the result to.

Return type:

Container

Returns:

ret – An output container with the results.

concat_from_sequence(input_sequence, *, new_axis=0, axis=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) –

    Container with leaves to join with leaves of other arrays/containers.

    Each array leave must have the same shape.

  • input_sequence (Union[Tuple[Union[Array, NativeArray, Container]], List[Union[Array, NativeArray, Container]]]) – Container with other leaves to join. Each array leave must have the same shape.

  • new_axis (Union[int, Container], default: 0) – Insert and concatenate on a new axis or not, default 0 means do not insert new axis. new_axis = 0: concatenate new_axis = 1: stack

  • axis (Union[int, Container], default: 0) – axis along which the array leaves will be concatenated. More details can be found in the docstring for ivy.stack.

  • 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 array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an output container with the results.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> z = ivy.Container.static_concat_from_sequence([x,y],axis=1)
>>> print(z)
{
    a: ivy.array([[[0, 1],
                [3, 2]],
                [[2, 3],
                [1, 0]]]),
    b: ivy.array([[[4, 5],
                [1, 0]]])
}
dsplit(indices_or_sections, /, *, copy=None)[source]#

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

Parameters:
  • self (Container) – the container with array inputs.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

Return type:

List[Container]

Returns:

ret – list of containers holding arrays split from the input at the 3rd axis

Examples

>>> ary = ivy.Container(
    a = ivy.array(
            [[[0.,  1.],
              [2.,  3.]],
              [[4.,  5.],
              [6.,  7.]]]
        ),
    b=ivy.array(
            [[[ 0.,  1.,  2.,  3.],
              [ 4.,  5.,  6.,  7.],
              [ 8.,  9., 10., 11.],
              [12., 13., 14., 15.]]]
        )
    )
>>> ary.dsplit(2)
[{
    a: ivy.array([[[0.], [2.]],
                  [[4.], [6.]]]),
    b: ivy.array([[[0., 1.], [4., 5.], [8., 9.], [12., 13.]]])
}, {
    a: ivy.array([[[1.], [3.]],
                  [[5.], [7.]]]),
    b: ivy.array([[[2., 3.], [6., 7.], [10., 11.], [14., 15.]]])
}]
dstack(xs, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> x.dstack([y])
{
    a: ivy.array([[[0, 3],
                   [1, 2]],
                  [[2, 1],
                   [3, 0]]]),
    b: ivy.array([[[4, 1]],
                   [[5, 0]]])
}
expand(shape, /, *, copy=None, out=None)[source]#
Parameters:
  • self (Union[Array, NativeArray, Container]) – input container.

  • shape (Union[Shape, NativeShape, Container]) – A 1-D Array indicates the shape you want to expand to, following the broadcast rule.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None. device

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

Return type:

Container

Returns:

ret – An output Container with the results.

fill_diagonal(v, /, *, wrap=False)[source]#

ivy.Container instance method variant of ivy.fill_diagonal.

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

Return type:

Container

flatten(*, copy=None, start_dim=0, end_dim=-1, order='C', out=None)[source]#

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

Parameters:
  • self (Container) – input container to flatten at leaves.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • start_dim (Union[int, Container], default: 0) – first dim to flatten. If not set, defaults to 0.

  • end_dim (Union[int, Container], default: -1) – last dim to flatten. If not set, defaults to -1.

  • order (Union[str, Container], default: 'C') – Read the elements of the input container using this index order, and place the elements into the reshaped array using this index order. ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. Default order is ‘C’

Return type:

Container

Returns:

ret – Container with arrays flattened at leaves.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]),
...                   b=ivy.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]))
>>> x.flatten()
[{
    a: ivy.array([1, 2, 3, 4, 5, 6, 7, 8])
    b: ivy.array([9, 10, 11, 12, 13, 14, 15, 16])
}]
>>> x = ivy.Container(a=ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]),
...                   b=ivy.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]))
>>> x.flatten(order="F")
[{
    a: ivy.array([1, 5, 3, 7, 2, 6, 4, 8])
    b: ivy.array([9, 13, 11, 15, 10, 14, 12, 16])
}]
fliplr(*, copy=None, out=None)[source]#

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

Parameters:
  • self (Container) – the container with arrays to be flipped. Arrays must be at least 2-D.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays corresponding to the input container’s array with elements order reversed along axis 1.

Examples

With one ivy.Container input:

>>> m = ivy.Container(a=ivy.diag([1, 2, 3]),        ...                    b=ivy.array([[1, 2, 3],[4, 5, 6]]))
>>> m.fliplr()
{
    a: ivy.array([[0, 0, 1],
                  [0, 2, 0],
                  [3, 0, 0]]),
    b: ivy.array([[3, 2, 1],
                  [6, 5, 4]])
}
flipud(*, copy=None, out=None)[source]#

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

Parameters:
  • self (Container) – the container with arrays to be flipped.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays corresponding to the input container’s array with elements order reversed along axis 0.

Examples

With one ivy.Container input:

>>> m = ivy.Container(a=ivy.diag([1, 2, 3]), b=ivy.arange(4))
>>> m.flipud()
{
    a: ivy.array(
        [[ 0.,  0.,  3.],
         [ 0.,  2.,  0.],
         [ 1.,  0.,  0.]]
    )
    b: ivy.array([3, 2, 1, 0])
}
fold(mode, shape, *, out=None)[source]#

ivy.Container instance method variant of ivy.fold.

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

Parameters:
  • self (Container) – input tensor to be folded

  • mode (Union[int, Container]) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – shape of the original tensor before unfolding

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

  • -------

  • ret – Container of folded tensors

Return type:

Container

heaviside(x2, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – input container including the arrays.

  • x2 (Container) – values to use where the array is zero.

  • out (Optional[Container], default: None) – optional output container array, for writing the result to.

Return type:

Container

Returns:

ret – output container with element-wise Heaviside step function of each array.

Examples

With ivy.Array input: >>> x1 = ivy.Container(a=ivy.array([-1.5, 0, 2.0]), b=ivy.array([3.0, 5.0]) >>> x2 = ivy.Container(a=0.5, b=[1.0, 2.0]) >>> x1.heaviside(x2) {

a: ivy.array([ 0. , 0.5, 1. ]) b: ivy.array([1.0, 1.0])

}

hsplit(indices_or_sections, copy=None, /)[source]#

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

Parameters:
  • self (Container) – the container with array inputs.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

Return type:

List[Container]

Returns:

ret – list of containers split horizontally from input container

Examples

>>> ary = ivy.Container(
    a = ivy.array(
            [[[0.,  1.],
              [2.,  3.]],
              [[4.,  5.],
              [6.,  7.]]]
        ),
    b=ivy.array(
            [0.,  1.,  2.,  3.,
             4.,  5.,  6.,  7.,
             8.,  9.,  10., 11.,
             12., 13., 14., 15.]
        )
    )
>>> ary.hsplit(2)
[{
    a: ivy.array([[[0., 1.]],
                  [[4., 5.]]]),
    b: ivy.array([0., 1., 2., 3., 4., 5., 6., 7.])
}, {
    a: ivy.array([[[2., 3.]],
                  [[6., 7.]]]),
    b: ivy.array([8., 9., 10., 11., 12., 13., 14., 15.])
}]
hstack(xs, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> z = x.hstack([y])
>>> print(z)
{
    a: ivy.array([[0, 1, 3, 2],
                  [2, 3, 1, 0]]),
    b: ivy.array([[4, 5, 1, 0]])
}
i0(*, out=None)[source]#

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

Parameters:
  • self (Container) – the container with array inputs.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays with the modified Bessel function evaluated at each of the elements of x.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array(4))
>>> x.i0()
{
    a: ivy.array([1.26606588, 2.2795853 , 4.88079259])
    b: ivy.array(11.30192195)
}
matricize(row_modes, column_modes=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.matricize.

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – the input tensor

  • row_modes (Union[Sequence[int], Container]) – modes to use as row of the matrix (in the desired order)

  • column_modes (Optional[Union[Sequence[int], Container]], default: None) – modes to use as column of the matrix, in the desired order if None, the modes not in row_modes will be used in ascending order

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

  • ret

  • ------- – ivy.Container

Return type:

Container

moveaxis(source, destination, /, *, copy=None, out=None)[source]#

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

Parameters:
  • self (Container) – The container with the arrays whose axes should be reordered.

  • source (Union[int, Sequence[int], Container]) – Original positions of the axes to move. These must be unique.

  • destination (Union[int, Sequence[int], Container]) – Destination positions for each of the original axes. These must also be unique.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with moved axes.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.zeros((3, 4, 5)), b=ivy.zeros((2,7,6))) >>> x.moveaxis(, 0, -1).shape {

a: (4, 5, 3) b: (7, 6, 2)

}

pad(pad_width, /, *, mode='constant', stat_length=1, constant_values=0, end_values=0, reflect_type='even', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None, **kwargs)[source]#

ivy.Container instance method variant of ivy.pad.

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

Return type:

Container

partial_fold(mode, shape, skip_begin=1, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.partial_fold.

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

Parameters:
  • self (Union[Array, NativeArray]) – a partially unfolded tensor

  • mode (Union[int, Container]) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions left untouched at the beginning

  • 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 – partially re-folded tensor

partial_tensor_to_vec(skip_begin=1, skip_end=0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.partial_tensor_to_vec.

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – tensor to partially vectorise

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[Union[int, Container]], default: 0) – number of dimensions to leave untouched at the end

  • 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 – partially re-folded tensor

partial_unfold(mode=0, skip_begin=1, skip_end=0, ravel_tensors=False, *, out=None)[source]#

ivy.Container instance method variant of ivy.partial_unfold.

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – tensor of shape n_samples x n_1 x n_2 x … x n_i

  • mode (Optional[Union[int, Container]], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[Union[int, Container]], default: 0) – number of dimensions to leave untouched at the end

  • ravel_tensors (Optional[Union[bool, Container]], default: False) – if True, the unfolded tensors are also flattened

  • 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 – partially unfolded tensor

partial_vec_to_tensor(shape, skip_begin=1, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.partial_vec_to_tensor.

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – partially vectorized tensor

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • 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 – full tensor

put_along_axis(indices, values, axis, /, *, mode='replace', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.put_along_axis.

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

Return type:

Container

rot90(*, copy=None, k=1, axes=(0, 1), key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – Input array of two or more dimensions.

  • k (Union[int, Container], default: 1) – Number of times the array is rotated by 90 degrees.

  • axes (Union[Tuple[int, int], Container], default: (0, 1)) – The array is rotated in the plane defined by the axes. Axes must be different.

  • 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 – Container with a rotated view of input array.

Examples

>>> m = ivy.Container(a=ivy.array([[1,2], [3,4]]),
...                   b=ivy.array([[1,2,3,4],[7,8,9,10]]))
>>> n = m.rot90()
>>> print(n)
{
    a: ivy.array([[2, 4],
                  [1, 3]]),
    b: ivy.array([[4, 10],
                  [3, 9],
                  [2, 8],
                  [1, 7]])
}
soft_thresholding(threshold, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.soft_thresholding.

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

Parameters:
  • x – the input tensor

  • threshold (Union[float, Array, NativeArray, Container]) – float or array with shape tensor.shape * If float the threshold is applied to the whole tensor * If array, one threshold is applied per elements, 0 values are ignored

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ivy.Container – thresholded tensor on which the operator has been applied

static static_as_strided(x, shape, strides, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input container.

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – The shape of the new arrays.

  • strides (Union[Sequence[int], Container]) – The strides of the new arrays (specified in bytes).

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

Container

Returns:

ret – Output container.

static static_atleast_1d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • arys (Union[Array, NativeArray, Container]) – one or more container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 1d. Copies are made only if necessary.

Examples

>>> ary = ivy.Container(a=ivy.array(1), b=ivy.array([3,4,5]),                        c=ivy.array([[3]]))
>>> ivy.Container.static_atleast_1d(ary)
{
    a: ivy.array([1]),
    b: ivy.array([3, 4, 5]),
    c: ivy.array([[3]]),
}
static static_atleast_2d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • arys (Union[Array, NativeArray, Container]) – one or more container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 2D. Copies are made only if necessary.

Examples

>>> ary = ivy.Container(a=ivy.array(1), b=ivy.array([3,4,5]),                        c=ivy.array([[3]]))
>>> ivy.Container.static_atleast_2d(ary)
{
    a: ivy.array([[1]]),
    b: ivy.array([[3, 4, 5]]),
    c: ivy.array([[3]])
}
static static_atleast_3d(*arys, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • arys (Union[Array, NativeArray, Container]) – one or more container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – container or list of container where each elements within container is at least 3D. Copies are made only if necessary. For example, a 1-D array of shape (N,) becomes a view of shape (1, N, 1), and a 2-D array of shape (M, N) becomes a view of shape (M, N, 1).

Examples

>>> ary = ivy.Container(a=ivy.array(1), b=ivy.array([3,4,5]),                        c=ivy.array([[3]]))
>>> ivy.Container.static_atleast_3d(ary)
{
    a: ivy.array([[[1]]]),
    b: ivy.array([[[3],
                   [4],
                   [5]]]),
    c: ivy.array([[[3]]])
}
static static_broadcast_shapes(shapes, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • shapes (Union[Container, List[Tuple[int]]]) – the container with shapes to broadcast.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

Container

Returns:

ret – Container with broadcasted shapes.

Examples

>>> shapes = ivy.Container(a = [(2, 3), (2, 1)],
...                        b = [(2, 3), (1, 3)],
...                        c = [(2, 3), (2, 3)],
...                        d = [(2, 3), (2, 1), (1, 3), (2, 3)])
>>> z = ivy.Container.static_broadcast_shapes(shapes)
>>> print(z)
{
    a: (2, 3),
    b: (2, 3),
    c: (2, 3),
    d: (2, 3)
}
static static_column_stack(xs, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.column_stack.

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

Parameters:
  • xs (Sequence[Union[Container, Array, NativeArray]]) – Container with leaves to stack.

  • 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 array, for writing the result to.

Return type:

Container

Returns:

ret – An output container with the results.

static static_concat_from_sequence(input_sequence, /, *, new_axis=0, axis=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input_sequence (Union[Tuple[Union[Array, NativeArray, Container]], List[Union[Array, NativeArray, Container]]]) – Container with leaves to join. Each array leave must have the same shape.

  • new_axis (Union[int, Container], default: 0) – Insert and concatenate on a new axis or not, default 0 means do not insert new axis. new_axis = 0: concatenate new_axis = 1: stack

  • axis (Union[int, Container], default: 0) – axis along which the array leaves will be concatenated. More details can be found in the docstring for ivy.concat_from_sequence.

  • 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 array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an output container with the results.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> z = ivy.Container.static_concat_from_sequence(x,new_axis = 1, axis = 1)
>>> print(z)
{
    a: ivy.array([[0, 2],
                [1, 3]]),
    b: ivy.array([[4],
                [5]])
}
>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> z = ivy.Container.static_concat_from_sequence([x,y])
>>> print(z)
{
    a: ivy.array([[0, 1],
                  [2, 3],
                  [3, 2],
                  [1, 0]]),
    b: ivy.array([[4, 5],
                  [1, 0]])
}
>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> z = ivy.Container.static_concat_from_sequence([x,y],new_axis=1, axis=1)
>>> print(z)
{
    a: ivy.array([[[0, 1],
                [3, 2]],
                [[2, 3],
                [1, 0]]]),
    b: ivy.array([[[4, 5],
                [1, 0]]])
}
static static_dsplit(ary, indices_or_sections, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • ary (Union[Array, NativeArray, Container]) – the container with array inputs.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. 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.

Return type:

List[Container]

Returns:

ret – list of containers holding arrays split from the input at the 3rd axis

Examples

>>> ary = ivy.Container(
    a = ivy.array(
            [[[0.,  1.],
              [2.,  3.]],
              [[4.,  5.],
              [6.,  7.]]]
        ),
    b=ivy.array(
            [[[ 0.,  1.,  2.,  3.],
              [ 4.,  5.,  6.,  7.],
              [ 8.,  9., 10., 11.],
              [12., 13., 14., 15.]]]
        )
    )
>>> ivy.Container.static_dsplit(ary, 2)
[{
    a: ivy.array([[[0.], [2.]],
                  [[4.], [6.]]]),
    b: ivy.array([[[0., 1.], [4., 5.], [8., 9.], [12., 13.]]])
}, {
    a: ivy.array([[[1.], [3.]],
                  [[5.], [7.]]]),
    b: ivy.array([[[2., 3.], [6., 7.], [10., 11.], [14., 15.]]])
}]
static static_dstack(xs, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

With one ivy.Container input: >>> c = ivy.Container(a=[ivy.array([1,2,3]), ivy.array([0,0,0])],

b=ivy.arange(3))

>>> ivy.Container.static_dstack(c)
{
    a: ivy.array([[1, 0],
                  [2, 0]
                  [3,0]]),
    b: ivy.array([[0, 1, 2])
}
static static_expand(x, shape, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Parameters:
  • x (Union[Array, NativeArray, Container]) – input container.

  • shape (Union[Shape, NativeShape, Container]) – A 1-D Array indicates the shape you want to expand to, following the broadcast rule.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None. device

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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 array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – An output Container with the results.

static static_flatten(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, copy=None, start_dim=0, end_dim=-1, order='C', out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container to flatten at leaves.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • start_dim (Union[int, Container], default: 0) – first dim to flatten. If not set, defaults to 0.

  • end_dim (Union[int, Container], default: -1) – last dim to flatten. If not set, defaults to -1.

  • order (Union[str, Container], default: 'C') – Read the elements of the input container using this index order, and place the elements into the reshaped array using this index order. ‘C’ means to read / write the elements using C-like index order, with the last axis index changing fastest, back to the first axis index changing slowest. ‘F’ means to read / write the elements using Fortran-like index order, with the first index changing fastest, and the last index changing slowest. Note that the ‘C’ and ‘F’ options take no account of the memory layout of the underlying array, and only refer to the order of indexing. Default order is ‘C’

Return type:

Container

Returns:

ret – Container with arrays flattened at leaves.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]),
...                   b=ivy.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]))
>>> ivy.flatten(x)
[{
    a: ivy.array([1, 2, 3, 4, 5, 6, 7, 8])
    b: ivy.array([9, 10, 11, 12, 13, 14, 15, 16])
}]
>>> x = ivy.Container(a=ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]]),
...                   b=ivy.array([[[9, 10], [11, 12]], [[13, 14], [15, 16]]]))
>>> ivy.flatten(x, order="F")
[{
    a: ivy.array([1, 5, 3, 7, 2, 6, 4, 8])
    b: ivy.array([9, 13, 11, 15, 10, 14, 12, 16])
}]
static static_fliplr(m, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • m (Union[Array, NativeArray, Container]) – the container with arrays to be flipped. Arrays must be at least 2-D.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. 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

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays corresponding to the input container’s array with elements order reversed along axis 1.

Examples

With one ivy.Container input: >>> m = ivy.Container(a=ivy.diag([1, 2, 3]), … b=ivy.array([[1, 2, 3],[4, 5, 6]])) >>> ivy.Container.static_fliplr(m) {

a: ivy.array([[0, 0, 1],

[0, 2, 0], [3, 0, 0]]),

b: ivy.array([[3, 2, 1],

[6, 5, 4]])

}

static static_flipud(m, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • m (Union[Array, NativeArray, Container]) – the container with arrays to be flipped.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays corresponding to the input container’s array with elements order reversed along axis 0.

Examples

With one ivy.Container input:

>>> m = ivy.Container(a=ivy.diag([1, 2, 3]), b=ivy.arange(4))
>>> ivy.Container.static_flipud(m)
{
    a: ivy.array(
        [[ 0.,  0.,  3.],
         [ 0.,  2.,  0.],
         [ 1.,  0.,  0.]]
    )
    b: ivy.array([3, 2, 1, 0])
}
static static_fold(x, /, mode, shape, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.fold.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input tensor to be unfolded

  • mode (Union[int, Container]) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • 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 – Container of folded tensors

static static_heaviside(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – input container including the arrays.

  • x2 (Union[Array, NativeArray, Container]) – values to use where the array is zero.

  • out (Optional[Container], default: None) – optional output container array, for writing the result to.

Return type:

Container

Returns:

ret – output container with element-wise Heaviside step function of each array.

Examples

With ivy.Array input: >>> x1 = ivy.Container(a=ivy.array([-1.5, 0, 2.0]), b=ivy.array([3.0, 5.0]) >>> x2 = ivy.Container(a=0.5, b=[1.0, 2.0]) >>> ivy.Container.static_heaviside(x1, x2) {

a: ivy.array([ 0. , 0.5, 1. ]) b: ivy.array([1.0, 1.0])

}

static static_hsplit(ary, indices_or_sections, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • ary (Union[Array, NativeArray, Container]) – the container with array inputs.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

List[Container]

Returns:

ret – list of containers split horizontally from input array.

Examples

>>> ary = ivy.Container(
    a = ivy.array(
            [[[0.,  1.],
              [2.,  3.]],
              [[4.,  5.],
              [6.,  7.]]]
        ),
    b=ivy.array(
            [0.,  1.,  2.,  3.,
             4.,  5.,  6.,  7.,
             8.,  9.,  10., 11.,
             12., 13., 14., 15.]
        )
    )
>>> ivy.Container.static_hsplit(ary, 2)
[{
    a: ivy.array([[[0., 1.]],
                  [[4., 5.]]]),
    b: ivy.array([0., 1., 2., 3., 4., 5., 6., 7.])
}, {
    a: ivy.array([[[2., 3.]],
                  [[6., 7.]]]),
    b: ivy.array([8., 9., 10., 11., 12., 13., 14., 15.])
}]
static static_hstack(xs, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

With one ivy.Container input: >>> c = ivy.Container(a=[ivy.array([1,2,3]), ivy.array([0,0,0])]) >>> ivy.Container.static_hstack(c) {

a: ivy.array([1, 2, 3, 0, 0, 0])

}

static static_i0(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – the container with array inputs.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including arrays with the modified Bessel function evaluated at each of the elements of x.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array(4))
>>> ivy.Container.static_i0(x)
{
    a: ivy.array([1.26606588, 2.2795853 , 4.88079259])
    b: ivy.array(11.30192195)
}
static static_matricize(x, /, row_modes, column_modes=None, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.matricize.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – the input tensor

  • row_modes (Union[Sequence[int], Container]) – modes to use as row of the matrix (in the desired order)

  • column_modes (Optional[Union[Sequence[int], Container]], default: None) – modes to use as column of the matrix, in the desired order if None, the modes not in row_modes will be used in ascending order

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

  • ret

  • ------- – ivy.Container

Return type:

Container

static static_moveaxis(a, source, destination, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Array, NativeArray, Container]) – The container with the arrays whose axes should be reordered.

  • source (Union[int, Sequence[int], Container]) – Original positions of the axes to move. These must be unique.

  • destination (Union[int, Sequence[int], Container]) – Destination positions for each of the original axes. These must also be unique.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Container including arrays with moved axes.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.zeros((3, 4, 5)), b=ivy.zeros((2,7,6))) >>> ivy.Container.static_moveaxis(x, 0, -1).shape {

a: (4, 5, 3) b: (7, 6, 2)

}

static static_pad(input, pad_width, /, *, mode='constant', stat_length=1, constant_values=0, end_values=0, reflect_type='even', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None, **kwargs)[source]#

ivy.Container static method variant of ivy.pad.

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

Return type:

Container

static static_partial_fold(x, /, mode, shape, skip_begin=1, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.partial_fold.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – a partially unfolded tensor

  • mode (Union[int, Container]) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions left untouched at the beginning

  • 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 – partially re-folded tensor

static static_partial_tensor_to_vec(x, /, skip_begin=1, skip_end=0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.partial_tensor_to_vec.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – tensor to partially vectorise

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[Union[int, Container]], default: 0) – number of dimensions to leave untouched at the end

  • 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 – partially vectorised tensor with the skip_begin first and skip_end last dimensions untouched

static static_partial_unfold(x, /, mode=0, skip_begin=1, skip_end=0, ravel_tensors=False, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.partial_unfold.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – tensor of shape n_samples x n_1 x n_2 x … x n_i

  • mode (Optional[Union[int, Container]], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

  • skip_end (Optional[Union[int, Container]], default: 0) – number of dimensions to leave untouched at the end

  • ravel_tensors (Optional[Union[bool, Container]], default: False) – if True, the unfolded tensors are also flattened

  • 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 – partially unfolded tensor

static static_partial_vec_to_tensor(x, /, shape, skip_begin=1, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.partial_vec_to_tensor.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – a partially vectorised tensor

  • shape (Union[Shape, NativeShape, Sequence[int], Container]) – the shape of the original full tensor (including skipped dimensions)

  • skip_begin (Optional[Union[int, Container]], default: 1) – number of dimensions to leave untouched at the beginning

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

full tensor

static static_rot90(m, /, *, copy=None, k=1, axes=(0, 1), key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • m (Union[Container, Array, NativeArray]) – Input array of two or more dimensions.

  • k (Union[int, Container], default: 1) – Number of times the array is rotated by 90 degrees.

  • axes (Union[Tuple[int, int], Container], default: (0, 1)) – The array is rotated in the plane defined by the axes. Axes must be different.

  • 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 – Container with a rotated view of m.

Examples

>>> m = ivy.Container(a=ivy.array([[1,2], [3,4]]),                        b=ivy.array([[1,2,3,4],                                    [7,8,9,10]]))
>>> n = ivy.Container.static_rot90(m)
>>> print(n)
{
    a: ivy.array([[2, 4],
                  [1, 3]]),
    b: ivy.array([[4, 10],
                  [3, 9],
                  [2, 8],
                  [1, 7]])
}
static static_soft_thresholding(x, /, threshold, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.soft_thresholding.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – the input tensor

  • threshold (Union[float, Array, NativeArray, Container]) – float or array with shape tensor.shape * If float the threshold is applied to the whole tensor * If array, one threshold is applied per elements, 0 values are ignored

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ivy.Container – thresholded tensor on which the operator has been applied

static static_take_along_axis(arr, indices, axis, mode='fill', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • arr (Union[Array, NativeArray, Container]) – container with array inputs.

  • indices (Union[Array, NativeArray, Container]) – container with indices of the values to extract.

  • axis (Union[int, Container]) – The axis over which to select values. If axis is None, then arr and indices must be 1-D sequences of the same length.

  • mode (Union[str, Container], default: 'fill') – One of: ‘clip’, ‘fill’, ‘drop’. Parameter controlling how out-of-bounds indices will be handled.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

Container

Returns:

ret – a container with arrays of the same shape as those in indices.

Examples

>>> arr = ivy.Container(a=ivy.array([[1, 2], [3, 4]]),                                b=ivy.array([[5, 6], [7, 8]]))
>>> indices = ivy.Container(a=ivy.array([[0, 0], [1, 1]]),                                    b=ivy.array([[1, 0], [1, 0]]))
>>> ivy.Container.static_take_along_axis(arr, indices, axis=1)
{
    a: ivy.array([[1, 1],
                  [4, 4]]),
    b: ivy.array([[6, 5],
                  [8, 7]])
}
static static_top_k(x, k, /, *, axis=-1, largest=True, sorted=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – The container to compute top_k for.

  • k (Union[int, Container]) – Number of top elements to return must not exceed the array size.

  • axis (Union[int, Container], default: -1) – The axis along which we must return the top elements default value is 1.

  • largest (Union[bool, Container], default: True) – If largest is set to False we return k smallest elements of the array.

  • sorted (Union[bool, Container], default: True) – If sorted is set to True we return the elements in sorted order.

  • 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[Union[Tuple[Container, Container], Container]], default: None) – Optional output tuple, for writing the result to. Must have two Container, with a shape that the returned tuple broadcast to.

Return type:

Tuple[Container, Container]

Returns:

ret – a container with indices and values.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([-1, 2, -4]), b=ivy.array([4., 5., 0.]))
>>> y = ivy.Container.static_top_k(x, 2)
>>> print(y)
{
    a: [
        values = ivy.array([ 2, -1]),
        indices = ivy.array([1, 0])
    ],
    b: [
        values = ivy.array([5., 4.]),
        indices = ivy.array([1, 0])
    ]
}
static static_unfold(x, /, mode=0, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.unfold.

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – input tensor to be unfolded

  • mode (Optional[Union[int, Container]], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • 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 – Container of unfolded tensors

static static_vsplit(ary, indices_or_sections, /, *, copy=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • ary (Union[Array, NativeArray, Container]) – the container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

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

Return type:

List[Container]

Returns:

ret – list of containers holding arrays split vertically from the input

Examples

>>> ary = ivy.Container(
        a = ivy.array(
                [[[0.,  1.],
                  [2.,  3.]],
                  [[4.,  5.],
                  [6.,  7.]]]
            ),
        b=ivy.array(
                [[ 0.,  1.,  2.,  3.],
                 [ 4.,  5.,  6.,  7.],
                 [ 8.,  9., 10., 11.],
                 [12., 13., 14., 15.]]
            )
        )
>>> ivy.Container.static_vsplit(ary, 2)
[{
    a: ivy.array([[[0., 1.],
                   [2., 3.]]]),
    b: ivy.array([[0., 1., 2., 3.],
                  [4., 5., 6., 7.]])
}, {
    a: ivy.array([[[4., 5.],
                   [6., 7.]]]),
    b: ivy.array([[8., 9., 10., 11.],
                  [12., 13., 14., 15.]])
}]
static static_vstack(xs, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

With one ivy.Container input:

>>> c = ivy.Container(a=[ivy.array([1,2,3]), ivy.array([0,0,0])],
                      b=ivy.arange(3))
>>> y = ivy.Container.static_vstack(c)
>>> print(y)
{
    a: ivy.array([[1, 2, 3],
                  [0, 0, 0]]),
    b: ivy.array([[0],
                  [1],
                  [2]])
}
take(indices, /, *, axis=None, mode='fill', fill_value=None, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.take.

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

Parameters:
  • self (Union[int, Array, NativeArray, Container]) – input array

  • indices (Union[int, Array, NativeArray, Container]) – array indices. Must have an integer data type.

  • axis (Optional[Union[int, Container]], default: None) – axis over which to select values. If axis is negative, the function must determine the axis along which to select values by counting from the last dimension. By default, the flattened input array is used.

  • mode (Union[str, Container], default: 'fill') – specifies how out-of-bounds indices will behave. - ‘raise’ – raise an error - ‘wrap’ – wrap around - ‘clip’ – clip to the range (all indices that are too large are replaced by the index that addresses the last element along that axis. Note that this disables indexing with negative numbers.) - ‘fill’ (default) = returns invalid values (e.g. NaN) for out-of bounds indices (see also fill_value below)

  • fill_value (Optional[Union[Number, Container]], default: None) – fill value to return for out-of-bounds slices (Defaults to NaN for inexact types, the largest negative value for signed types, the largest positive value for unsigned types, and True for booleans.)

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

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

Return type:

Container

Returns:

ret

an array having the same data type as x. The output array must have the same rank (i.e., number of dimensions) as x and must have the same shape as x, except for the axis specified by axis whose size must equal the number of elements in indices.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([True,False,False]),
...                     b=ivy.array([2.3,4.5,6.7]),
...                     c=ivy.array([1,2,3]))
>>> indices = ivy.array([[1,9,2]])
>>> y = x.take(indices)
>>> print(y)
{
    a: ivy.array([[False, True, False]]),
    b: ivy.array([[4.5, nan, 6.69999981]]),
    c: ivy.array([[2, -2147483648, 3]])
}
take_along_axis(indices, axis, mode='fill', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Union[Container, Array, NativeArray]) – container with array inputs.

  • indices (Union[Container, Array, NativeArray]) – container with indices of the values to extract.

  • axis (Union[int, Container]) – The axis over which to select values. If axis is None, then arr and indices must be 1-D sequences of the same length.

  • mode (Union[str, Container], default: 'fill') – One of: ‘clip’, ‘fill’, ‘drop’. Parameter controlling how out-of-bounds indices will be handled.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The keychains 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.

Return type:

Container

Returns:

ret – a container with arrays of the same shape as those in indices.

Examples

>>> arr = ivy.Container(a=ivy.array([[1, 2], [3, 4]]),                                b=ivy.array([[5, 6], [7, 8]]))
>>> indices = ivy.Container(a=ivy.array([[0, 0], [1, 1]]),                                    b=ivy.array([[1, 0], [1, 0]]))
>>> arr.take_along_axis(indices, axis=1)
[{
    a: ivy.array([[1, 1],
                  [4, 4]]),
    b: ivy.array([[6, 5],
                    [8, 7]])
}]
top_k(k, /, *, axis=-1, largest=True, sorted=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – The container to compute top_k for.

  • k (Union[int, Container]) – Number of top elements to return must not exceed the array size.

  • axis (Union[int, Container], default: -1) – The axis along which we must return the top elements default value is 1.

  • largest (Union[bool, Container], default: True) – If largest is set to False we return k smallest elements of the array.

  • sorted (Union[bool, Container], default: True) – If sorted is set to True we return the elements in sorted order.

  • 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[Tuple[Container, Container]], default: None) – Optional output tuple, for writing the result to. Must have two Container, with a shape that the returned tuple broadcast to.

Return type:

Tuple[Container, Container]

Returns:

ret – a container with indices and values.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([-1, 2, -4]), b=ivy.array([4., 5., 0.]))
>>> y = x.top_k(2)
>>> print(y)
[{
    a: ivy.array([2, -1]),
    b: ivy.array([5., 4.])
}, {
    a: ivy.array([1, 0]),
    b: ivy.array([1, 0])
}]
trim_zeros(*, trim='fb')[source]#

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

Parameters:
  • self (1-D array) – Input array.

  • trim (str, optional) – A string with ‘f’ representing trim from front and ‘b’ to trim from back. Default is ‘fb’, trim zeros from both front and back of the array.

Return type:

Array

Returns:

1-D array The result of trimming the input. The input data type is preserved.

Examples

>>> a = ivy.array([0, 0, 0, 0, 8, 3, 0, 0, 7, 1, 0])
>>> ivy.trim_zeros(a)
array([8, 3, 0, 0, 7, 1])
>>> ivy.trim_zeros(a, 'b')
array([0, 0, 0, 0, 8, 3, 0, 0, 7, 1])
>>> ivy.trim_zeros([0, 8, 3, 0, 0])
[8, 3]
unflatten(shape, dim=0, *, out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – input array

  • shape (Union[Tuple[int], Array, NativeArray, Container]) – array indices. Must have an integer data type.

  • dim (Optional[Union[int, Container]], default: 0) – axis over which to unflatten. If axis is negative, the function must determine the axis along which to select values by counting from the last dimension. By default, the flattened input array is used.

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

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

Return type:

Container

Returns:

ret

an array having the same data type as x. The output array must have the same rank (i.e., number of dimensions) as x and must have the same shape as x, except for the axis specified by dim which is replaced with a tuple specified in shape.

Examples

With ‘ivy.Container’ input:

>>> x = ivy.Container(a = ivy.array([[True, False, False, True],
...                                 [False, True, False, True]]),
...                     b = ivy.array([[1.2, 2.3, 3.4, 4.5],
...                                   [5.6, 6.7, 7.8, 8.9]]),
...                     c = ivy.array([[1, 2, 3, 4],
...                                   [5, 6, 7, 8]]))
>>> dim = 1
>>> shape = (2, 2)
>>> y = x.unflatten(shape=shape, dim=dim)
>>> print(y)
{
    a: ivy.array([[[True, False], [False, True]],
                  [[False, True], [False, True]]]),
    b: ivy.array([[[1.2, 2.3], [3.4, 4.5]], [[5.6, 6.7], [7.8, 8.9]]]),
    c: ivy.array([[[1, 2], [3, 4]], [[5, 6], [7, 8]]])
}
unfold(mode=0, *, out=None)[source]#

ivy.Container instance method variant of ivy.unfold.

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

Parameters:
  • self (Container) – input tensor to be unfolded

  • mode (Optional[Union[int, Container]], default: 0) – indexing starts at 0, therefore mode is in range(0, tensor.ndim)

  • 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 – Container of unfolded tensors

unique_consecutive(*, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.unique_consecutive.

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

Return type:

Container

vsplit(indices_or_sections, /, *, copy=None)[source]#

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

Parameters:
  • self (Container) – the container with array inputs.

  • copy (Optional[Union[bool, Container]], default: None) – boolean indicating whether or not to copy the input array. If True, the function must always copy. If False, the function must never copy and must raise a ValueError in case a copy would be necessary. If None, the function must reuse existing memory buffer if possible and copy otherwise. Default: None.

  • indices_or_sections (Union[int, Sequence[int], Array, NativeArray, Container]) – If indices_or_sections is an integer n, the array is split into n equal sections, provided that n must be a divisor of the split axis. If indices_or_sections is a sequence of ints or 1-D array, then input is split at each of the indices.

Return type:

List[Container]

Returns:

ret – list of containers holding arrays split vertically from the input

Examples

>>> ary = ivy.Container(
        a = ivy.array(
                [[[0.,  1.],
                  [2.,  3.]],
                  [[4.,  5.],
                  [6.,  7.]]]
            ),
        b=ivy.array(
                [[ 0.,  1.,  2.,  3.],
                 [ 4.,  5.,  6.,  7.],
                 [ 8.,  9., 10., 11.],
                 [12., 13., 14., 15.]]
            )
        )
>>> ary.vsplit(2)
[{
    a: ivy.array([[[0., 1.],
                   [2., 3.]]]),
    b: ivy.array([[0., 1., 2., 3.],
                  [4., 5., 6., 7.]])
}, {
    a: ivy.array([[[4., 5.],
                   [6., 7.]]]),
    b: ivy.array([[8., 9., 10., 11.],
                  [12., 13., 14., 15.]])
}]
vstack(xs, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Return type:

Container

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> x.vstack([y])
{
    a: ivy.array([[[0, 1],
                [2, 3]],
                [[3, 2],
                [1, 0]]]),
    b: ivy.array([[[4, 5]],
                [[1, 0]]])
}
ivy.data_classes.container.experimental.manipulation.concat_from_sequence(self, /, input_sequence, *, new_axis=0, axis=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) –

  • arrays/containers. (Container with leaves to join with leaves of other) –

  • shape. (Each array leave must have the same) –

  • input_sequence (Union[Tuple[Union[Array, NativeArray, Container]], List[Union[Array, NativeArray, Container]]]) –

  • join. (Container with other leaves to) –

  • shape.

  • new_axis (Union[int, Container], default: 0) –

  • not (Insert and concatenate on a new axis or) –

:param : :param default 0 means do not insert new axis.: :param new_axis = 0: :type new_axis = 0: concatenate :param new_axis = 1: :type new_axis = 1: stack :type axis: Union[int, Container], default: 0 :param axis: :param axis along which the array leaves will be concatenated. More details can be found in: :param the docstring for ivy.stack.: :type key_chains: Optional[Union[List[str], Dict[str, str], Container]], default: None :param key_chains: :param The key-chains to apply or not apply the method to. Default is None.: :type to_apply: Union[bool, Container], default: True :param to_apply: :param If True: :param the method will be applied to key_chains: :param otherwise key_chains: :param will be skipped. Default is True.: :type prune_unapplied: Union[bool, Container], default: False :param prune_unapplied: :param Whether to prune key_chains for which the function was not applied.: :param Default is False.: :type map_sequences: Union[bool, Container], default: False :param map_sequences: :param Whether to also map method to sequences (lists: :param tuples).: :param Default is False.: :type out: Optional[Container], default: None :param out: :param optional output array: :param for writing the result to. It must have a shape: :param that the inputs broadcast to.:

Return type:

Container

Returns:

  • ret

  • an output container with the results.

Examples

>>> x = ivy.Container(a=ivy.array([[0, 1], [2,3]]), b=ivy.array([[4, 5]]))
>>> y = ivy.Container(a=ivy.array([[3, 2], [1,0]]), b=ivy.array([[1, 0]]))
>>> z = ivy.Container.static_concat_from_sequence([x,y],axis=1)
>>> print(z)
{
'a': ivy.array([[[0, 1],
                [3, 2]],
                [[2, 3],
                [1, 0]]]),
'b': ivy.array([[[4, 5],
                [1, 0]]])
}
class ivy.data_classes.container.experimental.norms._ContainerWithNormsExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
batch_norm(mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x

    Input array of default shape (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and

    C corresponds to the channel dimension.

  • mean (Union[NativeArray, Array, Container]) – Mean array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).

  • variance (Union[NativeArray, Array, Container]) – Variance array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) – An offset array. If present, will be added to the normalized input. It can be of any shape broadcastable to (N,*S,C).

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) – A scale array. If present, the scale is applied to the normalized input. It can be of any shape broadcastable to (N,*S,C).

  • training (Union[bool, Container], default: False) – If true, calculate and use the mean and variance of x. Otherwise, use the provided mean and variance.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • momentum (Union[float, Container], default: 0.1) –

    the value used for the running_mean and running_var computation.

    Default value is 0.1.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Tuple[Union[Array, Container], Union[Array, Container], Union[Array, Container]]], default: None) – optional output arrays, for writing the result to.

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

Return type:

Tuple[Container, Container, Container]

Returns:

ret

Tuple of containers containing

the normalized input, running mean, and running variance.

group_norm(num_groups=1, /, *, offset=None, scale=None, eps=1e-05, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) – Input array of default shape (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and C corresponds to the channel dimension.

  • num_groups (Union[int, Container], default: 1) – number of groups to separate the channels into

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) – An offset array of size C. If present, will be added to the normalized input.

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) – A scale array of size C. If present, the scale is applied to the normalized input.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Union[Array, Container]], default: None) – optional output arrays, for writing the result to.

Return type:

Container

Returns:

ret – The normalized array.

instance_norm(mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Union[Array, NativeArray, Container]) –

    Input array of shape default (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and

    C corresponds to the channel dimension.

  • mean (Union[NativeArray, Array, Container]) – Mean array of size C used for input’s normalization.

  • variance (Union[NativeArray, Array, Container]) – Variance array of size C used for input’s normalization.

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) – An offset array of size C. If present, will be added to the normalized input.

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) – A scale array of size C. If present, the scale is applied to the normalized input.

  • training (Union[bool, Container], default: False) – If true, calculate and use the mean and variance of x. Otherwise, use the provided mean and variance.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • momentum (Union[float, Container], default: 0.1) –

    the value used for the running_mean and running_var computation.

    Default value is 0.1.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Tuple[Union[Array, Container], Union[Array, Container], Union[Array, Container]]], default: None) – optional output arrays, for writing the result to.

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

Return type:

Tuple[Container, Container, Container]

Returns:

ret

Tuple of containers containing

the normalized input, running mean, and running variance.

l1_normalize(axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

l2_normalize(axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0.5, 1.5, 2.5], [3.5, 4.5, 5.5]]),
...                    b=ivy.array([[-1., -1.], [-1., -0.5]]))
>>> y = x.l2_normalize(axis=1)
>>> print(y)
{
    a: ivy.array([[0.16903085, 0.50709254, 0.84515423],
                  [0.44183609, 0.56807494, 0.69431382]]),
    b: ivy.array([[-0.70710677, -0.70710677],
                  [-0.89442718, -0.44721359]])
}
lp_normalize(p=2, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0.5, 1.5, 2.5], [3.5, 4.5, 5.5]]),
...                    b=ivy.array([[-1., -1.], [-1., -0.5]]))
>>> y = x.lp_normalize(axis=1)
>>> print(y)
{
    a: ivy.array([[0.16903085, 0.50709254, 0.84515423],
                  [0.44183609, 0.56807494, 0.69431382]]),
    b: ivy.array([[-0.70710677, -0.70710677],
                  [-0.89442718, -0.44721359]])
}
static static_batch_norm(x, mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input array of default shape (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and C corresponds to the channel dimension.

  • mean (Union[NativeArray, Array, Container]) – Mean array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).

  • variance (Union[NativeArray, Array, Container]) – Variance array used for input’s normalization. It can be of any shape braodcastable to (N,*S,C).

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) – An offset array. If present, will be added to the normalized input. It can be of any shape broadcastable to (N,*S,C).

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) – A scale array. If present, the scale is applied to the normalized input. It can be of any shape broadcastable to (N,*S,C).

  • training (Union[bool, Container], default: False) – If true, calculate and use the mean and variance of x. Otherwise, use the provided mean and variance.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • momentum (Union[float, Container], default: 0.1) –

    the value used for the running_mean and running_var computation.

    Default value is 0.1.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Tuple[Union[Array, Container], Union[Array, Container], Union[Array, Container]]], default: None) – optional output arrays, for writing the result to.

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

Return type:

Tuple[Container, Container, Container]

Returns:

ret

Tuple of containers containing

the normalized input, running mean, and running variance.

static static_group_norm(x, num_groups=1, /, *, offset=None, scale=None, eps=1e-05, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input array of default shape (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and C corresponds to the channel dimension.

  • num_groups (Union[int, Container], default: 1) – number of groups to separate the channels into

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) – An offset array of size C. If present, will be added to the normalized input.

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) – A scale array of size C. If present, the scale is applied to the normalized input.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Union[Array, Container]], default: None) – optional output arrays, for writing the result to.

Return type:

Container

Returns:

ret – The normalized array.

static static_instance_norm(x, mean, variance, /, *, offset=None, scale=None, training=False, eps=1e-05, momentum=0.1, data_format='NSC', out=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

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

    Input array of shape default (N, *S, C), where N is the batch dimension, *S corresponds to any number of spatial dimensions and

    C corresponds to the channel dimension.

  • mean (Union[NativeArray, Array, Container]) – Mean array of size C used for input’s normalization.

  • variance (Union[NativeArray, Array, Container]) – Variance array of size C used for input’s normalization.

  • offset (Optional[Union[Array, NativeArray, Container]], default: None) –

    An offset array of size C. If present, will be added

    to the normalized input.

  • scale (Optional[Union[Array, NativeArray, Container]], default: None) –

    A scale array of size C. If present, the scale

    is applied to the normalized input.

  • training (Union[bool, Container], default: False) –

    If true, calculate and use the mean and variance of x.

    Otherwise, use the provided mean and variance.

  • eps (Union[float, Container], default: 1e-05) – A small float number to avoid dividing by 0.

  • momentum (Union[float, Container], default: 0.1) –

    the value used for the running_mean and running_var computation.

    Default value is 0.1.

  • data_format (Union[str, Container], default: 'NSC') – The ordering of the dimensions in the input, one of “NSC” or “NCS”, where N is the batch dimension, S represents any number of spatial dimensions and C is the channel dimension. Default is “NSC”.

  • out (Optional[Tuple[Union[Array, Container], Union[Array, Container], Union[Array, Container]]], default: None) – optional output arrays, for writing the result to.

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

Return type:

Tuple[Container, Container, Container]

Returns:

ret

Tuple of containers

containing the normalized input, running mean, and running variance.

static static_l1_normalize(x, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0.5, 1.5, 2.5], [3.5, 4.5, 5.5]])))
...                    b=ivy.array([[-1., -1.], [-1., -0.5]]]))
>>> y = ivy.Container.static_l1_normalize(x, axis=1)
>>> print(y)
{
    a: ivy.array([[0.1, 0.3, 0.5],
                  [0.35, 0.45, 0.55]]),
    b: ivy.array([[-0.5, -0.5],
                  [-0.5, -0.25]])
}
static static_l2_normalize(x, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – The input container with leaves to be normalized.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0.5, 1.5, 2.5], [3.5, 4.5, 5.5]])))
...                    b=ivy.array([[-1., -1.], [-1., -0.5]]]))
>>> y = ivy.Container.static_l2_normalize(x, axis=1)
>>> print(y)
{
    a: ivy.array([[0.16903085, 0.50709254, 0.84515423],
                  [0.44183609, 0.56807494, 0.69431382]]),
    b: ivy.array([[-0.70710677, -0.70710677],
                  [-0.89442718, -0.44721359]])
}
static static_lp_normalize(x, p=2, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – The input container with leaves to be normalized.

  • p (Union[float, Container], default: 2) – The order of the norm.

  • axis (Optional[Union[int, Container]], default: None) – The axis along which to normalize.

  • 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 containing the normalized leaves.

Examples

>>> x = ivy.Container(a=ivy.array([[0.5, 1.5, 2.5], [3.5, 4.5, 5.5]])))
...                    b=ivy.array([[-1., -1.], [-1., -0.5]]]))
>>> y = ivy.Container.static_lp_normalize(x, p=1, axis=1)
>>> print(y)
{
    a: ivy.array([[0.12500000, 0.37500000, 0.62500000],
                  [0.27500000, 0.35000000, 0.42500000]]),
    b: ivy.array([[-1.0000000, -1.0000000],
                  [-0.5000000, -0.2500000]])
}
class ivy.data_classes.container.experimental.random._ContainerWithRandomExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
bernoulli(*, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
Parameters:
  • self (Container) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed in.

  • logits (Optional[Union[float, Array, NativeArray, Container]], default: None) – An N-D Array representing the log-odds of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid(logits). Only one of logits or probs should be passed in.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

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

Return type:

Container

Returns:

ret – Drawn samples from the Bernoulli distribution

beta(beta, /, *, shape=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, device=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • self (Container) – Input container. Should have a numeric data type.

  • alpha – The alpha parameter of the distribution.

  • beta (Union[int, float, Container, Array, NativeArray]) – The beta parameter of the distribution.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – The shape of the output array. Default is 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.

  • device (Optional[Union[str, Container]], default: None) – The device to place the output array on. Default is None.

  • dtype (Optional[Union[str, Container]], default: None) – The data type of the output array. Default is None.

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • 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 object, with values drawn from the beta distribution.

dirichlet(*, size=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • self (Container) – Sequence of floats of length k

  • size (Optional[Union[Shape, NativeShape, Container]], default: None) – optional container including ints or tuple of ints, Output shape for the arrays in the input container.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output container array data type. If dtype is None, the output data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the drawn samples.

Examples

>>> alpha = ivy.Container(a=ivy.array([7,6,5]),                                   b=ivy.array([8,9,4]))
>>> size = ivy.Container(a=3, b=5)
>>> alpha.dirichlet(size)
{
    a: ivy.array(
        [[0.43643127, 0.32325703, 0.24031169],
         [0.34251311, 0.31692529, 0.3405616 ],
         [0.5319725 , 0.22458365, 0.24344385]]
        ),
    b: ivy.array(
        [[0.26588406, 0.61075421, 0.12336174],
         [0.51142915, 0.25041268, 0.23815817],
         [0.64042903, 0.25763214, 0.10193883],
         [0.31624692, 0.46567987, 0.21807321],
         [0.37677699, 0.39914594, 0.22407707]]
        )
}
gamma(beta, /, *, shape=None, device=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • self (Container) – First parameter of the distribution.

  • beta (Union[int, float, Container, Array, NativeArray]) – Second parameter of the distribution.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[str, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[str, Container]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) –

    A python integer. Used to create a random seed distribution out

    Optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Returns:

ret – Drawn samples from the parameterized gamma distribution with the shape of the input Container.

poisson(*, shape=None, device=None, dtype=None, seed=None, fill_value=0, out=None)[source]#

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

Parameters:
  • self (Container) – Input container with rate parameter(s) describing the poisson distribution(s) to sample.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – optional container including ints or tuple of ints, Output shape for the arrays in the input container.

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output container array data type. If dtype is None, the output data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution.

  • fill_value (Optional[Union[float, int, Container]], default: 0) – if lam is negative, fill the output array with this value on that specific dimension.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the drawn samples.

Examples

>>> lam = ivy.Container(a=ivy.array([7,6,5]),                                 b=ivy.array([8,9,4]))
>>> shape = ivy.Container(a=(2,3), b=(1,1,3))
>>> lam.poisson(shape=shape)
{
    a: ivy.array([[5, 4, 6],
                  [12, 4, 5]]),
    b: ivy.array([[[8, 13, 3]]])
}
static static_bernoulli(probs, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, logits=None, shape=None, device=None, dtype=None, seed=None, out=None)[source]#
Parameters:
  • probs (Container) – An N-D Array representing the probability of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution. Only one of logits or probs should be passed in

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

  • logits (Optional[Union[float, Array, NativeArray, Container]], default: None) – An N-D Array representing the log-odds of a 1 event. Each entry in the Array parameterizes an independent Bernoulli distribution where the probability of an event is sigmoid (logits). Only one of logits or probs should be passed in.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – The device to place the output array on. Default is None.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The data type of the output array. Default is None.

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Union[Array, 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 – Drawn samples from the Bernoulli distribution

static static_beta(alpha, beta, /, *, shape=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, device=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • x – Input array or container. Should have a numeric data type.

  • alpha (Container) – The alpha parameter of the distribution.

  • beta (Union[int, float, Container, Array, NativeArray]) – The beta parameter of the distribution.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – The shape of the output array. Default is 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.

  • device (Optional[Union[str, Container]], default: None) – The device to place the output array on. Default is None.

  • dtype (Optional[Union[str, Container]], default: None) – The data type of the output array. Default is None.

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • 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 object, with values drawn from the beta distribution.

static static_dirichlet(alpha, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, size=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • alpha (Container) – Sequence of floats of length k

  • size (Optional[Union[Shape, NativeShape, Container]], default: None) – optional container including ints or tuple of ints, Output shape for the arrays in the input container.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output container array data type. If dtype is None, the output data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the drawn samples.

Examples

>>> alpha = ivy.Container(a=ivy.array([7,6,5]),                                   b=ivy.array([8,9,4]))
>>> size = ivy.Container(a=3, b=5)
>>> ivy.Container.static_dirichlet(alpha, size)
{
    a: ivy.array(
        [[0.43643127, 0.32325703, 0.24031169],
         [0.34251311, 0.31692529, 0.3405616 ],
         [0.5319725 , 0.22458365, 0.24344385]]
        ),
    b: ivy.array(
        [[0.26588406, 0.61075421, 0.12336174],
         [0.51142915, 0.25041268, 0.23815817],
         [0.64042903, 0.25763214, 0.10193883],
         [0.31624692, 0.46567987, 0.21807321],
         [0.37677699, 0.39914594, 0.22407707]]
        )
}
static static_gamma(alpha, beta, /, *, shape=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, device=None, dtype=None, seed=None, out=None)[source]#

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

Parameters:
  • alpha (Container) – First parameter of the distribution.

  • beta (Union[int, float, Container, Array, NativeArray]) – Second parameter of the distribution.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – If the given shape is, e.g ‘(m, n, k)’, then ‘m * n * k’ samples are drawn. (Default value = ‘None’, where ‘ivy.shape(logits)’ samples are drawn)

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

  • device (Optional[Union[str, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[str, Container]], default: None) – output array data type. If dtype is None, the output array data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution

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

Returns:

ret – Drawn samples from the parameterized gamma distribution with the shape of the input Container.

static static_poisson(lam, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, shape=None, device=None, dtype=None, seed=None, fill_value=0, out=None)[source]#

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

Parameters:
  • lam (Container) – Input container with rate parameter(s) describing the poisson distribution(s) to sample.

  • shape (Optional[Union[Shape, NativeShape, Container]], default: None) – optional container including ints or tuple of ints, Output shape for the arrays in the input container.

  • device (Optional[Union[Device, NativeDevice, Container]], default: None) – device on which to create the array ‘cuda:0’, ‘cuda:1’, ‘cpu’ etc. (Default value = None).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – output container array data type. If dtype is None, the output data type will be the default floating-point data type. Default None

  • seed (Optional[Union[int, Container]], default: None) – A python integer. Used to create a random seed distribution.

  • fill_value (Optional[Union[float, int, Container]], default: 0) – if lam is negative, fill the output array with this value on that specific dimension.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container including the drawn samples.

Examples

>>> lam = ivy.Container(a=ivy.array([7,6,5]),                                 b=ivy.array([8,9,4]))
>>> shape = ivy.Container(a=(2,3), b=(1,1,3))
>>> ivy.Container.static_poisson(lam, shape=shape)
{
    a: ivy.array([[5, 4, 6],
                  [12, 4, 5]]),
    b: ivy.array([[[8, 13, 3]]])
}
class ivy.data_classes.container.experimental.searching._ContainerWithSearchingExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static static_unravel_index(indices, shape, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • indices (Container) – Input container including arrays.

  • shape (Union[Tuple[int], Container]) – The shape of the array to use for unraveling indices.

  • out (Optional[Union[Array, Container]], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – Container with tuples that have arrays with the same shape as the arrays in the input container.

Examples

With one ivy.Container input: >>> indices = ivy.Container(a=ivy.array([22, 41, 37])), b=ivy.array([30, 2])) >>> ivy.Container.static_unravel_index(indices, (7,6)) {

a: (ivy.array([3, 6, 6]), ivy.array([4, 5, 1])) b: (ivy.array([5, 0], ivy.array([0, 2])))

}

unravel_index(shape, /, *, out=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • shape (Union[Tuple[int], Container]) – The shape of the array to use for unraveling indices.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – Container with tuples that have arrays with the same shape as the arrays in the input container.

Examples

With one ivy.Container input: >>> indices = ivy.Container(a=ivy.array([22, 41, 37])), b=ivy.array([30, 2])) >>> indices.unravel_index((7, 6)) {

a: (ivy.array([3, 6, 6]), ivy.array([4, 5, 1])) b: (ivy.array([5, 0], ivy.array([0, 2])))

}

class ivy.data_classes.container.experimental.set._ContainerWithSetExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
class ivy.data_classes.container.experimental.sorting._ContainerWithSortingExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
invert_permutation(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.invert_permutation.

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

Return type:

Container

lexsort(*, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input container with array-like inputs to sort as keys.

  • axis (Union[int, Container], default: -1) – axis of each key to be indirectly sorted. By default, sort over the last axis of each key.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – a container containing the sorted input arrays.

Examples

>>> a = ivy.Container(x = ivy.asarray([[9,4,0,4,0,2,1],[1,5,1,4,3,4,4]]),
...                   y = ivy.asarray([[1, 5, 2],[3, 4, 4]])
>>> a.lexsort()
{
    x: ivy.array([2, 0, 4, 6, 5, 3, 1])),
    y: ivy.array([0, 2, 1])
}
static static_invert_permutation(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.invert_permutation.

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

Return type:

Container

static static_lexsort(a, /, *, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Array, NativeArray, Container]) – array-like or container input to sort as keys.

  • axis (Union[int, Container], default: -1) – axis of each key to be indirectly sorted. By default, sort over the last axis of each key.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – a container containing sorted input arrays.

Examples

With ivy.Container input:

>>> a = ivy.Container(x = ivy.asarray([[9,4,0,4,0,2,1],[1,5,1,4,3,4,4]]),
...                   y = ivy.asarray([[1, 5, 2],[3, 4, 4]])
>>> ivy.Container.static_lexsort(a)
{
    x: ivy.array([2, 0, 4, 6, 5, 3, 1])),
    y: ivy.array([0, 2, 1])
}
class ivy.data_classes.container.experimental.statistical._ContainerWithStatisticalExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
static _static_cummax(x, /, *, axis=0, exclusive=False, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input array or container to cummax.

  • axis (Union[int, Container], default: 0) – Axis to cummax along. Default is 0.

  • exclusive (Union[bool, Container], default: False) – Whether to exclude the first element of the input array. Default is False.

  • reverse (Union[bool, Container], default: False) – Whether to perform the cummax from last to first element in the selected axis. Default is False (from first to last element)

  • 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. Default is None.

Return type:

Container

Returns:

  • ret – Containers with arrays cummax at leaves along specified axis.

  • ——–

  • With one ivy.Container input

  • >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))

  • >>> y = ivy.Container.static_cummax(x, axis=0)

  • >>> print(y)

  • { – a: ivy.array([1, 2, 3]), b: ivy.array([4, 5, 6])

  • }

  • >>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]), – b=ivy.array([[3, 4], [4, 5], [5, 6]]))

  • >>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))

  • >>> ivy.Container.static_cummax(x, axis=1, out=y)

  • >>> print(y)

  • {

    a: ivy.array([[2., 3.],

    [5., 7.], [11., 13.]]),

    b: ivy.array([[3., 4.],

    [4., 5.], [5., 6.]])

  • }

static _static_cummin(x, /, *, axis=0, exclusive=False, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • x (Union[Container, Array, NativeArray]) – Input array or container to cummin.

  • axis (Union[int, Container], default: 0) – Axis to cummin along. Default is 0.

  • exclusive (Union[bool, Container], default: False) – Whether to exclude the first element of the input array. Default is False.

  • reverse (Union[bool, Container], default: False) – Whether to perform the cummin from last to first element in the selected axis. Default is False (from first to last element)

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

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – Data type of the returned array. Default is None.

  • out (Optional[Container], default: None) – Optional output container. Default is None.

Return type:

Container

Returns:

  • ret – Containers with arrays cummin at leaves along specified axis.

  • Examples #TODO (fix examples and this doc)

  • ——–

  • With one ivy.Container input

  • >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))

  • >>> y = ivy.Container.static_cummin(x, axis=0)

  • >>> print(y)

  • { – a: ivy.array([1, 1, 1]), b: ivy.array([4, 4, 4])

  • }

  • >>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]), – b=ivy.array([[3, 4], [4, 5], [5, 6]]))

  • >>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))

  • >>> x.static_cummin(axis=1, out=y)

  • {

    a: ivy.array([[2, 2],

    [5, 5], [11, 11]]),

    b: ivy.array([[3, 3],

    [4, 4], [5, 5]])

  • }

static _static_nanmin(x, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, initial=None, where=None, out=None)[source]#

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

Parameters:
  • input – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the minimum is computed. The default is to compute the minimum of the flattened array.

  • out (Optional[Array], default: None) – optional output array, for writing the result to.

  • keepdims (Optional[Union[bool, Container]], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

  • initial (Optional[Union[int, float, complex, Container]], default: None) – The maximum value of an output element

  • where (Optional[Union[Array, Container]], default: None) – Elements to compare for the minimum

Return type:

Container

Returns:

ret – Return minimum of an array or minimum along an axis, ignoring any NaNs.

Examples

>>> a = ivy.Container(x=ivy.array([[1, 2], [3, ivy.nan]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> ivy.Container.static_nanmin(a)
{
    x: 1.
    y: 1.
}
bincount(*, weights=None, minlength=0, out=None)[source]#

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

Parameters:
  • self (Container) – Input array.

  • weights (Optional[Container], default: None) – An optional input array.

  • minlength (Union[int, Container], default: 0) – A minimum number of bins for the output array.

Return type:

Container

Returns:

ret – The bincount of the array elements.

Examples

>>> a = ivy.Container([[10.0, ivy.nan, 4], [3, 2, 1]])
>>> a.bincount(a)
    3.0
>>> a.bincount(a, axis=0)
    array([6.5, 2. , 2.5])
corrcoef(*, y=None, rowvar=True, out=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • y (Optional[Container], default: None) – An additional input container.

  • rowvar (Union[bool, Container], default: True) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

Return type:

Container

Returns:

ret – The corrcoef of the array elements in the input container.

Examples

>>> a = ivy.Container(w=ivy.array([[1., 2.], [3., 4.]]),                                  z=ivy.array([[0., 1., 2.], [2., 1., 0.]]))
>>> ivy.Container.corrcoef(a)
{
    w: ivy.array([[1., 1.],
                  [1., 1.]]),
    z: ivy.array([[1., -1.],
                  [-1., 1.]])
}
cov(x2=None, /, *, rowVar=True, bias=False, ddof=None, fweights=None, aweights=None, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • self (Container) – a 1D or 2D input container, with a numeric data type.

  • x2 (Optional[Container], default: None) – optional second 1D or 2D input array, nativearray, or container, with a numeric data type. Must have the same shape as self.

  • rowVar (Union[bool, Container], default: True) – optional variable where each row of input is interpreted as a variable (default = True). If set to False, each column is instead interpreted as a variable.

  • bias (Union[bool, Container], default: False) – optional variable for normalizing input (default = False) by (N - 1) where N is the number of given observations. If set to True, then normalization is instead by N. Can be overridden by keyword ddof.

  • ddof (Optional[Union[int, Container]], default: None) – optional variable to override bias (default = None). ddof=1 will return the unbiased estimate, even with fweights and aweights given. ddof=0 will return the simple average.

  • fweights (Optional[Union[Array, Container]], default: None) – optional 1D array of integer frequency weights; the number of times each observation vector should be repeated.

  • aweights (Optional[Union[Array, Container]], default: None) – optional 1D array of observation vector weights. These relative weights are typically large for observations considered “important” and smaller for observations considered less “important”. If ddof=0 is specified, the array of weights can be used to assign probabilities to observation vectors.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – optional variable to set data-type of the result. By default, data-type will have at least numpy.float64 precision.

  • 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 output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the covariance matrix of an input matrix, or the covariance matrix of two variables. The returned container must have a floating-point data type determined by Type Promotion Rules and must be a square matrix of shape (N, N), where N is the number of variables in the input(s).

Examples

>>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([1., 2., 3.]))
>>> y = ivy.Container(a=ivy.array([3., 2., 1.]), b=ivy.array([3., 2., 1.]))
>>> z = x.cov(y)
>>> print(z)
{
a: ivy.array([[1., -1.],

[-1., 1.]]),

b: ivy.array([[1., -1.],

[-1., 1.]])

}

cummax(*, axis=0, exclusive=False, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – Input container to cummax at leaves.

  • axis (Union[int, Container], default: 0) – Axis along which the cumulative product is computed. Default is 0.

  • exclusive (Union[bool, Container], default: False) – Whether to exclude the first element of the input array. Default is False.

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

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – Data type of the returned array. Default is None.

  • out (Optional[Container], default: None) – Optional output container. Default is None.

Return type:

Container

Returns:

  • ret – Containers with arrays cummax at leaves along specified axis.

  • ——–

  • With one ivy.Container instances

  • >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))

  • >>> y = x.cummax(axis=0)

  • >>> print(y)

  • [{ – a: ivy.array([1, 2, 3]), b: ivy.array([4, 5, 6])

  • }, { – a: ivy.array([0, 1, 2]), b: ivy.array([0, 1, 2])

  • }]

  • >>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]),

  • … b=ivy.array([[3, 4], [4, 5], [5, 6]]))

  • >>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))

  • >>> x.cummax(axis=1, exclusive=True, out=y)

  • >>> print(y)

  • {

    a: ivy.array([[0., 1.],

    [0., 1.], [0., 1.]]),

    b: ivy.array([[0., 1.],

    [0., 1.], [0., 1.]])

  • }

cummin(*, axis=0, exclusive=False, reverse=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – Input container to cummin at leaves.

  • axis (Union[int, Container], default: 0) – Axis along which the cumulative product is computed. Default is 0.

  • exclusive (Union[bool, Container], default: False) – Whether to exclude the first element of the input array. Default is False.

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

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – Data type of the returned array. Default is None.

  • out (Optional[Container], default: None) – Optional output container. Default is None.

Return type:

Container

Returns:

  • ret – Containers with arrays cummin at leaves along specified axis.

  • Examples #TODO (change examples and change doc string)

  • ——–

  • With one ivy.Container instances

  • >>> x = ivy.Container(a=ivy.array([1, 2, 3]), b=ivy.array([4, 5, 6]))

  • >>> y = x.cummin(axis=0)

  • >>> print(y)

  • { – a: ivy.array([1, 1, 1]), b: ivy.array([4, 4, 4])

  • }

  • >>> x = ivy.Container(a=ivy.array([[2, 3], [5, 7], [11, 13]]), – b=ivy.array([[3, 4], [4, 5], [5, 6]]))

  • >>> y = ivy.Container(a = ivy.zeros((3, 2)), b = ivy.zeros((3, 2)))

  • >>> x.cummin(axis=1, out=y)

  • {

    a: ivy.array([[2, 2],

    [5, 5], [11, 11]]),

    b: ivy.array([[3, 3],

    [4, 4], [5, 5]])

  • }

histogram(*, bins=None, axis=None, extend_lower_interval=False, extend_upper_interval=False, dtype=None, range=None, weights=None, density=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self (Container) – input array.

  • bins (Optional[Union[int, Array, NativeArray, Container, str]], default: None) – if bins is an int, it defines the number of equal-width bins in the given range. if bins is an array, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.

  • axis (Optional[Union[Array, NativeArray, Container]], default: None) – dimension along which maximum values must be computed. By default, the maximum value must be computed over the entire array. Default: None.

  • extend_lower_interval (Optional[Union[bool, Container]], default: False) – if True, extend the lowest interval I0 to (-inf, c1].

  • extend_upper_interval (Optional[Union[bool, Container]], default: False) – ff True, extend the upper interval I_{K-1} to [c_{K-1}, +inf).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – the output type.

  • range (Optional[Union[Tuple[float], Container]], default: None) – the lower and upper range of the bins. The first element of the range must be less than or equal to the second.

  • weights (Optional[Union[Array, NativeArray, Container]], default: None) – each value in a only contributes its associated weight towards the bin count (instead of 1). Must be of the same shape as a.

  • density (Optional[Union[bool, Container]], default: False) – if True, the result is the value of the probability density function at the bin, normalized such that the integral over the range of bins is 1.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

  • ret – a tuple containing the values of the histogram and the bin edges.

  • Both the description and the type hints above assumes an array input for

  • simplicity, but this function is *nestable, and therefore also accepts*

  • ivy.Container instances in place of any of the arguments.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.]))
>>> y = ivy.array([0., 1., 2., 3., 4., 5.])
>>> dtype = ivy.int32
>>> z = x.histogram(bins=y, dtype=dtype)
>>> print(z)
{
    a: ivy.array([1, 1, 1, 0, 0]),
    b: ivy.array([0, 0, 0, 1, 2])
}
igamma(*, x, out=None)[source]#

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

Parameters:
  • self (Container) – Input array.

  • x (Union[Container, Array, NativeArray]) – An additional input array. x has the same type as a.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The lower incomplete gamma function of the array elements.

Examples

>>> a = ivy.array([2.5])
>>> x = ivy.array([1.7, 1.2])
>>> a.igamma(x)
    ivy.array([0.3614, 0.2085])
lgamma(*, out=None)[source]#
Return type:

Container

median(*, axis=None, keepdims=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The median of the array elements.

Examples

With one ivy.Container input: >>> x = ivy.Container( >>> a=ivy.array([[10, 7, 4], [3, 2, 1]]), >>> b=ivy.array([[1, 4, 2], [8, 7, 0]]) >>> ) >>> x.median(axis=0) {

a: ivy.array([6.5, 4.5, 2.5]), b: ivy.array([4.5, 5.5, 1.])

}

nanmean(*, axis=None, keepdims=False, dtype=None, out=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The desired data type of returned tensor. Default is None.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The nanmean of the array elements in the input container.

Examples

>>> a = ivy.Container(x=ivy.array([[1, ivy.nan], [3, 4]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> a.nanmean()
{
    x: 2.6666666666666665
    y: 1.8
}
nanmedian(*, axis=None, keepdims=False, overwrite_input=False, out=None)[source]#

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

Parameters:
  • self (Container) – Input array.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – The axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original container. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

  • overwrite_input (Union[bool, Container], default: False) – If True, then allow use of memory of input array a for calculations. The input array will be modified by the call to median. This will save memory when you do not need to preserve the contents of the input array.Treat the input as undefined, but it will probably be fully or partially sorted. Default is False. If overwrite_input is True and input container does not already have leaves which are of the ndarray kind, an error will be raised.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – A new array holding the result. If the input contains integers

Examples

With ivy.Container input and default backend set as numpy: >>> x = ivy.Container(a=ivy.array([[10.0, ivy.nan, 4], [3, 2, 1]]),

b=ivy.array([[12, 10, 34], [45, 23, ivy.nan]]))

>>> x.nanmedian()
{
    a: ivy.array(3.),
    b: ivy.array(23.)
}
>>> x.nanmedian(axis=0)
{
    a: ivy.array([6.5, 2., 2.5]),
    b: ivy.array([28.5, 16.5, 34.])
}
nanmin(*, axis=None, keepdims=False, out=None, initial=None, where=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the minimum is computed. The default is to compute the minimum of the flattened array.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

  • keepdims (Optional[Union[bool, Container]], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

  • initial (Optional[Union[int, float, complex, Container]], default: None) – The maximum value of an output element.

  • where (Optional[Union[Array, Container]], default: None) – Elements to compare for the minimum.

Return type:

Container

Returns:

ret – Return minimum of an array or minimum along an axis, ignoring any NaNs

Examples

>>> a = ivy.Container(x=ivy.array([[1, 2], [3, ivy.nan]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> a.nanmin()
{
    x: 12.0
    y: 12.0
}
nanprod(*, axis=None, dtype=None, keepdims=False, out=None, initial=None, where=None)[source]#

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

Parameters:
  • self (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the product is computed. The default is to compute the product of the flattened array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The desired data type of returned array. Default is None.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

  • keepdims (Optional[Union[bool, Container]], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

  • initial (Optional[Union[int, float, complex, Container]], default: None) – The starting value for this product.

  • where (Optional[Union[Array, Container]], default: None) – Elements to include in the product

Return type:

Container

Returns:

ret – The product of array elements over a given axis treating Not a Numbers (NaNs) as ones

Examples

>>> a = ivy.Container(x=ivy.array([[1, 2], [3, ivy.nan]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> a.nanprod()
{
    x: 12.0
    y: 12.0
}
quantile(q, /, *, axis=None, keepdims=False, interpolation='linear', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a – Input container including arrays.

  • q (Union[Array, float, Container]) – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – Axis or axes along which the quantiles are computed. The default is to compute the quantile(s) along a flattened version of the array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original array a.

  • interpolation (Union[str, Container], default: 'linear') – {‘nearest’, ‘linear’, ‘lower’, ‘higher’, ‘midpoint’}. Default value: ‘linear’. This specifies the interpolation method to use when the desired quantile lies between two data points i < j: - linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j. - lower: i. - higher: j. - nearest: i or j, whichever is nearest. - midpoint: (i + j) / 2. linear and midpoint interpolation do not work with integer dtypes.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – Container with (rank(q) + N - len(axis)) dimensional arrays of same dtype as input arrays in the container, or, if axis is None, rank(q) arrays. The first rank(q) dimensions index quantiles for different values of q.

Examples

With one ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
...                   b=ivy.array([1., 2., 3., 4.]))
>>> z = ivy.array([0.5])
>>> y = x.quantile(z)
>>> print(y)
{
    a: ivy.array(3.5),
    b: ivy.array(2.5)
}
>>> x = ivy.Container(a=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
...                   b=ivy.array([1., 2., 3., 4.]))
>>> z = ivy.array([0.5, 0.75])
>>> y = x.quantile(z)
>>> print(y)
{
    a: ivy.array([3.5, 6.25]),
    b: ivy.array([2.5, 3.25])
}
>>> x = ivy.Container(a=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
...                   b=ivy.array([1., 2., 3., 4.]))
>>> z = ivy.array([0.5, 0.75])
>>> y = x.quantile(z, axis = 0)
>>> print(y)
{
    a: ivy.array([[6.5, 4.5, 2.5],
                  [8.25, 5.75, 3.25]]),
    b: ivy.array([2.5, 3.25])
}
>>> x = ivy.Container(a=ivy.array([[10., 7., 4.], [3., 2., 1.]]))
>>> z = ivy.array([0.5, 0.75])
>>> y = x.quantile(z, axis = 1, keepdims=True)
>>> print(y)
{
    a: ivy.array([[[7.],
                   [2.]],
                  [[8.5],
                   [2.5]]])
}
>>> x = ivy.Container(a=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
...                   b=ivy.array([1., 2., 3., 4.]))
>>> z = ivy.array([0.3, 0.7])
>>> y = x.quantile(z, axis = 0, interpolation="lower")
>>> print(y)
{
    a: ivy.array([[3., 2., 1.],
                  [3., 2., 1.]]),
    b: ivy.array([1., 3.])
}
static static_bincount(x, /, *, weights=None, minlength=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – Input container including arrays.

  • weights (Optional[Container], default: None) – An optional input container including arrays.

  • minlength (Union[int, Container], default: 0) – A minimum number of bins for the output array.

Return type:

Container

Returns:

ret – The bincount of the array elements.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([1, 1, 2, 2, 2, 3]),

b=ivy.array([1, 1, 2, 2, 2, 3]))

>>> ivy.Container.static_bincount(x)
    {
        a: array([0, 2, 3, 1])
        b: array([0, 2, 3, 1])
    }
static static_corrcoef(x, /, *, y=None, rowvar=True, key_chains=None, to_apply=False, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Container) – Input container including arrays.

  • y (Optional[Container], default: None) – An additional input container.

  • rowvar (Union[bool, Container], default: True) – If rowvar is True (default), then each row represents a variable, with observations in the columns. Otherwise, the relationship is transposed: each column represents a variable, while the rows contain observations.

Return type:

Container

Returns:

ret – The corrcoef of the array elements in the container.

Examples

>>> a = ivy.Container(w=ivy.array([[1., 2.], [3., 4.]]),                                  z=ivy.array([[0., 1., 2.], [2., 1., 0.]]))
>>> ivy.Container.corrcoef(a)
{
    w: ivy.array([[1., 1.],
                  [1., 1.]]),
    z: ivy.array([[1., -1.],
                  [-1., 1.]])
}
static static_cov(x1, x2=None, /, *, rowVar=True, bias=False, ddof=None, fweights=None, aweights=None, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

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

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – a 1D or 2D input array, nativearray or container, with a numeric data type.

  • x2 (Optional[Union[Array, NativeArray, Container]], default: None) – optional second 1D or 2D input array, nativearray, or container, with a numeric data type. Must have the same shape as x1.

  • rowVar (Union[bool, Container], default: True) – optional variable where each row of input is interpreted as a variable (default = True). If set to False, each column is instead interpreted as a variable.

  • bias (Union[bool, Container], default: False) – optional variable for normalizing input (default = False) by (N - 1) where N is the number of given observations. If set to True, then normalization is instead by N. Can be overridden by keyword ddof.

  • ddof (Optional[Union[int, Container]], default: None) – optional variable to override bias (default = None). ddof=1 will return the unbiased estimate, even with fweights and aweights given. ddof=0 will return the simple average.

  • fweights (Optional[Union[Array, Container]], default: None) – optional 1D array of integer frequency weights; the number of times each observation vector should be repeated.

  • aweights (Optional[Union[Array, Container]], default: None) – optional 1D array of observation vector weights. These relative weights are typically large for observations considered “important” and smaller for observations considered less “important”. If ddof=0 is specified, the array of weights can be used to assign probabilities to observation vectors.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – optional variable to set data-type of the result. By default, data-type will have at least numpy.float64 precision.

  • 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 output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the covariance matrix of an input matrix, or the covariance matrix of two variables. The returned container must have a floating-point data type determined by Type Promotion Rules and must be a square matrix of shape (N, N), where N is the number of rows in the input(s).

Examples

With one ivy.Container input: >>> x = ivy.array([1., 2., 3.]) >>> y = ivy.Container(a=ivy.array([3. ,2. ,1.]), b=ivy.array([-1., -2., -3.])) >>> z = ivy.Container.static_cov(x, y) >>> print(z) {

a: ivy.array([ 1., -1.]

[-1., 1.]),

b: ivy.array([ 1., -1.]

[-1., 1.])

}

With multiple ivy.Container inputs: >>> x = ivy.Container(a=ivy.array([1., 2., 3.]), b=ivy.array([1., 2., 3.])) >>> y = ivy.Container(a=ivy.array([3., 2., 1.]), b=ivy.array([3., 2., 1.])) >>> z = ivy.Container.static_cov(x, y) >>> print(z) {

a: ivy.container([ 1., -1., -1., -1.]

[ 1., 1., -1., -1.]),

b: ivy.container([-1., -1., 1., 1.]

[-1., 1., 1., 1.])

}

static static_histogram(a, /, *, bins=None, axis=None, extend_lower_interval=False, extend_upper_interval=False, dtype=None, range=None, weights=None, density=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.<func_name>. This method simply wraps the function, and so the docstring for ivy.histogram also applies to this method with minimal changes.

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

  • bins (Optional[Union[int, Array, NativeArray, Container, str]], default: None) – if bins is an int, it defines the number of equal-width bins in the given range. if bins is an array, it defines a monotonically increasing array of bin edges, including the rightmost edge, allowing for non-uniform bin widths.

  • axis (Optional[Union[Array, NativeArray, Container]], default: None) – dimension along which maximum values must be computed. By default, the maximum value must be computed over the entire array. Default: None.

  • extend_lower_interval (Optional[Union[bool, Container]], default: False) – if True, extend the lowest interval I0 to (-inf, c1].

  • extend_upper_interval (Optional[Union[bool, Container]], default: False) – ff True, extend the upper interval I_{K-1} to [c_{K-1}, +inf).

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – the output type.

  • range (Optional[Tuple[Union[bool, Container]]], default: None) – the lower and upper range of the bins. The first element of the range must be less than or equal to the second.

  • weights (Optional[Union[Array, NativeArray, Container]], default: None) – each value in a only contributes its associated weight towards the bin count (instead of 1). Must be of the same shape as a.

  • density (Optional[Union[bool, Container]], default: False) – if True, the result is the value of the probability density function at the bin, normalized such that the integral over the range of bins is 1.

  • 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, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

  • ret – a tuple containing the values of the histogram and the bin edges.

  • Both the description and the type hints above assumes an array input for

  • simplicity, but this function is *nestable, and therefore also accepts*

  • ivy.Container instances in place of any of the arguments.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([0., 1., 2.]), b=ivy.array([3., 4., 5.]))
>>> y = ivy.array([0., 1., 2., 3., 4., 5.])
>>> dtype = ivy.int32
>>> z = ivy.Container.static_histogram(x, bins=y, dtype=dtype)
>>> print(z.a)
>>> print(z.b)
(ivy.array([1, 1, 1, 0, 0]), ivy.array([0., 1., 2., 3., 4., 5.]))
(ivy.array([0, 0, 0, 1, 2]), ivy.array([0., 1., 2., 3., 4., 5.]))
static static_igamma(a, /, *, x, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • self – Input array.

  • x (Union[Container, Array, NativeArray]) – An additional input array. x has the same type as a.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The lower incomplete gamma function of the array elements.

Examples

>>> a = ivy.array([2.5])
>>> x = ivy.array([1.7, 1.2])
>>> a.igamma(x)
    ivy.array([0.3614, 0.2085])
static static_lgamma(a, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static static_median(input, /, *, axis=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

  • out (Optional[Union[Array, Container]], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The median of the array elements.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.zeros((3, 4, 5)), b=ivy.zeros((2,7,6))) >>> ivy.Container.static_moveaxis(x, 0, -1).shape {

a: (4, 5, 3) b: (7, 6, 2)

}

static static_nanmean(input, /, *, axis=None, keepdims=False, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the means are computed. The default is to compute the mean of the flattened array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a. If the value is anything but the default, then keepdims will be passed through to the mean or sum methods of sub-classes of ndarray. If the sub-classes methods does not implement keepdims any exceptions will be raised.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The desired data type of returned tensor. Default is None.

  • out (Optional[Union[Array, Container]], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The nanmean of the array elements in the container.

Examples

>>> a = ivy.Container(x=ivy.array([[1, ivy.nan], [3, 4]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> ivy.Container.static_moveaxis(a)
{
    x: 2.6666666666666665
    y: 1.8
}
static static_nanmedian(input, /, *, axis=None, keepdims=False, overwrite_input=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • input (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the medians are computed. The default is to compute the median along a flattened version of the array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one.

  • overwrite_input (Union[bool, Container], default: False) – If True, then allow use of memory of input array for calculations.

  • out (Optional[Union[Array, Container]], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – The median of the array elements.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([[10.0, ivy.nan, 4], [3, 2, 1]])) >>> ivy.Container.static_nanmedian(x) {

a: ivy.array(3.)

}

static static_nanprod(input, /, *, axis=None, dtype=None, keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None, initial=1, where=None)[source]#

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

Parameters:
  • input (Container) – Input container including arrays.

  • axis (Optional[Union[int, Tuple[int], Container]], default: None) – Axis or axes along which the product is computed. The default is to compute the product of the flattened array.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – The desired data type of returned array. Default is None.

  • out (Optional[Union[Array, Container]], default: None) – optional output array, for writing the result to.

  • keepdims (Optional[Union[bool, Container]], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original a.

  • initial (Optional[Union[int, float, complex, Container]], default: 1) – The starting value for this product.

  • where (Optional[Union[Array, Container]], default: None) – Elements to include in the product

Return type:

Container

Returns:

ret – The product of array elements over a given axis treating Not a Numbers (NaNs) as ones

Examples

>>> a = ivy.Container(x=ivy.array([[1, 2], [3, ivy.nan]]),                                y=ivy.array([[ivy.nan, 1, 2], [1, 2, 3]])
>>> ivy.Container.static_nanprod(a)
{
    x: 12.0
    y: 12.0
}
static static_quantile(a, q, /, *, axis=None, keepdims=False, interpolation='linear', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • a (Union[Container, Array, NativeArray]) – Input container including arrays.

  • q (Union[Array, float, Container]) – Quantile or sequence of quantiles to compute, which must be between 0 and 1 inclusive.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – Axis or axes along which the quantiles are computed. The default is to compute the quantile(s) along a flattened version of the array.

  • keepdims (Union[bool, Container], default: False) – If this is set to True, the axes which are reduced are left in the result as dimensions with size one. With this option, the result will broadcast correctly against the original array a.

  • interpolation (Union[str, Container], default: 'linear') – {‘nearest’, ‘linear’, ‘lower’, ‘higher’, ‘midpoint’}. Default value: ‘linear’. This specifies the interpolation method to use when the desired quantile lies between two data points i < j: - linear: i + (j - i) * fraction, where fraction is the fractional part of the index surrounded by i and j. - lower: i. - higher: j. - nearest: i or j, whichever is nearest. - midpoint: (i + j) / 2. linear and midpoint interpolation do not work with integer dtypes.

  • out (Optional[Container], default: None) – optional output array, for writing the result to.

Return type:

Container

Returns:

ret – Container with (rank(q) + N - len(axis)) dimensional arrays of same dtype as input arrays in the container, or, if axis is None, rank(q) arrays. The first rank(q) dimensions index quantiles for different values of q.

Examples

With one ivy.Container input:

>>> a = ivy.Container(x=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
                      y=ivy.array([1., 2., 3., 4.]))
>>> q = 0.5
>>> b = ivy.Container.static_quantile(a, q)
>>> print(b)
{
    x: 3.5,
    y: 2.5
}
>>> a = ivy.Container(x=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
                      y=ivy.array([1., 2., 3., 4.]))
>>> q = ivy.array([0.5, 0.75])
>>> b = ivy.Container.static_quantile(a, q)
>>> print(b)
{
    x: ivy.array([3.5, 6.25]),
    y: ivy.array([2.5, 3.25])
}
>>> a = ivy.Container(x=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
                      y=ivy.array([1., 2., 3., 4.]))
>>> q = ivy.array([0.5, 0.75])
>>> b = ivy.Container.static_quantile(a, q, axis = 0)
>>> print(b)
{
    x: ivy.array([[6.5, 4.5, 2.5],
                [8.25, 5.75, 3.25]]),
    y: ivy.array([2.5, 3.25])
}
>>> a = ivy.Container(x=ivy.array([[10., 7., 4.], [3., 2., 1.]]))
>>> b = ivy.Container.static_quantile(a, q, axis = 1, keepdims=True)
>>> print(b)
{
    x: ivy.array([[[7.],
            [2.]],
            [[8.5],
            [2.5]]])
}
>>> a = ivy.Container(x=ivy.array([[10., 7., 4.], [3., 2., 1.]]),
                      y=ivy.array([1., 2., 3., 4.]))
>>> q = ivy.array([0.3, 0.7])
>>> b = ivy.Container.static_quantile(a, q, axis = 0, interpolation="lower")
>>> print(b)
{
    x: ivy.array([[3., 2., 1.],
                [3., 2., 1.]]),
    y: ivy.array([1., 3.])
}
class ivy.data_classes.container.experimental.utility._ContainerWithUtilityExperimental(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#
_abc_impl = <_abc._abc_data object>#
optional_get_element(*, out=None)[source]#

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

Parameters:
  • self (Container) – Input container

  • out (Optional[Container], default: None) – Optional output container, for writing the result to.

Return type:

Container

Returns:

ret – Output container.

static static_optional_get_element(x=None, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

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

Parameters:
  • x (Optional[Union[Array, Container]], default: None) – container with array inputs.

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

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

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

  • map_sequences (bool, 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.

Return type:

Container

Returns:

ret – Container with arrays flattened at leaves.