Operator¶
toydl.core.operator.add ¶
add(x: float, y: float) -> float
\(f(x, y) = x + y\)
Source code in toydl/core/operator.py
18 19 20 |
|
toydl.core.operator.id_ ¶
id_(x: float) -> float
\(f(x) = x\)
Source code in toydl/core/operator.py
13 14 15 |
|
toydl.core.operator.lt ¶
lt(x: float, y: float) -> float
\(f(x, y) = x < y\)
Source code in toydl/core/operator.py
32 33 34 |
|
toydl.core.operator.mul ¶
mul(x: float, y: float) -> float
\(f(x, y) = x * y\)
Source code in toydl/core/operator.py
4 5 6 |
|
toydl.core.operator.neg ¶
neg(x: float) -> float
\(f(x) = -x\)
Source code in toydl/core/operator.py
23 24 25 |
|
toydl.core.operator.relu ¶
relu(x: float) -> float
f(x) = x if x is greater than 0, else 0
Source code in toydl/core/operator.py
72 73 74 75 76 |
|
toydl.core.operator.sigmoid ¶
sigmoid(x: float) -> float
\[f(x) = \frac{1.0}{(1.0 + e^{-x})}\]
Calculate as
\[
f(x) = \begin{cases}
\frac{1.0}{1.0 + e^{-x}} & \text{if } x \geq 0 \\
\frac{e^x}{1.0 + e^x} & \text{otherwise}
\end{cases}
\]
for stability.
The key is to make sure the x
in exp(x) is always negative to avoid exp(x) overflow.
Source code in toydl/core/operator.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|