Activations#
- class ivy.data_classes.container.activations._ContainerWithActivations(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]#
Bases:
ContainerBase
- _abc_impl = <_abc._abc_data object>#
- static _static_gelu(x, /, *, approximate=False, 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.gelu. This method simply wraps the function, and so the docstring for ivy.gelu also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – input container.approximate (
Union
[bool
,Container
], default:False
) – whether to use the gelu approximation algorithm or exact 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 gelu unit function applied element-wise.
Examples
>>> x = ivy.Container(a =ivy.array([0.3, -0.1])) >>> y = ivy.Container.static_gelu(x) >>> print(y) { a: ivy.array([0.185, -0.046]) }
- static _static_hardswish(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.hardswish. This method simply wraps the function, and so the docstring for ivy.hardswish 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 hardswish activation function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-3., 4., 5.]), b=ivy.array([0., 5.])) >>> x = ivy.hardswish(x, out=x) >>> x { a: ivy.array([-0., 4., 5.]), b: ivy.array([0., 5.]) }
- static _static_leaky_relu(x, /, *, alpha=0.2, 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.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:
x (
Union
[Array
,NativeArray
,Container
]) – input container.alpha (
Container
, default:0.2
) – array or scalar specifying the negative slope.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 leaky relu 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_leaky_relu(x) >>> print(y) { a: ivy.array([0.38999999, -0.17]), b: ivy.array([1., -0.04]) }
- static _static_log_softmax(x, /, *, axis=-1, complex_mode='jax', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container static method variant of ivy.log_softmax. This method simply wraps the function, and so the docstring for ivy.log_softmax also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – input container.axis (
Optional
[Container
], default:-1
) – the axis or axes along which the log_softmax should be computedcomplex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.func_wrapper.handle_complex_input
for more detail.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.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 log_softmax unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-1.0, -0.98, 2.3])) >>> y = ivy.Container.static_log_softmax(x) >>> print(y) { a: ivy.array([-3.37, -3.35, -0.0719]) }
>>> x = ivy.Container(a=ivy.array([1.0, 2.4]), b=ivy.array([-0.2, -1.0])) >>> y = ivy.Container.static_log_softmax(x) >>> print(y) { a: ivy.array([-1.62, -0.22]), b: ivy.array([-0.371, -1.17]) }
- static _static_mish(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.mish. This method simply wraps the function, and so the docstring for ivy.mish 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 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_mish(x) >>> print(y) { a: ivy.array([0.86509842, -0.30883577]), b: ivy.array([0.28903052, -0.10714479]) }
- static _static_relu(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.relu. This method simply wraps the function, and so the docstring for ivy.relu 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 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_relu(x) >>> print(y) { a: ivy.array([1., 0.]), b: ivy.array([0.40000001, 0.]) }
- static _static_sigmoid(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.sigmoid. This method simply wraps the function, and so the docstring for ivy.sigmoid 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 sigmoid unit function applied element-wise.
Examples
>>> ivy.Container(a=ivy.array([-1., 1., 2.]), b=ivy.array([0.5, 0., -0.1])) >>> y = ivy.Container.static_sigmoid(x) >>> print(y) { a: ivy.array([0.2689414, 0.7310586, 0.88079703]), b: ivy.array([0.62245935, 0.5, 0.4750208]) }
- static _static_softmax(x, /, *, axis=None, 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.softmax. This method simply wraps the function, and so the docstring for ivy.softmax also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – input container.axis (
Optional
[Container
], default:None
) – the axis or axes along which the softmax should be computedkey_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 softmax unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([1.0, 0]), b=ivy.array([1.3, 0, -1.0])) >>> y = ivy.Container.static_softmax(x) >>> print(y) { a: ivy.array([0.7310586, 0.2689414]), b: ivy.array([0.72844321, 0.19852395, 0.07303288]) }
- static _static_softplus(x, /, *, beta=None, threshold=None, 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.softplus. This method simply wraps the function, and so the docstring for ivy.softplus also applies to this method with minimal changes.
- Parameters:
x (
Union
[Array
,NativeArray
,Container
]) – input container.beta (
Optional
[Union
[int
,float
,Container
]], default:None
) – The beta value for the softplus formation. Default:None
.threshold (
Optional
[Union
[int
,float
,Container
]], default:None
) – values above this revert to a linear function. Default:None
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.func_wrapper.handle_complex_input
for more detail.out (
Optional
[Container
], default:None
) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container with the softplus unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-0.3461, -0.6491]), b=ivy.array([1., 0.])) >>> y = ivy.Container.static_softplus(x) >>> print(y) { a: ivy.array([0.53499615, 0.42036411]), b: ivy.array([1.31326175, 0.69314718]) }
>>> x = ivy.Container(a=ivy.array([-1., 2., 4.])) >>> y = ivy.Container.static_softplus(x, beta=0.5, threshold=2) >>> print(y) { a: ivy.array([0.948, 2.63, 4.25]) }
- gelu(*, approximate=False, 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.gelu. This method simply wraps the function, and so the docstring for ivy.gelu also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container.approximate (
Union
[bool
,Container
], default:False
) – whether to use the gelu approximation algorithm or exact 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 gelu unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([1., 2.]), b=ivy.array([-0.9, -1.])) >>> y = x.gelu() print(y) { a: ivy.array([0.841, 1.95]), b: ivy.array([-0.166, -0.159]) }
- hardswish(*, 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.hardswish. This method simply wraps the function, and so the docstring for ivy.hardswish 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 hardswish activation function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-3., 4., 5.]), b=ivy.array([0., 5.])) >>> x = ivy.hardswish(x, out=x) >>> x { a: ivy.array([-0., 4., 5.]), b: ivy.array([0., 5.]) }
- leaky_relu(*, alpha=0.2, 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:0.2
) – array or scalar specifying the negative slope.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 leaky relu unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([0.39, -0.85]), b=ivy.array([1., -0.2])) >>> y = x.leaky_relu() >>> print(y) { a: ivy.array([0.38999999, -0.17]), b: ivy.array([1., -0.04]) }
- log_softmax(*, axis=-1, complex_mode='jax', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.log_softmax. This method simply wraps the function, and so the docstring for ivy.log_softmax also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container.axis (
Optional
[Container
], default:-1
) – the axis or axes along which the log_softmax should be computedcomplex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.func_wrapper.handle_complex_input
for more detail.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.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 – a container with the log_softmax unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-1.0, -0.98, 2.3])) >>> y = x.log_softmax() >>> print(y) { a: ivy.array([-3.37, -3.35, -0.0719]) }
>>> x = ivy.Container(a=ivy.array([1.0, 2.4]), b=ivy.array([-0.2, -1.0])) >>> y = x.log_softmax() >>> print(y) { a: ivy.array([-1.62, -0.22]), b: ivy.array([-0.371, -1.17]) }
- mish(*, 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.mish. This method simply wraps the function, and so the docstring for ivy.mish 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 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.mish() >>> print(y) { a: ivy.array([0.86509842, -0.30883577]), b: ivy.array([0.28903052, -0.10714479]) }
- relu(*, 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.relu. This method simply wraps the function, and so the docstring for ivy.relu 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 isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 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.relu() >>> print(y) { a: ivy.array([1., 0.]), b: ivy.array([0.40000001, 0.]) }
- sigmoid(*, 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.sigmoid. This method simply wraps the function, and so the docstring for ivy.sigmoid also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 sigmoid unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-1., 1., 2.]), b=ivy.array([0.5, 0., -0.1])) >>> y = x.sigmoid() >>> print(y) { a: ivy.array([0.2689414, 0.7310586, 0.88079703]), b: ivy.array([0.62245935, 0.5, 0.4750208]) }
- softmax(*, axis=None, key_chains=None, to_apply=True, prune_unapplied=False, complex_mode='jax', map_sequences=False, out=None)[source]#
ivy.Container instance method variant of ivy.softmax. This method simply wraps the function, and so the docstring for ivy.softmax also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container.axis (
Optional
[Container
], default:None
) – the axis or axes along which the softmax should be computedkey_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.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 softmax unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([1.0, 0]), b=ivy.array([1.3, 0, -1.0])) >>> y = x.softmax() >>> print(y) { a: ivy.array([0.7310586, 0.2689414]), b: ivy.array([0.72844321, 0.19852395, 0.07303288]) }
- softplus(*, beta=None, threshold=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, complex_mode='jax', out=None)[source]#
ivy.Container instance method variant of ivy.softplus. This method simply wraps the function, and so the docstring for ivy.softplus also applies to this method with minimal changes.
- Parameters:
self (
Container
) – input container.beta (
Optional
[Union
[int
,float
,Container
]], default:None
) – The beta value for the softplus formation. Default:None
.threshold (
Optional
[Union
[int
,float
,Container
]], default:None
) – values above this revert to a linear function. Default:None
.key_chains (
Optional
[Union
[List
[str
],Dict
[str
,str
],Container
]], default:None
) – The key-chains to apply or not apply the method to. Default isNone
.to_apply (
Union
[bool
,Container
], default:True
) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default isTrue
.prune_unapplied (
Union
[bool
,Container
], default:False
) – Whether to prune key_chains for which the function was not applied. Default isFalse
.map_sequences (
Union
[bool
,Container
], default:False
) – Whether to also map method to sequences (lists, tuples). Default isFalse
.complex_mode (
Literal
['split'
,'magnitude'
,'jax'
], default:'jax'
) – optional specifier for how to handle complex data types. Seeivy.func_wrapper.handle_complex_input
for more detail.out (
Optional
[Container
], default:None
) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container with the softplus unit function applied element-wise.
Examples
>>> x = ivy.Container(a=ivy.array([-0.3461, -0.6491])) >>> y = x.softplus() >>> print(y) { a: ivy.array([0.535, 0.42]) }
>>> x = ivy.Container(a=ivy.array([-1., 2., 4.])) >>> y = x.softplus(beta=0.5, threshold=2) >>> print(y) { a: ivy.array([0.948, 2.63, 4.25]) }
This should have hopefully given you an overview of the activations submodule, if you have any questions, please feel free to reach out on our discord!