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

Tanhshrink

class torch.nn.Tanhshrink [source]

Applies the element-wise function:

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

Examples:

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

© 2019 Torch Contributors
Licensed under the 3-clause BSD License.
https://pytorch.org/docs/1.8.0/generated/torch.nn.Tanhshrink.html