Skip to content
masterclass Buddy

PyTorch · Class

nn.Tanh

torch.nn.Tanh applies the hyperbolic tangent to each tensor element. It returns a tensor with the same shape as the input.

Last updated

Syntax

torch.nn.Tanh(*args, **kwargs)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • torch.nn.modules.activation.Tanh
  • forward

Source: Tanh — PyTorch 2.14 documentation. Checked 2026-11-03.