PyTorch torch.exp() method returns a new tensor after getting the exponent of the elements of the input tensor.

Syntax:
torch.exp(input, out=None)Arguments
- input: This is input tensor.
- out: The output tensor.
Return: It returns a Tensor.
Let’s see this concept with the help of few examples:
Example 1:
Example 1:
# Importing the PyTorch library import torch # A constant tensor of size n a = torch.randn(6) print(a) # Applying the exp function and # storing the result in 'out' out = torch.exp(a) print(out) |
chevron_right
filter_none
Output:
1.0532 -1.9300 0.6392 -0.7519 0.9133 0.3998 [torch.FloatTensor of size 6] 2.8667 0.1451 1.8949 0.4715 2.4925 1.4915 [torch.FloatTensor of size 6]
Example 2:
# Importing the PyTorch library import torch # A constant tensor of size n a = torch.FloatTensor([1, 4, 6, 3]) print(a) # Applying the exp function and # storing the result in 'out' out = torch.exp(a) print(out) |
chevron_right
filter_none
Output:
1 4 6 3 [torch.FloatTensor of size 4] 2.7183 54.5981 403.4288 20.0855 [torch.FloatTensor of size 4]
Recommended Posts:
- Python - PyTorch abs() method
- Python - PyTorch log() method
- Python Pytorch eye() method
- Python Pytorch ones() method
- Python | PyTorch cos() method
- Python | PyTorch sin() method
- Python | PyTorch tan() method
- Python - PyTorch div() method
- Python - PyTorch add() method
- Python Pytorch range() method
- Python - PyTorch is_storage() method
- Python - PyTorch numel() method
- Python - PyTorch fmod() method
- Python - PyTorch floor() method
- Python - PyTorch frac() method
- Python | PyTorch atan() method
- Python - PyTorch is_storage() method
- Python | PyTorch asin() method
- Python - PyTorch is_tensor() method
- Python | PyTorch acos() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

