torch.Tensor.Tensor.deg2rad
Convert degrees to radians.
Multiplies each element by π/180 to convert from degree to radian measure. Useful for converting user-provided angles to the radian convention used by torch.
Use Cases:
- Converting user input angles from degrees to radians
- Preparing angle data for trigonometric functions
Returns
Tensor<S, D, Dev>– New tensor with angles converted to radiansExamples
// Convert common angles
const angles_deg = torch.tensor([0, 90, 180, 270, 360]);
const angles_rad = angles_deg.deg2rad(); // [0, π/2, π, 3π/2, 2π]
// Convert and compute sine
const degrees = torch.tensor([30, 45, 60]);
const result = degrees.deg2rad().sin(); // [0.5, √2/2, √3/2]See Also
- PyTorch tensor.deg2rad()
- rad2deg - Inverse operation