You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 67dc6b2
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/interfaces/special.md
+24-2Lines changed: 24 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,16 +6,31 @@ Operations that do not belong to any of the other interface groups.
6
6
7
7
## Overview
8
8
9
-
`Special` holds the operations that neither pointwise element-wise functions (`Arithmetic`, `Comparable`, `Unary`, `Trigonometric`), nor aggregate reductions (`Reductions`), nor array-like access (`ArrayLike`) can describe.
9
+
`Special` holds the operations that neither the basic algebraic and trigonometric families (`Arithmetic`, `Comparable`, `Unary`, `Trigonometric`), aggregate reductions (`Reductions`), nor array-like access (`ArrayLike`) can describe.
10
10
11
-
`softmax()` is the sole member: it preserves the shape of the tensor, but each element of the output depends on a whole reduction axis rather than on one input element, so it is neither element-wise nor a reduction.
11
+
`softmax()` is the only shape-preserving member whose output depends on a whole reduction axis rather than on one input element, so it is neither element-wise nor a reduction. `erf()` is an element-wise error-function transform grouped here so the error-function family stays together, distinct from the basic algebraic operations.
12
12
13
13
```php
14
14
interface Special
15
15
```
16
16
17
17
## Methods
18
18
19
+
### `sigmoid() : mixed`
20
+
21
+
Return the element-wise logistic function, `1 / (1 + exp(-x))`.
22
+
23
+
A large negative input saturates to exactly `0.0` and a large positive one to
24
+
exactly `1.0`, so the result never overflows to an infinity.
25
+
26
+
### `softplus() : mixed`
27
+
28
+
Return the element-wise softplus, `log(1 + exp(x))`.
29
+
30
+
The computation is numerically stable: for a large positive input it reduces to
31
+
`x + log1p(0) == x` and for a large negative input to `log1p(0) == 0.0`, so the
32
+
result never overflows to an infinity.
33
+
19
34
### `softmax() : mixed`
20
35
21
36
Return the softmax of the tensor, i.e. the exponentials of its elements
@@ -36,3 +51,10 @@ The maximum of each row is subtracted before exponentiating, so no intermediate
36
51
can overflow regardless of the magnitude of the input, and a single-element row
37
52
normalizes to `1.0`. Note the degenerate case this implies: a matrix with a
38
53
single *column* has one-element rows, so it normalizes to all ones.
54
+
55
+
### `erf() : mixed`
56
+
57
+
Return the element-wise Gaussian error function.
58
+
59
+
A large input saturates to exactly `1.0` or `-1.0` rather than returning an
Every group is homogeneous in what it does to the tensor's shape: `Arithmetic`,
29
29
`Comparable`, `Unary`, and `Trigonometric` are element-wise and preserve it,
30
30
`Reductions` collapse it, and `ArrayLike` is about access rather than arithmetic.
31
-
`Special` is the escape hatch for operations that preserve the shape without being
32
-
element-wise.
31
+
`Special` is the escape hatch for operations that fit no other group, such as shape-preserving cross-axis operations like `softmax()` and the element-wise error-function family `erf()`.
33
32
34
33
Additionally, because `ArrayLike` extends `ArrayAccess`, `IteratorAggregate`, and `Countable`, every tensor is array-accessible, iterable, and countable.
0 commit comments