Skip to content

Commit dd9f760

Browse files
authored
Update logaddexp.md
1 parent 362c8fa commit dd9f760

File tree

1 file changed

+5
-6
lines changed
  • content/pytorch/concepts/tensor-operations/terms/logaddexp

1 file changed

+5
-6
lines changed

content/pytorch/concepts/tensor-operations/terms/logaddexp/logaddexp.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ Description: 'Computes the element-wise logarithm of the sum of exponentials of
44
Subjects:
55
- 'Code Foundations'
66
- 'Computer Science'
7-
- 'Data Science'
87
Tags:
98
- 'Elements'
109
- 'Methods'
@@ -15,11 +14,11 @@ CatalogContent:
1514
- 'paths/data-science'
1615
---
1716

18-
The **`.logaddexp()`** function in PyTorch computes the point-wise value of:
17+
The **`.logaddexp()`** function in PyTorch computes the element-wise logarithm of the sum of exponentials of two input [tensors](https://www.codecademy.com/resources/docs/pytorch/tensors). If the tensors are `x` and `y`, the mathematical formula will be:
1918

2019
$$\log(\exp(x) + \exp(y))$$
2120

22-
for two input tensors `x` and `y`. This operation is particularly useful for combining log-space values (such as log-probabilities) in a numerically stable way.
21+
This operation is particularly useful for combining log-space values (such as log-probabilities) in a numerically stable way.
2322

2423
## Syntax
2524

@@ -39,7 +38,7 @@ Returns a new tensor of the same shape as the broadcasted `input` and `other`, w
3938

4039
$$\log\left(\exp(\text{input}[i]) + \exp(\text{other}[i])\right)$$
4140

42-
## Example 1: Combining log-probabilities
41+
## Example 1: Combining Log-Probabilities
4342

4443
In this example, two tensors representing log-probabilities are combined using `.logaddexp()`:
4544

@@ -53,13 +52,13 @@ result = torch.logaddexp(x, y)
5352
print(result)
5453
```
5554

56-
The ouput of this code is:
55+
The output of this code is:
5756

5857
```shell
5958
tensor([ 0.3544, -0.2870, -2.7986])
6059
```
6160

62-
## Example 2: Broadcasting two tensors of different shapes
61+
## Example 2: Broadcasting Two Tensors of Different Shapes
6362

6463
In this example, a tensor and a scalar are combined with broadcasting using `.logaddexp()`:
6564

0 commit comments

Comments
 (0)