PyTorch torch.arctanh 函数
torch.arctanh 是 PyTorch 中用于计算逐元素反双曲正切(inverse hyperbolic tangent)的函数,与 torch.atanh 功能相同。
函数定义
torch.arctanh(input, out=None)
使用示例
实例
import torch
# 创建张量(值必须在-1到1之间)
x = torch.tensor([-0.5, -0.25, 0.0, 0.25, 0.5])
# 计算反双曲正切
result = torch.arctanh(x)
print(result)
# 创建张量(值必须在-1到1之间)
x = torch.tensor([-0.5, -0.25, 0.0, 0.25, 0.5])
# 计算反双曲正切
result = torch.arctanh(x)
print(result)
输出结果为:
tensor([-0.5493, -0.2554, 0.0000, 0.2554, 0.5493])

Pytorch torch 参考手册