# scaled_tanh#

ivy.scaled_tanh(x, /, *, alpha=1.7159, beta=0.67, out=None)[source]#

Compute the scaled hyperbolic tangent (tanh) activation.

The scaled tanh activation function is defined as: out = alpha * tanh(beta * x)

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

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

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

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

Return type:

`Array`

Returns:

ret – The input array after applying the scaled tanh activation.

Examples

With `ivy.Array` input:

```>>> x = ivy.array([22.])
>>> y = ivy.scaled_tanh(x)
>>> y
ivy.array([1.71589994]))
```
```>>> x = ivy.array([4.0, 7.0])
>>> y = ivy.scaled_tanh(x, alpha=1.2, beta=5)
>>> y
ivy.array([1.20000005, 1.20000005])
```

With `ivy.Container` input:

```>>> x = ivy.Container(a=ivy.array([1.2, -1.2]), b=ivy.array([4.4, -2.2]))
>>> y = ivy.scaled_tanh(x)
>>> y
{
a: ivy.array([1.14324772, -1.14324772]),
b: ivy.array([1.70648694, -1.54488957])
}
>>> x = ivy.Container(a=ivy.array([1.2]), b=ivy.array([4.4]))
>>> y = ivy.scaled_tanh(x, alpha=0.2, beta=0.5)
>>> y
{
a: ivy.array([0.10740992]),
b: ivy.array([0.19514863])
}
```
Array.scaled_tanh(self, /, *, alpha=1.7159, beta=0.67, out=None)[source]#

ivy.Array instance 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:
• self (`Array`) – input array.

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

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

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

Return type:

`Array`

Returns:

ret – an array after applying the scaled_tanh activation.

Examples

```>>> x = ivy.array([-3., 2., 3.])
>>> x.scaled_tanh()
ivy.array([-1.65537548,  1.49570239,  1.65537548])
```
```>>> x = ivy.array([2., 2., 2.])
>>> x.scaled_tanh(alpha=9, beta=0.1)
ivy.array([1.77637792, 1.77637792, 1.77637792])
```
```>>> x = ivy.array([2., 2., 2.])
>>> x.scaled_tanh(alpha=0.1, beta=9)
ivy.array([0.1, 0.1, 0.1])
```
Container.scaled_tanh(self, /, *, 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])
}
```