Commit ade8ab5
authored
⚡️ Speed up function
Here is an optimized version of your program. The original code inadvertently computes `np.exp(x)` twice when `x < 0`, incurring redundant computation. By computing it once and caching the result, you eliminate the duplicate work. This reduces runtime, especially on large arrays.
This form reduces repeated computation and will run faster, especially for large NumPy arrays.
**All comments are preserved unless their code portion changed.**sigmoid_stable by 208%1 parent 102b4b6 commit ade8ab5
1 file changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments