@reicek/neataptic-ts 0.1.25 → 0.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/copilot-instructions.md +11 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +3 -3
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +1 -1
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +1 -1
- package/.github/skills/trace-audit-reporting/SKILL.md +3 -3
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +1 -1
- package/package.json +19 -13
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +4 -4
- package/plans/README.md +24 -0
- package/plans/Roadmap.md +62 -40
- package/plans/analyze-trace-solid-split.plans.md +66 -0
- package/plans/architecture-solid-split.plans.md +9 -15
- package/plans/asciiMaze-typescript-repair.plans.md +1 -1
- package/plans/generate-docs-solid-split.plans.md +87 -0
- package/plans/methods-docs.plans.md +25 -1
- package/plans/methods-solid-split.plans.md +14 -14
- package/plans/neat-docs.plans.md +9 -1
- package/plans/neat-test-surface-repair.plans.md +1 -1
- package/plans/render-docs-html-solid-split.plans.md +68 -0
- package/plans/src-no-explicit-any-cleanup.plans.md +1 -1
- package/plans/utils-docs.plans.md +6 -1
- package/scripts/analyze-trace/analyze-trace.analysis.ts +479 -0
- package/scripts/analyze-trace/analyze-trace.constants.ts +35 -0
- package/scripts/analyze-trace/analyze-trace.io.ts +69 -0
- package/scripts/analyze-trace/analyze-trace.report.ts +100 -0
- package/scripts/analyze-trace/analyze-trace.shared.ts +116 -0
- package/scripts/analyze-trace/analyze-trace.ts +45 -0
- package/scripts/analyze-trace/analyze-trace.types.ts +72 -0
- package/scripts/assets/theme.css +80 -23
- package/scripts/copy-examples.ts +239 -0
- package/scripts/export-onnx.ts +223 -0
- package/scripts/generate-bench-tables.ts +378 -37
- package/scripts/generate-docs/generate-docs.constants.ts +107 -0
- package/scripts/generate-docs/generate-docs.order.ts +355 -0
- package/scripts/generate-docs/generate-docs.state.ts +31 -0
- package/scripts/generate-docs/generate-docs.targets.ts +165 -0
- package/scripts/generate-docs/generate-docs.ts +63 -0
- package/scripts/generate-docs/generate-docs.types.ts +112 -0
- package/scripts/generate-docs/output/generate-docs.output.folder-index.utils.ts +167 -0
- package/scripts/generate-docs/output/generate-docs.output.ordering.utils.ts +353 -0
- package/scripts/generate-docs/output/generate-docs.output.readme.utils.ts +420 -0
- package/scripts/generate-docs/output/generate-docs.output.ts +123 -0
- package/scripts/generate-docs/output/generate-docs.output.warnings.utils.ts +219 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.collection.utils.ts +365 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.jsdoc.utils.ts +373 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.normalize.utils.ts +155 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.render.utils.ts +149 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.signature.utils.ts +289 -0
- package/scripts/generate-docs/symbols/generate-docs.symbols.ts +11 -0
- package/scripts/mermaid-cli.mjs +102 -22
- package/scripts/mermaid-cli.ts +736 -0
- package/scripts/render-docs-html/render-docs-html.assets.ts +54 -0
- package/scripts/render-docs-html/render-docs-html.mermaid.ts +245 -0
- package/scripts/{render-docs-html.sidebar.ts → render-docs-html/render-docs-html.navigation.ts} +141 -144
- package/scripts/render-docs-html/render-docs-html.pages.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.shared.ts +333 -0
- package/scripts/render-docs-html/render-docs-html.types.ts +42 -0
- package/scripts/render-docs-html.ts +23 -587
- package/scripts/run-docs.ts +238 -0
- package/scripts/write-dist-docs-pkg.ts +40 -0
- package/src/README.md +75 -75
- package/src/architecture/connection/README.md +5 -5
- package/src/architecture/layer/README.md +508 -508
- package/src/architecture/network/README.md +1458 -1458
- package/src/architecture/network/activate/README.md +694 -694
- package/src/architecture/network/bootstrap/README.md +77 -77
- package/src/architecture/network/connect/README.md +74 -74
- package/src/architecture/network/deterministic/README.md +135 -135
- package/src/architecture/network/evolve/README.md +364 -364
- package/src/architecture/network/gating/README.md +130 -130
- package/src/architecture/network/genetic/README.md +399 -399
- package/src/architecture/network/mutate/README.md +897 -897
- package/src/architecture/network/onnx/README.md +720 -720
- package/src/architecture/network/onnx/export/README.md +728 -728
- package/src/architecture/network/onnx/export/layers/README.md +450 -450
- package/src/architecture/network/onnx/import/README.md +618 -618
- package/src/architecture/network/onnx/schema/README.md +32 -32
- package/src/architecture/network/prune/README.md +245 -245
- package/src/architecture/network/remove/README.md +135 -135
- package/src/architecture/network/runtime/README.md +106 -106
- package/src/architecture/network/serialize/README.md +542 -542
- package/src/architecture/network/slab/README.md +608 -608
- package/src/architecture/network/standalone/README.md +212 -212
- package/src/architecture/network/stats/README.md +84 -84
- package/src/architecture/network/topology/README.md +465 -465
- package/src/architecture/network/training/README.md +200 -200
- package/src/architecture/node/README.md +5 -5
- package/src/architecture/nodePool/README.md +14 -14
- package/src/methods/README.md +99 -99
- package/src/methods/activation/README.md +189 -189
- package/src/methods/cost/README.md +131 -131
- package/src/methods/rate/README.md +86 -86
- package/src/multithreading/README.md +77 -77
- package/src/multithreading/workers/browser/README.md +8 -8
- package/src/multithreading/workers/node/README.md +8 -8
- package/src/neat/README.md +148 -148
- package/src/neat/adaptive/README.md +120 -120
- package/src/neat/adaptive/acceptance/README.md +40 -40
- package/src/neat/adaptive/complexity/README.md +137 -137
- package/src/neat/adaptive/core/README.md +197 -197
- package/src/neat/adaptive/lineage/README.md +90 -90
- package/src/neat/adaptive/mutation/README.md +284 -284
- package/src/neat/compat/README.md +43 -43
- package/src/neat/compat/core/README.md +90 -90
- package/src/neat/diversity/README.md +35 -35
- package/src/neat/diversity/core/README.md +88 -88
- package/src/neat/evaluate/README.md +85 -85
- package/src/neat/evaluate/auto-distance/README.md +75 -75
- package/src/neat/evaluate/entropy-compat/README.md +37 -37
- package/src/neat/evaluate/entropy-sharing/README.md +43 -43
- package/src/neat/evaluate/fitness/README.md +23 -23
- package/src/neat/evaluate/novelty/README.md +120 -120
- package/src/neat/evaluate/objectives/README.md +17 -17
- package/src/neat/evaluate/shared/README.md +94 -94
- package/src/neat/evolve/README.md +96 -96
- package/src/neat/evolve/adaptive/README.md +60 -60
- package/src/neat/evolve/objectives/README.md +63 -63
- package/src/neat/evolve/offspring/README.md +56 -56
- package/src/neat/evolve/population/README.md +171 -171
- package/src/neat/evolve/runtime/README.md +79 -79
- package/src/neat/evolve/speciation/README.md +74 -74
- package/src/neat/evolve/warnings/README.md +10 -10
- package/src/neat/export/README.md +114 -114
- package/src/neat/helpers/README.md +50 -50
- package/src/neat/init/README.md +9 -9
- package/src/neat/lineage/core/README.md +101 -101
- package/src/neat/multiobjective/category/README.md +74 -74
- package/src/neat/multiobjective/crowding/README.md +272 -272
- package/src/neat/multiobjective/dominance/README.md +171 -171
- package/src/neat/multiobjective/fronts/README.md +68 -68
- package/src/neat/multiobjective/metrics/README.md +43 -43
- package/src/neat/multiobjective/objectives/README.md +31 -31
- package/src/neat/multiobjective/shared/README.md +27 -27
- package/src/neat/mutation/README.md +97 -97
- package/src/neat/mutation/add-conn/README.md +115 -115
- package/src/neat/mutation/add-node/README.md +126 -126
- package/src/neat/mutation/flow/README.md +149 -149
- package/src/neat/mutation/repair/README.md +185 -185
- package/src/neat/mutation/select/README.md +117 -117
- package/src/neat/mutation/shared/README.md +32 -32
- package/src/neat/objectives/README.md +25 -25
- package/src/neat/objectives/core/README.md +67 -67
- package/src/neat/pruning/README.md +40 -40
- package/src/neat/pruning/core/README.md +171 -171
- package/src/neat/pruning/facade/README.md +32 -32
- package/src/neat/rng/README.md +104 -104
- package/src/neat/rng/core/README.md +137 -137
- package/src/neat/rng/facade/README.md +50 -50
- package/src/neat/selection/README.md +111 -111
- package/src/neat/selection/core/README.md +227 -227
- package/src/neat/selection/facade/README.md +61 -61
- package/src/neat/shared/README.md +163 -163
- package/src/neat/speciation/README.md +31 -31
- package/src/neat/speciation/threshold/README.md +35 -35
- package/src/neat/species/README.md +25 -25
- package/src/neat/species/core/README.md +20 -20
- package/src/neat/species/core/shared/README.md +18 -18
- package/src/neat/species/history/context/README.md +22 -22
- package/src/neat/telemetry/accessors/README.md +58 -58
- package/src/neat/telemetry/exports/README.md +233 -233
- package/src/neat/telemetry/facade/README.md +252 -252
- package/src/neat/telemetry/facade/archive/README.md +57 -57
- package/src/neat/telemetry/facade/buffer/README.md +43 -43
- package/src/neat/telemetry/facade/lineage/README.md +12 -12
- package/src/neat/telemetry/facade/objectives/README.md +44 -44
- package/src/neat/telemetry/facade/runtime/README.md +26 -26
- package/src/neat/telemetry/facade/species/README.md +27 -27
- package/src/neat/telemetry/metrics/README.md +696 -696
- package/src/neat/telemetry/recorder/README.md +57 -57
- package/src/neat/telemetry/types/README.md +32 -32
- package/src/neat/topology-intent/README.md +75 -75
- package/src/utils/README.md +193 -193
- package/test/examples/asciiMaze/browser-entry/README.md +92 -92
- package/test/examples/asciiMaze/dashboardManager/README.md +109 -109
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +28 -28
- package/test/examples/asciiMaze/evolutionEngine/README.md +1527 -1527
- package/test/examples/asciiMaze/mazeMovement/README.md +105 -105
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +16 -16
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +57 -57
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +52 -52
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +46 -46
- package/test/examples/flappy_bird/browser-entry/README.md +508 -508
- package/test/examples/flappy_bird/browser-entry/host/README.md +101 -101
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +144 -144
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +194 -194
- package/test/examples/flappy_bird/browser-entry/playback/README.md +278 -278
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +129 -129
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +502 -502
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +139 -139
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +10 -10
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +43 -43
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +30 -30
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +59 -59
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +276 -276
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +16 -16
- package/test/examples/flappy_bird/constants/README.md +1070 -1070
- package/test/examples/flappy_bird/environment/README.md +22 -22
- package/test/examples/flappy_bird/evaluation/README.md +32 -32
- package/test/examples/flappy_bird/evaluation/rollout/README.md +141 -141
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +425 -425
- package/test/examples/flappy_bird/simulation-shared/README.md +170 -170
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +109 -109
- package/test/examples/flappy_bird/trainer/README.md +325 -325
- package/test/examples/flappy_bird/trainer/evaluation/README.md +74 -74
- package/scripts/analyze-trace.ts +0 -590
- package/scripts/copy-examples.mjs +0 -114
- package/scripts/export-onnx.mjs +0 -86
- package/scripts/generate-bench-tables.mjs +0 -182
- package/scripts/generate-docs.ts +0 -2900
- package/scripts/write-dist-docs-pkg.mjs +0 -16
|
@@ -156,304 +156,314 @@ forward-value question and the local-slope question, which is why the file is
|
|
|
156
156
|
organized around reusable transfer-curve families instead of separate forward
|
|
157
157
|
and derivative tables.
|
|
158
158
|
|
|
159
|
-
###
|
|
159
|
+
### absoluteActivation
|
|
160
160
|
|
|
161
161
|
```ts
|
|
162
|
-
|
|
162
|
+
absoluteActivation(
|
|
163
163
|
inputValue: number,
|
|
164
164
|
shouldComputeDerivative: boolean,
|
|
165
165
|
): number
|
|
166
166
|
```
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
Absolute activation implementation.
|
|
169
169
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
magnitude.
|
|
170
|
+
Absolute value discards sign and keeps only magnitude. It is unusual as a
|
|
171
|
+
default hidden-layer choice, but it can be useful in experiments where the
|
|
172
|
+
intensity of a signal matters more than whether it was positive or negative.
|
|
174
173
|
|
|
175
174
|
Parameters:
|
|
176
175
|
- `inputValue` - - Input to evaluate.
|
|
177
176
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
178
177
|
|
|
179
|
-
Returns:
|
|
178
|
+
Returns: Absolute output or derivative.
|
|
180
179
|
|
|
181
|
-
###
|
|
180
|
+
### ActivationFunction
|
|
182
181
|
|
|
183
182
|
```ts
|
|
184
|
-
|
|
183
|
+
ActivationFunction(
|
|
185
184
|
inputValue: number,
|
|
186
|
-
shouldComputeDerivative: boolean,
|
|
185
|
+
shouldComputeDerivative: boolean | undefined,
|
|
187
186
|
): number
|
|
188
187
|
```
|
|
189
188
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Compared with {@link logisticActivation}, tanh stays bounded while remaining
|
|
193
|
-
zero-centered, which often makes hidden activations easier to interpret when
|
|
194
|
-
positive and negative evidence should balance around zero.
|
|
189
|
+
Shared contract for activation implementations used by the runtime registry.
|
|
195
190
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
-
|
|
191
|
+
This utility layer is where the math-facing side of the activation chapter
|
|
192
|
+
lives. Each exported function keeps the same two-mode signature so the
|
|
193
|
+
higher-level {@link Activation} registry can switch between forward
|
|
194
|
+
evaluation and derivative lookup without wrapping every implementation in a
|
|
195
|
+
different adapter.
|
|
199
196
|
|
|
200
|
-
|
|
197
|
+
Read the implementations in four practical groups:
|
|
201
198
|
|
|
202
|
-
|
|
199
|
+
- bounded classics such as {@link logisticActivation},
|
|
200
|
+
{@link sigmoidActivation}, and {@link tanhActivation},
|
|
201
|
+
- sparse or piecewise-linear gates such as {@link reluActivation},
|
|
202
|
+
{@link stepActivation}, and {@link hardTanhActivation},
|
|
203
|
+
- shape-specialized functions such as {@link gaussianActivation},
|
|
204
|
+
{@link sinusoidActivation}, and {@link bentIdentityActivation},
|
|
205
|
+
- smoother modern hidden-layer candidates such as {@link softplusActivation},
|
|
206
|
+
{@link swishActivation}, {@link geluActivation}, and
|
|
207
|
+
{@link mishActivation}.
|
|
203
208
|
|
|
204
|
-
|
|
205
|
-
identityActivation(
|
|
206
|
-
inputValue: number,
|
|
207
|
-
shouldComputeDerivative: boolean,
|
|
208
|
-
): number
|
|
209
|
-
```
|
|
209
|
+
A useful reading order is:
|
|
210
210
|
|
|
211
|
-
|
|
211
|
+
1. compare {@link logisticActivation}, {@link tanhActivation}, and
|
|
212
|
+
{@link reluActivation} to anchor the classic bounded-versus-sparse trade,
|
|
213
|
+
2. scan {@link softplusActivation}, {@link swishActivation},
|
|
214
|
+
{@link geluActivation}, and {@link mishActivation} when you want smoother
|
|
215
|
+
hidden-layer behavior,
|
|
216
|
+
3. finish with the shape-specialized helpers when your experiment needs a
|
|
217
|
+
periodic, radial, or sign-like response rather than a general default.
|
|
212
218
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
219
|
+
Keep the derivative flag in mind while reading: every helper answers both the
|
|
220
|
+
forward-value question and the local-slope question, which is why the file is
|
|
221
|
+
organized around reusable transfer-curve families instead of separate forward
|
|
222
|
+
and derivative tables.
|
|
216
223
|
|
|
217
224
|
Parameters:
|
|
218
|
-
- `inputValue` - - Input to
|
|
219
|
-
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
225
|
+
- `inputValue` - - Input to the activation function.
|
|
226
|
+
- `shouldComputeDerivative` - - Whether to compute the derivative instead of the value.
|
|
220
227
|
|
|
221
|
-
Returns:
|
|
228
|
+
Returns: Activation output or derivative at the input.
|
|
222
229
|
|
|
223
|
-
###
|
|
230
|
+
### bentIdentityActivation
|
|
224
231
|
|
|
225
232
|
```ts
|
|
226
|
-
|
|
233
|
+
bentIdentityActivation(
|
|
227
234
|
inputValue: number,
|
|
228
235
|
shouldComputeDerivative: boolean,
|
|
229
236
|
): number
|
|
230
237
|
```
|
|
231
238
|
|
|
232
|
-
|
|
239
|
+
Bent identity activation implementation.
|
|
233
240
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
241
|
+
Bent identity stays close to a linear pass-through while adding a gentle
|
|
242
|
+
non-linearity near the origin. It is useful when pure identity feels too weak
|
|
243
|
+
but a strongly saturating activation would distort the signal too early.
|
|
237
244
|
|
|
238
245
|
Parameters:
|
|
239
246
|
- `inputValue` - - Input to evaluate.
|
|
240
247
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
241
248
|
|
|
242
|
-
Returns:
|
|
249
|
+
Returns: Bent identity output or derivative.
|
|
243
250
|
|
|
244
|
-
###
|
|
251
|
+
### bipolarActivation
|
|
245
252
|
|
|
246
253
|
```ts
|
|
247
|
-
|
|
254
|
+
bipolarActivation(
|
|
248
255
|
inputValue: number,
|
|
249
256
|
shouldComputeDerivative: boolean,
|
|
250
257
|
): number
|
|
251
258
|
```
|
|
252
259
|
|
|
253
|
-
|
|
260
|
+
Bipolar activation implementation.
|
|
254
261
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
the mathematical derivative is not uniquely defined there.
|
|
262
|
+
This is the sign-function version of a hard classifier: values collapse to
|
|
263
|
+
`-1` or `1` with no middle ground. It is mostly useful as a historical or
|
|
264
|
+
diagnostic contrast against smoother bounded activations.
|
|
259
265
|
|
|
260
266
|
Parameters:
|
|
261
267
|
- `inputValue` - - Input to evaluate.
|
|
262
268
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
263
269
|
|
|
264
|
-
Returns:
|
|
270
|
+
Returns: Bipolar output or derivative.
|
|
265
271
|
|
|
266
|
-
###
|
|
272
|
+
### bipolarSigmoidActivation
|
|
267
273
|
|
|
268
274
|
```ts
|
|
269
|
-
|
|
275
|
+
bipolarSigmoidActivation(
|
|
270
276
|
inputValue: number,
|
|
271
277
|
shouldComputeDerivative: boolean,
|
|
272
278
|
): number
|
|
273
279
|
```
|
|
274
280
|
|
|
275
|
-
|
|
281
|
+
Bipolar sigmoid activation implementation.
|
|
276
282
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
eager to saturate.
|
|
283
|
+
This is the `[-1, 1]` counterpart to {@link logisticActivation}. In practice
|
|
284
|
+
it is another route to a tanh-like curve, but the explicit bipolar naming is
|
|
285
|
+
helpful when comparing older NEAT-era literature or porting legacy settings.
|
|
281
286
|
|
|
282
287
|
Parameters:
|
|
283
288
|
- `inputValue` - - Input to evaluate.
|
|
284
289
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
285
290
|
|
|
286
|
-
Returns:
|
|
291
|
+
Returns: Bipolar sigmoid output or derivative.
|
|
287
292
|
|
|
288
|
-
###
|
|
293
|
+
### gaussianActivation
|
|
289
294
|
|
|
290
295
|
```ts
|
|
291
|
-
|
|
296
|
+
gaussianActivation(
|
|
292
297
|
inputValue: number,
|
|
293
298
|
shouldComputeDerivative: boolean,
|
|
294
299
|
): number
|
|
295
300
|
```
|
|
296
301
|
|
|
297
|
-
|
|
302
|
+
Gaussian activation implementation.
|
|
298
303
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
304
|
+
Gaussian responses peak at the origin and shrink toward zero on both sides,
|
|
305
|
+
which makes them useful when you want a node to behave more like a localized
|
|
306
|
+
detector than a broad monotonic amplifier.
|
|
302
307
|
|
|
303
308
|
Parameters:
|
|
304
309
|
- `inputValue` - - Input to evaluate.
|
|
305
310
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
306
311
|
|
|
307
|
-
Returns:
|
|
312
|
+
Returns: Gaussian output or derivative.
|
|
308
313
|
|
|
309
|
-
###
|
|
314
|
+
### geluActivation
|
|
310
315
|
|
|
311
316
|
```ts
|
|
312
|
-
|
|
317
|
+
geluActivation(
|
|
313
318
|
inputValue: number,
|
|
314
319
|
shouldComputeDerivative: boolean,
|
|
315
320
|
): number
|
|
316
321
|
```
|
|
317
322
|
|
|
318
|
-
Gaussian activation implementation.
|
|
323
|
+
Gaussian Error Linear Unit (GELU) activation implementation.
|
|
319
324
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
325
|
+
GELU keeps the soft gating idea of Swish but uses a Gaussian-CDF-shaped
|
|
326
|
+
weighting curve. This implementation uses the common tanh-based
|
|
327
|
+
approximation, which is fast enough for ordinary training code while staying
|
|
328
|
+
close to the exact GELU shape used in many transformer-era models.
|
|
323
329
|
|
|
324
330
|
Parameters:
|
|
325
331
|
- `inputValue` - - Input to evaluate.
|
|
326
332
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
327
333
|
|
|
328
|
-
Returns:
|
|
334
|
+
Returns: GELU output or derivative.
|
|
329
335
|
|
|
330
|
-
###
|
|
336
|
+
### hardTanhActivation
|
|
331
337
|
|
|
332
338
|
```ts
|
|
333
|
-
|
|
339
|
+
hardTanhActivation(
|
|
334
340
|
inputValue: number,
|
|
335
341
|
shouldComputeDerivative: boolean,
|
|
336
342
|
): number
|
|
337
343
|
```
|
|
338
344
|
|
|
339
|
-
|
|
345
|
+
Hard tanh activation implementation.
|
|
340
346
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
347
|
+
Hard tanh keeps tanh's familiar `[-1, 1]` output range while replacing the
|
|
348
|
+
curved middle section with a cheap piecewise-linear clamp. That makes it a
|
|
349
|
+
practical compromise when you want bounded outputs without paying for a full
|
|
350
|
+
smooth tanh evaluation.
|
|
344
351
|
|
|
345
352
|
Parameters:
|
|
346
353
|
- `inputValue` - - Input to evaluate.
|
|
347
354
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
348
355
|
|
|
349
|
-
Returns:
|
|
356
|
+
Returns: Hard tanh output or derivative.
|
|
350
357
|
|
|
351
|
-
###
|
|
358
|
+
### identityActivation
|
|
352
359
|
|
|
353
360
|
```ts
|
|
354
|
-
|
|
361
|
+
identityActivation(
|
|
355
362
|
inputValue: number,
|
|
356
363
|
shouldComputeDerivative: boolean,
|
|
357
364
|
): number
|
|
358
365
|
```
|
|
359
366
|
|
|
360
|
-
|
|
367
|
+
Identity activation implementation.
|
|
361
368
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
369
|
+
Use this when you explicitly want a linear pass-through unit. It is most
|
|
370
|
+
common in regression-style output layers or in experiments where the upstream
|
|
371
|
+
topology already provides the non-linearity and you only need a value relay.
|
|
365
372
|
|
|
366
373
|
Parameters:
|
|
367
374
|
- `inputValue` - - Input to evaluate.
|
|
368
375
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
369
376
|
|
|
370
|
-
Returns:
|
|
377
|
+
Returns: Identity output or derivative.
|
|
371
378
|
|
|
372
|
-
###
|
|
379
|
+
### inverseActivation
|
|
373
380
|
|
|
374
381
|
```ts
|
|
375
|
-
|
|
382
|
+
inverseActivation(
|
|
376
383
|
inputValue: number,
|
|
377
384
|
shouldComputeDerivative: boolean,
|
|
378
385
|
): number
|
|
379
386
|
```
|
|
380
387
|
|
|
381
|
-
|
|
388
|
+
Inverse activation implementation.
|
|
382
389
|
|
|
383
|
-
This
|
|
384
|
-
|
|
385
|
-
|
|
390
|
+
This helper mirrors a value around `1`, which makes it more of a niche
|
|
391
|
+
transformation than a general-purpose hidden activation. It is best read as
|
|
392
|
+
part of the method vocabulary's legacy and experimentation shelf rather than
|
|
393
|
+
as a recommended first-choice default.
|
|
386
394
|
|
|
387
395
|
Parameters:
|
|
388
396
|
- `inputValue` - - Input to evaluate.
|
|
389
397
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
390
398
|
|
|
391
|
-
Returns:
|
|
399
|
+
Returns: Inverse output or derivative.
|
|
392
400
|
|
|
393
|
-
###
|
|
401
|
+
### logisticActivation
|
|
394
402
|
|
|
395
403
|
```ts
|
|
396
|
-
|
|
404
|
+
logisticActivation(
|
|
397
405
|
inputValue: number,
|
|
398
406
|
shouldComputeDerivative: boolean,
|
|
399
407
|
): number
|
|
400
408
|
```
|
|
401
409
|
|
|
402
|
-
|
|
410
|
+
Logistic (sigmoid) activation implementation.
|
|
403
411
|
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
412
|
+
This is the bounded baseline most readers already know: useful when a node
|
|
413
|
+
should behave like a probability-like squashing unit, but also the easiest
|
|
414
|
+
activation to saturate if pre-activation values become too large in
|
|
415
|
+
magnitude.
|
|
408
416
|
|
|
409
417
|
Parameters:
|
|
410
418
|
- `inputValue` - - Input to evaluate.
|
|
411
419
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
412
420
|
|
|
413
|
-
Returns:
|
|
421
|
+
Returns: Logistic output or derivative.
|
|
414
422
|
|
|
415
|
-
###
|
|
423
|
+
### mishActivation
|
|
416
424
|
|
|
417
425
|
```ts
|
|
418
|
-
|
|
426
|
+
mishActivation(
|
|
419
427
|
inputValue: number,
|
|
420
428
|
shouldComputeDerivative: boolean,
|
|
421
429
|
): number
|
|
422
430
|
```
|
|
423
431
|
|
|
424
|
-
|
|
432
|
+
Mish activation implementation.
|
|
425
433
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
434
|
+
Mish is another smooth self-gated option, built from `x * tanh(softplus(x))`.
|
|
435
|
+
It keeps more negative-side nuance than ReLU while still rewarding large
|
|
436
|
+
positive evidence. The implementation reuses the same softplus stability
|
|
437
|
+
strategy so the helper behaves sensibly in the far positive and negative
|
|
438
|
+
tails.
|
|
429
439
|
|
|
430
440
|
Parameters:
|
|
431
441
|
- `inputValue` - - Input to evaluate.
|
|
432
442
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
433
443
|
|
|
434
|
-
Returns:
|
|
444
|
+
Returns: Mish output or derivative.
|
|
435
445
|
|
|
436
|
-
###
|
|
446
|
+
### reluActivation
|
|
437
447
|
|
|
438
448
|
```ts
|
|
439
|
-
|
|
449
|
+
reluActivation(
|
|
440
450
|
inputValue: number,
|
|
441
451
|
shouldComputeDerivative: boolean,
|
|
442
452
|
): number
|
|
443
453
|
```
|
|
444
454
|
|
|
445
|
-
|
|
455
|
+
Rectified Linear Unit (ReLU) activation implementation.
|
|
446
456
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
457
|
+
ReLU is the practical default for many hidden layers because it is cheap,
|
|
458
|
+
sparse, and easy to optimize. This implementation follows the common library
|
|
459
|
+
convention of returning `0` for the derivative at exactly `0`, even though
|
|
460
|
+
the mathematical derivative is not uniquely defined there.
|
|
451
461
|
|
|
452
462
|
Parameters:
|
|
453
463
|
- `inputValue` - - Input to evaluate.
|
|
454
464
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
455
465
|
|
|
456
|
-
Returns:
|
|
466
|
+
Returns: ReLU output or derivative.
|
|
457
467
|
|
|
458
468
|
### seluActivation
|
|
459
469
|
|
|
@@ -478,162 +488,152 @@ Parameters:
|
|
|
478
488
|
|
|
479
489
|
Returns: SELU output or derivative.
|
|
480
490
|
|
|
481
|
-
###
|
|
491
|
+
### sigmoidActivation
|
|
482
492
|
|
|
483
493
|
```ts
|
|
484
|
-
|
|
494
|
+
sigmoidActivation(
|
|
485
495
|
inputValue: number,
|
|
486
496
|
shouldComputeDerivative: boolean,
|
|
487
497
|
): number
|
|
488
498
|
```
|
|
489
499
|
|
|
490
|
-
|
|
500
|
+
Sigmoid alias activation implementation.
|
|
491
501
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
piecewise. The threshold checks keep the implementation numerically stable in
|
|
496
|
-
the extreme tails.
|
|
502
|
+
This intentionally delegates to {@link logisticActivation} so callers can use
|
|
503
|
+
either the mathematically explicit `logistic` name or the more common
|
|
504
|
+
deep-learning alias `sigmoid` without creating two separate implementations.
|
|
497
505
|
|
|
498
506
|
Parameters:
|
|
499
507
|
- `inputValue` - - Input to evaluate.
|
|
500
508
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
501
509
|
|
|
502
|
-
Returns:
|
|
510
|
+
Returns: Sigmoid output or derivative.
|
|
503
511
|
|
|
504
|
-
###
|
|
512
|
+
### sinusoidActivation
|
|
505
513
|
|
|
506
514
|
```ts
|
|
507
|
-
|
|
515
|
+
sinusoidActivation(
|
|
508
516
|
inputValue: number,
|
|
509
517
|
shouldComputeDerivative: boolean,
|
|
510
518
|
): number
|
|
511
519
|
```
|
|
512
520
|
|
|
513
|
-
|
|
521
|
+
Sinusoid activation implementation.
|
|
514
522
|
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
523
|
+
Reach for this when periodic structure matters more than monotonicity. A
|
|
524
|
+
sinusoidal response can encode cycles and phase relationships that ordinary
|
|
525
|
+
squashing activations tend to smooth away.
|
|
518
526
|
|
|
519
527
|
Parameters:
|
|
520
528
|
- `inputValue` - - Input to evaluate.
|
|
521
529
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
522
530
|
|
|
523
|
-
Returns:
|
|
531
|
+
Returns: Sinusoid output or derivative.
|
|
524
532
|
|
|
525
|
-
###
|
|
533
|
+
### softplusActivation
|
|
526
534
|
|
|
527
535
|
```ts
|
|
528
|
-
|
|
536
|
+
softplusActivation(
|
|
529
537
|
inputValue: number,
|
|
530
538
|
shouldComputeDerivative: boolean,
|
|
531
539
|
): number
|
|
532
540
|
```
|
|
533
541
|
|
|
534
|
-
|
|
542
|
+
Softplus activation implementation with stability guards.
|
|
535
543
|
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
544
|
+
Softplus is the smooth sibling of {@link reluActivation}: for large positive
|
|
545
|
+
values it behaves almost linearly, for large negative values it fades toward
|
|
546
|
+
zero, and around the origin it avoids the hard corner that makes ReLU
|
|
547
|
+
piecewise. The threshold checks keep the implementation numerically stable in
|
|
548
|
+
the extreme tails.
|
|
540
549
|
|
|
541
550
|
Parameters:
|
|
542
551
|
- `inputValue` - - Input to evaluate.
|
|
543
552
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
544
553
|
|
|
545
|
-
Returns:
|
|
554
|
+
Returns: Softplus output or derivative.
|
|
546
555
|
|
|
547
|
-
###
|
|
556
|
+
### softsignActivation
|
|
548
557
|
|
|
549
558
|
```ts
|
|
550
|
-
|
|
559
|
+
softsignActivation(
|
|
551
560
|
inputValue: number,
|
|
552
561
|
shouldComputeDerivative: boolean,
|
|
553
562
|
): number
|
|
554
563
|
```
|
|
555
564
|
|
|
556
|
-
|
|
565
|
+
Softsign activation implementation.
|
|
557
566
|
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
tails.
|
|
567
|
+
Softsign behaves like a gentler, cheaper-to-reason-about cousin of tanh. It
|
|
568
|
+
still compresses values into a bounded range, but the tails decay more
|
|
569
|
+
gradually, which can make it a useful comparison point when tanh feels too
|
|
570
|
+
eager to saturate.
|
|
563
571
|
|
|
564
572
|
Parameters:
|
|
565
573
|
- `inputValue` - - Input to evaluate.
|
|
566
574
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
567
575
|
|
|
568
|
-
Returns:
|
|
576
|
+
Returns: Softsign output or derivative.
|
|
569
577
|
|
|
570
|
-
###
|
|
578
|
+
### stepActivation
|
|
571
579
|
|
|
572
580
|
```ts
|
|
573
|
-
|
|
581
|
+
stepActivation(
|
|
574
582
|
inputValue: number,
|
|
575
583
|
shouldComputeDerivative: boolean,
|
|
576
584
|
): number
|
|
577
585
|
```
|
|
578
586
|
|
|
579
|
-
|
|
587
|
+
Step activation implementation.
|
|
580
588
|
|
|
581
|
-
This
|
|
582
|
-
|
|
583
|
-
|
|
589
|
+
This is the hard-threshold ancestor of smoother gates: it cleanly separates
|
|
590
|
+
negative from positive evidence, but its zero derivative almost everywhere
|
|
591
|
+
makes it a poor default for gradient-based training.
|
|
584
592
|
|
|
585
593
|
Parameters:
|
|
586
594
|
- `inputValue` - - Input to evaluate.
|
|
587
595
|
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
588
596
|
|
|
589
|
-
Returns:
|
|
597
|
+
Returns: Step output or derivative.
|
|
590
598
|
|
|
591
|
-
###
|
|
599
|
+
### swishActivation
|
|
592
600
|
|
|
593
601
|
```ts
|
|
594
|
-
|
|
602
|
+
swishActivation(
|
|
595
603
|
inputValue: number,
|
|
596
|
-
shouldComputeDerivative: boolean
|
|
604
|
+
shouldComputeDerivative: boolean,
|
|
597
605
|
): number
|
|
598
606
|
```
|
|
599
607
|
|
|
600
|
-
|
|
608
|
+
Swish activation implementation.
|
|
601
609
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
evaluation and derivative lookup without wrapping every implementation in a
|
|
606
|
-
different adapter.
|
|
610
|
+
Swish multiplies the input by a sigmoid gate, so the unit can dampen itself
|
|
611
|
+
smoothly instead of snapping to zero as ReLU does. That makes it a useful
|
|
612
|
+
comparison point when experimenting with smoother hidden-layer behavior.
|
|
607
613
|
|
|
608
|
-
|
|
614
|
+
Parameters:
|
|
615
|
+
- `inputValue` - - Input to evaluate.
|
|
616
|
+
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
609
617
|
|
|
610
|
-
|
|
611
|
-
{@link sigmoidActivation}, and {@link tanhActivation},
|
|
612
|
-
- sparse or piecewise-linear gates such as {@link reluActivation},
|
|
613
|
-
{@link stepActivation}, and {@link hardTanhActivation},
|
|
614
|
-
- shape-specialized functions such as {@link gaussianActivation},
|
|
615
|
-
{@link sinusoidActivation}, and {@link bentIdentityActivation},
|
|
616
|
-
- smoother modern hidden-layer candidates such as {@link softplusActivation},
|
|
617
|
-
{@link swishActivation}, {@link geluActivation}, and
|
|
618
|
-
{@link mishActivation}.
|
|
618
|
+
Returns: Swish output or derivative.
|
|
619
619
|
|
|
620
|
-
|
|
620
|
+
### tanhActivation
|
|
621
621
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
periodic, radial, or sign-like response rather than a general default.
|
|
622
|
+
```ts
|
|
623
|
+
tanhActivation(
|
|
624
|
+
inputValue: number,
|
|
625
|
+
shouldComputeDerivative: boolean,
|
|
626
|
+
): number
|
|
627
|
+
```
|
|
629
628
|
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
629
|
+
Hyperbolic tangent activation implementation.
|
|
630
|
+
|
|
631
|
+
Compared with {@link logisticActivation}, tanh stays bounded while remaining
|
|
632
|
+
zero-centered, which often makes hidden activations easier to interpret when
|
|
633
|
+
positive and negative evidence should balance around zero.
|
|
634
634
|
|
|
635
635
|
Parameters:
|
|
636
|
-
- `inputValue` - - Input to
|
|
637
|
-
- `shouldComputeDerivative` - - Whether to compute the derivative
|
|
636
|
+
- `inputValue` - - Input to evaluate.
|
|
637
|
+
- `shouldComputeDerivative` - - Whether to compute the derivative.
|
|
638
638
|
|
|
639
|
-
Returns:
|
|
639
|
+
Returns: Tanh output or derivative.
|