torch.Tensor.Tensor.arctan_
Tensor.arctan_(): thisIn-place inverse tangent (arctangent).
Computes the inverse tangent (arctangent) of each element in-place. The input can be any real value. Element-wise: y = arctan(x) where arctan returns values in (-π/2, π/2).
Use Cases:
- Recovering angles from tangent values
- Normalized slope calculations
- Converting unbounded values to bounded angles
- Activation function for angle representation
- Signal demodulation
- Input range: Any real number (no restrictions).
- Output range: Output is in (-π/2, π/2) radians.
- Unbounded to bounded: Maps unbounded inputs to bounded angles.
- In-place: Modifies tensor directly, more memory efficient.
- Alias: PyTorch calls this
atan_(), this is thearctan_()alias.
Returns
this– This tensor, modified in-placeExamples
const x = torch.tensor([0, 1, -1]);
x.arctan_(); // [0, π/4, -π/4] ≈ [0, 0.785, -0.785]
// No input restrictions - works for any value
const unbounded = torch.tensor([-100, 0, 100]);
unbounded.arctan_(); // Bounded to (-π/2, π/2)
// Recover angle from slope (rise/run)
const slopes = torch.tensor([1, 0.5, 2]);
const angles = slopes.clone().arctan_();
// Normalize network outputs to angles
const output = torch.randn([10, 1]);
output.arctan_(); // Now in range (-π/2, π/2)