From a334614ee4db2addee83bc6c61cf18b39c7e1e2e Mon Sep 17 00:00:00 2001 From: Lukas Kulas Date: Sat, 16 Aug 2025 18:18:45 +0800 Subject: [PATCH 1/6] Attempt to create n exp2 entry fot pytorch --- .../tensor-operations/terms/exp2/exp2.md | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md new file mode 100644 index 00000000000..d922af29ebe --- /dev/null +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -0,0 +1,23 @@ +The **`.exp2()`** function in PyTorch computes the base-2 exponential of each element in the input tensor. This function is useful for various mathematical operations and can be applied to tensors of any shape. The result is a new tensor with the same shape as the input, containing the base-2 exponentials of the input values. + +## Syntax + +```python +tensor.exp2() +``` + +Here's an example of how to use the .exp2() function in PyTorch: + +```python +import torch + +# Create a tensor +x = torch.tensor([1.0, 2.0, 3.0]) + +# Compute the base-2 exponential +y = x.exp2() + +print(y) +``` + +In this example, the .exp2() function is applied to the tensor `x`, and the result is stored in the tensor `y`. The output will be a tensor containing the base-2 exponentials of the elements in `x`. \ No newline at end of file From 809c6136dca29f0d1d401235ffc41e79c39e1398 Mon Sep 17 00:00:00 2001 From: arisdelacruz <115809819+arisdelacruz@users.noreply.github.com> Date: Sat, 16 Aug 2025 19:47:38 +0800 Subject: [PATCH 2/6] Update exp2.md --- .../tensor-operations/terms/exp2/exp2.md | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md index d922af29ebe..34eb5dbfaa4 100644 --- a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -1,3 +1,21 @@ +--- +Title: '.exp2()' +Description: 'Returns a new tensor with the base-2 exponential of each element in the input tensor.' +Subjects: + - 'Computer Science' + - 'Machine Learning' + - 'Mathematics' + - 'Deep Learning' +Tags: + - 'Tensor Operations' + - 'Exponential Functions' + - 'Mathematics' + - 'Deep Learning' +CatalogContent: + - 'intro-to-py-torch-and-neural-networks' + - 'paths/computer-science' +--- + The **`.exp2()`** function in PyTorch computes the base-2 exponential of each element in the input tensor. This function is useful for various mathematical operations and can be applied to tensors of any shape. The result is a new tensor with the same shape as the input, containing the base-2 exponentials of the input values. ## Syntax @@ -6,9 +24,19 @@ The **`.exp2()`** function in PyTorch computes the base-2 exponential of each el tensor.exp2() ``` +**Parameters:** + +- `self` (Tensor): The input tensor whose elements you want to compute the base-2 exponential for. + +**Keyword Arguments:** + +- `out` (Tensor, optional): The output tensor to store the result. + +## Example + Here's an example of how to use the .exp2() function in PyTorch: -```python +```py import torch # Create a tensor @@ -20,4 +48,10 @@ y = x.exp2() print(y) ``` -In this example, the .exp2() function is applied to the tensor `x`, and the result is stored in the tensor `y`. The output will be a tensor containing the base-2 exponentials of the elements in `x`. \ No newline at end of file +The output will be: + +```shell +tensor([2.0000, 4.0000, 8.0000]) +``` + +In this example, the .exp2() function is applied to the tensor `x`, and the result is stored in the tensor `y`. The output will be a tensor containing the base-2 exponentials of the elements in `x`. From b933491dd7e0f80b317b57cf3942b0c57c62aa8c Mon Sep 17 00:00:00 2001 From: Mamta Wardhani Date: Tue, 19 Aug 2025 17:52:28 +0530 Subject: [PATCH 3/6] minor updates --- .../tensor-operations/terms/exp2/exp2.md | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md index 34eb5dbfaa4..03f4cc1e30d 100644 --- a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -4,13 +4,10 @@ Description: 'Returns a new tensor with the base-2 exponential of each element i Subjects: - 'Computer Science' - 'Machine Learning' - - 'Mathematics' - - 'Deep Learning' Tags: - - 'Tensor Operations' - - 'Exponential Functions' - - 'Mathematics' - 'Deep Learning' + - 'Functions' + - 'Tensor' CatalogContent: - 'intro-to-py-torch-and-neural-networks' - 'paths/computer-science' @@ -20,21 +17,28 @@ The **`.exp2()`** function in PyTorch computes the base-2 exponential of each el ## Syntax -```python -tensor.exp2() +```pseudo +tensor.exp2(input, *, out=None) ``` -**Parameters:** +This function is an alias for: -- `self` (Tensor): The input tensor whose elements you want to compute the base-2 exponential for. +```pseudo +torch.special.exp2(input, *, out=None) +``` -**Keyword Arguments:** +**Parameters:** +- `self` (Tensor): The input tensor. - `out` (Tensor, optional): The output tensor to store the result. +**Return value:** + +The `.exp2()` function returns a tensor with the base-2 exponentials of the input tensor, same shape as the input. + ## Example -Here's an example of how to use the .exp2() function in PyTorch: +Here's an example of how to use the `.exp2()` function in PyTorch: ```py import torch @@ -51,7 +55,7 @@ print(y) The output will be: ```shell -tensor([2.0000, 4.0000, 8.0000]) +tensor([2., 4., 8.]) ``` -In this example, the .exp2() function is applied to the tensor `x`, and the result is stored in the tensor `y`. The output will be a tensor containing the base-2 exponentials of the elements in `x`. +In this example, the `.exp2()` function is applied to the tensor `x`, and the result is stored in the tensor `y`. The output will be a tensor containing the base-2 exponentials of the elements in `x`. From 0bb0e1ab7b1c0fec51c212e10d642f91def9dd5c Mon Sep 17 00:00:00 2001 From: Avdhoot <50920321+avdhoottt@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:18:06 +0530 Subject: [PATCH 4/6] Update content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md --- .../pytorch/concepts/tensor-operations/terms/exp2/exp2.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md index 03f4cc1e30d..be8506dda4e 100644 --- a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -18,7 +18,11 @@ The **`.exp2()`** function in PyTorch computes the base-2 exponential of each el ## Syntax ```pseudo -tensor.exp2(input, *, out=None) +# Function syntax: +result = torch.exp2(input, *, out=None) + +# Tensor method syntax: +result = tensor.exp2() ``` This function is an alias for: From 3e0e39a55b9fedc78d82575d8c91a92dd10b5f3a Mon Sep 17 00:00:00 2001 From: Avdhoot <50920321+avdhoottt@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:18:29 +0530 Subject: [PATCH 5/6] Update content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md --- content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md index be8506dda4e..b9aba1e54ab 100644 --- a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -33,8 +33,8 @@ torch.special.exp2(input, *, out=None) **Parameters:** -- `self` (Tensor): The input tensor. -- `out` (Tensor, optional): The output tensor to store the result. +- input (Tensor): The input tensor +- out (Tensor, optional): The output tensor to store the result **Return value:** From 17a453e16ee3d632be4927315c591d3e6f407398 Mon Sep 17 00:00:00 2001 From: Avdhoot <50920321+avdhoottt@users.noreply.github.com> Date: Wed, 20 Aug 2025 22:21:11 +0530 Subject: [PATCH 6/6] Update content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md --- content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md index b9aba1e54ab..ba1ae1e8af2 100644 --- a/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md +++ b/content/pytorch/concepts/tensor-operations/terms/exp2/exp2.md @@ -13,7 +13,7 @@ CatalogContent: - 'paths/computer-science' --- -The **`.exp2()`** function in PyTorch computes the base-2 exponential of each element in the input tensor. This function is useful for various mathematical operations and can be applied to tensors of any shape. The result is a new tensor with the same shape as the input, containing the base-2 exponentials of the input values. +The **`.exp2()`** function in PyTorch computes the base-2 exponential of each element in the input [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). This function is useful for various mathematical operations and can be applied to tensors of any shape. The result is a new tensor with the same shape as the input, containing the base-2 exponentials of the input values. ## Syntax