Skip to content

[Term Entry] PyTorch Tensor Operations: .exp() #7262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions content/pytorch/concepts/tensor-operations/terms/exp/exp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
Title: '.exp()'
Description: 'Returns a new tensor with the exponential of the elements of the input tensor input..'
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 **`.exp()`** function computes the exponential of each element in the input tensor. This is mathematically equivalent to applying the function $y_i = e^{x_i}$ element-wise, where `e` is Euler’s number (~2.71828).

## Syntax

```py
torch.exp(input, *, out=None) → Tensor
```

**Parameters :**

- input: The input tensor.
- out *(optional)*: The output tensor to store results.

**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 :
```py
import torch

# Define a tensor
x = torch.tensor([0.0 , 1.0 , 2.0 , math.log(2.) ])

# Compute the exponential
result = torch.exp(x)

print(result)

```

The above code produces the following output:

```shell
tensor([1.0000 , 2.7183, 7.3891 , 2. ])
```