torch.Tensor.Tensor.arctanh_
Tensor.arctanh_(): thisIn-place inverse hyperbolic tangent (arctanh).
Computes the inverse hyperbolic tangent of each element in-place. The input must be in the range (-1, 1) for real-valued outputs. Element-wise: y = arctanh(x) = 0.5 * ln((1 + x) / (1 - x)).
Use Cases:
- Inverse of tanh activations (common in RNNs)
- Fisher z-transformation for correlation analysis
- Unbounded encoding of bounded values
- Signal processing with range compression
- Input range: Input must be in (-1, 1) for finite real output.
- Boundary behavior: Input at ±1 produces ±Infinity.
- Unbounded output: Maps [-1, 1] to (-∞, ∞).
- In-place: Modifies tensor directly, more memory efficient.
- Alias: PyTorch calls this
atanh_(), this is thearctanh_()alias.
Returns
this– This tensor, modified in-placeExamples
const x = torch.tensor([0, 0.5, -0.5]);
x.arctanh_(); // [0, 0.549, -0.549]
// Input must be in (-1, 1)
const valid = torch.tensor([-0.9, -0.5, 0, 0.5, 0.9]);
valid.arctanh_(); // Works fine
// Boundary values produce infinite results
const boundary = torch.tensor([1]);
boundary.arctanh_(); // Results in ±Infinity
// Inverse of tanh - common in RNNs
const tanhOutput = torch.tensor([0, 0.5, -0.5]);
const encoded = tanhOutput.clone().arctanh_();