API

 torch / nn / torch.nn


Tanhshrink

class torch.nn.Tanhshrink[source]

Applies the element-wise function:

Tanhshrink(x)=xtanh(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)

此页内容是否对您有帮助