torch.tanh¶ torch.tanh(input, *, out=None) → 张量¶ 返回一个新的张量,其中包含input元素的双曲正切值。 outi=tanh(inputi)\text{out}_{i} = \tanh(\text{input}_{i}) outi=tanh(inputi) Parameters 输入 (张量) – 输入张量。 Keyword Arguments 输出 (张量, 可选) – 输出张量。 示例: >>> a = torch.randn(4) >>> a 张量([ 0.8986, -0.7279, 1.1745, 0.2611]) >>> torch.tanh(a) 张量([ 0.7156, -0.6218, 0.8257, 0.2553])