relu6#
- ivy.relu6(x, /, *, out=None)[source]#
Apply the rectified linear unit 6 function element-wise.
- Parameters:
- Return type:
- Returns:
ret – an array containing the rectified linear unit 6 activation of each element in
x
.
Examples
With
ivy.Array
input:>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.relu6(x) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.zeros(9) >>> ivy.relu6(x, out = y) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
With
ivy.Container
input:>>> x = { a: ivy.array([-3., -2., -1., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) } >>> x = ivy.relu6(x, out=x) >>> print(x) { a: ivy.array([0., 0., 0., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 6., 6., 6.]) }
- Array.relu6(self, /, *, out=None)#
Apply the rectified linear unit 6 function element-wise.
- Parameters:
self – input array
out (
Optional
[Array
]) – optional output array, for writing the result to. (default:None
) It must have a shape that the inputs broadcast to.
- Return type:
Array
- Returns:
ret – an array containing the rectified linear unit 6 activation of each element in input.
Examples
With
ivy.Array
input:>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.relu6(x) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
>>> x = ivy.array([-1., 0., 1., 2., 3., 4., 5., 6., 7.]) >>> y = ivy.zeros(9) >>> ivy.relu6(x, out = y) >>> print(y) ivy.array([0., 0., 1., 2., 3., 4., 5., 6., 6.])
With
ivy.Container
input:>>> x = { a: ivy.array([-3., -2., -1., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 7., 8., 9.]) } >>> x = ivy.relu6(x, out=x) >>> print(x) { a: ivy.array([0., 0., 0., 0., 1., 2., 3., 4., 5.]), b: ivy.array([1., 2., 3., 4., 5., 6., 6., 6., 6.]) }
- Container.relu6(self, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)#
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
]]]) – The key-chains to apply or not apply the method to. Default isNone
. (default:None
)to_apply (
bool
) – If True, the method will be applied to key_chains, otherwise key_chains (default:True
) will be skipped. Default isTrue
.prune_unapplied (
bool
) – Whether to prune key_chains for which the function was not applied. (default:False
) Default isFalse
.map_sequences (
bool
) – Whether to also map method to sequences (lists, tuples). (default:False
) Default isFalse
.out (
Optional
[Container
]) – optional output container, for writing the result to. It must have a shape (default:None
) that the inputs broadcast to.
- Return type:
Container
- Returns:
ret – a container with the rectified linear 6 activation unit function applied element-wise.
Examples
>>> x = { 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., 6., 6., 6.]) }