From a6aae73041fea2cdad8f5ca64979ea024178a773 Mon Sep 17 00:00:00 2001 From: AtulDeshpande09 Date: Mon, 30 Jun 2025 20:09:18 +0530 Subject: [PATCH 1/2] [Term Entry] PyTorch Tensor Operations: .deg2rad() --- .../terms/deg2rad/deg2rad.md | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md diff --git a/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md b/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md new file mode 100644 index 00000000000..9521cebc2b8 --- /dev/null +++ b/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md @@ -0,0 +1,54 @@ +--- +Title: '.deg2rad()' +Description: 'Converts angles from degrees to radians.' +Subjects: + - 'Computer Science' + - 'Machine Learning' +Tags: + - 'Python' + - 'Machine Learning' + - 'Functions' + - 'Tensor' +CatalogContent: + - 'intro-to-py-torch-and-neural-networks' + - 'paths/computer-science' +--- + +In PyTorch, the **`.deg2rad()`** function converts angles from degrees to radians. This is especially useful when working with trigonometric functions like `sin()` or `cos()`, which expect inputs in radians. + +## Syntax + +```py +torch.deg2rad(input, *, out=None) + +``` + +- `input`: A tensor containing angle values in degrees. + +- `out` _(optional)_: The output tensor. + + +## Example + +The following example demonstrates the usage of the `.deg2rad()` function: + +```py +import torch + +# Define a tensor with angles in degrees +degrees = torch.tensor([0.0, 90.0, 180.0, 270.0]) + +# Convert to radians +radians = torch.deg2rad(degrees) + +# Print the result +print(radians) + +``` + +The above code produces the following output: + +```shell +tensor([0.0000, 1.5708, 3.1416, 4.7124]) + +``` From e0c6d3887e3038a5cc0175942c93afe65055e786 Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Fri, 4 Jul 2025 09:25:32 +0530 Subject: [PATCH 2/2] content --- .../terms/deg2rad/deg2rad.md | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md b/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md index 9521cebc2b8..32a69a3ec9f 100644 --- a/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md +++ b/content/pytorch/concepts/tensor-operations/terms/deg2rad/deg2rad.md @@ -5,28 +5,31 @@ Subjects: - 'Computer Science' - 'Machine Learning' Tags: - - 'Python' - - 'Machine Learning' - 'Functions' + - 'Machine Learning' + - 'Python' - 'Tensor' CatalogContent: - 'intro-to-py-torch-and-neural-networks' - 'paths/computer-science' --- -In PyTorch, the **`.deg2rad()`** function converts angles from degrees to radians. This is especially useful when working with trigonometric functions like `sin()` or `cos()`, which expect inputs in radians. +In PyTorch, the **`.deg2rad()`** function converts angles from degrees to radians. This is especially useful when using trigonometric functions like `torch.sin()` or `torch.cos()`, which require input in radians. ## Syntax -```py +```pseudo torch.deg2rad(input, *, out=None) - ``` -- `input`: A tensor containing angle values in degrees. - -- `out` _(optional)_: The output tensor. - +**Parameters:** + +- `input`: The input tensor containing angles in degrees. +- `out` (optional): The output tensor to store the result. If provided, the result is written to this tensor in-place. + +**Return value:** + +A tensor with the same shape as `input`, where each element is converted from degrees to radians. If `out` is specified, the returned tensor is the same as `out`. ## Example @@ -43,12 +46,10 @@ radians = torch.deg2rad(degrees) # Print the result print(radians) - ``` The above code produces the following output: ```shell tensor([0.0000, 1.5708, 3.1416, 4.7124]) - ```