pytorch / 2 / generated / torch.nn.tanhshrink.html

Tanhshrink

class torch.nn.Tanhshrink(*args, **kwargs) [source]

Applies the element-wise function:

Tanhshrink ( x ) = x tanh ( x ) \text{Tanhshrink}(x) = x - \tanh(x)
Shape:
  • Input: ( ) (*) , where * means any number of dimensions.
  • Output: ( ) (*) , same shape as the input.
../_images/Tanhshrink.png

Examples:

>>> m = nn.Tanhshrink()
>>> input = torch.randn(2)
>>> output = m(input)

© 2024, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://pytorch.org/docs/2.1/generated/torch.nn.Tanhshrink.html