Skip to content

Commit 40f8f4f

Browse files
[Term Entry] PyTorch Tensor Operations: .erfc()
* Create erfc.md * Update erfc.md * Update erfc.md * Update erfc.md ---------
1 parent 68f0571 commit 40f8f4f

File tree

1 file changed

+61
-0
lines changed
  • content/pytorch/concepts/tensor-operations/terms/erfc

1 file changed

+61
-0
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
Title: '.erfc()'
3+
Description: 'Computes the complementary error function of input.'
4+
Subjects:
5+
- 'Computer Science'
6+
- 'Machine Learning'
7+
Tags:
8+
- 'Functions'
9+
- 'Machine Learning'
10+
- 'Python'
11+
- 'Tensor'
12+
CatalogContent:
13+
- 'intro-to-py-torch-and-neural-networks'
14+
- 'paths/computer-science'
15+
---
16+
17+
In PyTorch, the **`.erfc()`** function returns the complementary error function of of each element in the input [tensor](https://www.codecademy.com/resources/docs/pytorch/tensors). The complementary error function is written as:
18+
19+
$$erfc(x)= 1 - \frac{2}{\sqrt{\pi}}\int_0^1 e^{-t^2} dt$$
20+
21+
## Syntax
22+
23+
```pseudo
24+
torch.erfc(input, *, out=None) → Tensor
25+
```
26+
27+
Or,
28+
29+
```pseudo
30+
torch.special.erfc(input, *, out=None) → Tensor
31+
```
32+
33+
**Parameters:**
34+
35+
- `input`: The input tensor.
36+
- `out` (Optional): A tensor to store the output. If provided, the result is written to this tensor.
37+
38+
**Return value:**
39+
40+
It returns a new tensor of the same shape as the input, containing the computed complementary error function values for each corresponding element.
41+
42+
## Example
43+
44+
In this example, we compute the complementary error function values of each tensor using `.erfc()`:
45+
46+
```py
47+
import torch
48+
49+
# Define a tensor
50+
x = torch.tensor([0, -1., 10.])
51+
52+
result = torch.erfc(x)
53+
54+
print(result)
55+
```
56+
57+
The output of this code is:
58+
59+
```shell
60+
tensor([1.0000e+00, 1.8427e+00, 1.4013e-45])
61+
```

0 commit comments

Comments
 (0)