@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
|
@@ -824,6 +824,15 @@ Removes the connection from the network's `gates` list.
|
|
|
824
824
|
|
|
825
825
|
## architecture/network/network.utils.ts
|
|
826
826
|
|
|
827
|
+
### __trainingInternals
|
|
828
|
+
|
|
829
|
+
Test-only internal helper bundle.
|
|
830
|
+
|
|
831
|
+
This is exported so unit tests can cover edge-cases in the smoothing logic without
|
|
832
|
+
running full end-to-end training loops.
|
|
833
|
+
|
|
834
|
+
Important: this is **not** considered stable public API. It may change between releases.
|
|
835
|
+
|
|
827
836
|
### activate
|
|
828
837
|
|
|
829
838
|
```ts
|
|
@@ -842,66 +851,35 @@ Parameters:
|
|
|
842
851
|
|
|
843
852
|
Returns: Output activation values.
|
|
844
853
|
|
|
845
|
-
###
|
|
846
|
-
|
|
847
|
-
```ts
|
|
848
|
-
gaussianRand(
|
|
849
|
-
rng: () => number,
|
|
850
|
-
): number
|
|
851
|
-
```
|
|
852
|
-
|
|
853
|
-
Produce a normally distributed random sample using the Box-Muller transform.
|
|
854
|
-
|
|
855
|
-
Parameters:
|
|
856
|
-
- `rng` - Pseudo-random source in the interval [0, 1).
|
|
857
|
-
|
|
858
|
-
Returns: Standard normal sample with mean 0 and variance 1.
|
|
859
|
-
|
|
860
|
-
### noTraceActivate
|
|
854
|
+
### activateBatch
|
|
861
855
|
|
|
862
856
|
```ts
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
857
|
+
activateBatch(
|
|
858
|
+
inputs: number[][],
|
|
859
|
+
training: boolean,
|
|
860
|
+
): number[][]
|
|
866
861
|
```
|
|
867
862
|
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
This is the most allocation‑sensitive activation path. Internally it will attempt
|
|
871
|
-
to leverage a compact "fast slab" routine (an optimized, vectorized broadcast over
|
|
872
|
-
contiguous activation buffers) when the Network instance indicates that such a path
|
|
873
|
-
is currently valid. If that attempt fails (for instance because the slab is stale
|
|
874
|
-
after a structural mutation) execution gracefully falls back to a node‑by‑node loop.
|
|
863
|
+
Activate the network over a mini‑batch (array) of input vectors, returning a 2‑D array of outputs.
|
|
875
864
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
3. Try the fast slab path; if it throws, continue with the standard path.
|
|
881
|
-
4. Acquire a pooled output buffer sized to the number of output neurons.
|
|
882
|
-
5. Iterate all nodes in their internal order:
|
|
883
|
-
- Input nodes: directly assign provided input values.
|
|
884
|
-
- Hidden nodes: compute activation via Node.noTraceActivate (no bookkeeping).
|
|
885
|
-
- Output nodes: compute activation and store it (in sequence) inside the
|
|
886
|
-
pooled output buffer.
|
|
887
|
-
6. Copy the pooled buffer into a fresh array (detaches user from the pool) and
|
|
888
|
-
release the pooled buffer back to the pool.
|
|
865
|
+
This helper simply loops, invoking {@link Network.activate} (or its bound variant) for each
|
|
866
|
+
sample. It is intentionally naive: no attempt is made to fuse operations across the batch.
|
|
867
|
+
For very large batch sizes or performance‑critical paths consider implementing a custom
|
|
868
|
+
vectorized backend that exploits SIMD, GPU kernels, or parallel workers.
|
|
889
869
|
|
|
890
|
-
|
|
891
|
-
- Time: O(N + E) where N = number of nodes, E = number of inbound edges processed
|
|
892
|
-
inside each Node.noTraceActivate call (not explicit here but inside the node).
|
|
893
|
-
- Space: O(O) transient (O = number of outputs) due to the pooled output buffer.
|
|
870
|
+
Input validation occurs per row to surface the earliest mismatch with a descriptive index.
|
|
894
871
|
|
|
895
872
|
Parameters:
|
|
896
873
|
- `this` - - Bound Network instance.
|
|
897
|
-
- `
|
|
874
|
+
- `inputs` - - Array of input vectors; each must have length == network.input.
|
|
875
|
+
- `training` - - Whether each activation should keep training traces.
|
|
898
876
|
|
|
899
|
-
Returns:
|
|
877
|
+
Returns: 2‑D array: outputs[i] is the activation result for inputs[i].
|
|
900
878
|
|
|
901
879
|
Example:
|
|
902
880
|
|
|
903
|
-
const
|
|
904
|
-
console.log(
|
|
881
|
+
const batchOut = net.activateBatch([[0,0,1],[1,0,0],[0,1,0]]);
|
|
882
|
+
console.log(batchOut.length); // 3 rows
|
|
905
883
|
|
|
906
884
|
### activateRaw
|
|
907
885
|
|
|
@@ -932,35 +910,94 @@ Example:
|
|
|
932
910
|
|
|
933
911
|
const y = net.activateRaw([0,1,0]);
|
|
934
912
|
|
|
935
|
-
###
|
|
913
|
+
### addNodeBetweenImpl
|
|
936
914
|
|
|
937
915
|
```ts
|
|
938
|
-
|
|
939
|
-
|
|
916
|
+
addNodeBetweenImpl(): void
|
|
917
|
+
```
|
|
918
|
+
|
|
919
|
+
Split one randomly selected connection by inserting a hidden node.
|
|
920
|
+
|
|
921
|
+
This preserves the long-standing public `addNodeBetween()` behavior:
|
|
922
|
+
- it does not opt into `ADD_NODE` deterministic-chain policy,
|
|
923
|
+
- it preserves the original source-edge weight on the first new connection,
|
|
924
|
+
- it uses `1` for the hidden-to-target edge to keep the split easy to reason about.
|
|
925
|
+
|
|
926
|
+
Parameters:
|
|
927
|
+
- `this` - Target network instance.
|
|
928
|
+
|
|
929
|
+
Returns: Nothing.
|
|
930
|
+
|
|
931
|
+
### applyGradientClippingImpl
|
|
932
|
+
|
|
933
|
+
```ts
|
|
934
|
+
applyGradientClippingImpl(
|
|
935
|
+
net: default,
|
|
936
|
+
cfg: GradientClipRuntimeConfig,
|
|
937
|
+
): void
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
Apply gradient clipping to a network using a normalized runtime configuration.
|
|
941
|
+
|
|
942
|
+
This is a small wrapper that forwards to the concrete implementation used by training.
|
|
943
|
+
|
|
944
|
+
Parameters:
|
|
945
|
+
- `net` - - Network instance to update.
|
|
946
|
+
- `cfg` - - Normalized clipping settings.
|
|
947
|
+
|
|
948
|
+
### canUseFastSlab
|
|
949
|
+
|
|
950
|
+
```ts
|
|
951
|
+
canUseFastSlab(
|
|
940
952
|
training: boolean,
|
|
941
|
-
):
|
|
953
|
+
): boolean
|
|
942
954
|
```
|
|
943
955
|
|
|
944
|
-
|
|
956
|
+
Public convenience wrapper exposing fast path eligibility.
|
|
957
|
+
Mirrors `_canUseFastSlab` internal predicate.
|
|
945
958
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
For very large batch sizes or performance‑critical paths consider implementing a custom
|
|
949
|
-
vectorized backend that exploits SIMD, GPU kernels, or parallel workers.
|
|
959
|
+
Parameters:
|
|
960
|
+
- `training` - Whether caller is performing training (disables fast path if true).
|
|
950
961
|
|
|
951
|
-
|
|
962
|
+
Returns: True when slab fast path predicates hold.
|
|
963
|
+
|
|
964
|
+
### clearState
|
|
965
|
+
|
|
966
|
+
```ts
|
|
967
|
+
clearState(): void
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
Clear all node runtime traces and states.
|
|
952
971
|
|
|
953
972
|
Parameters:
|
|
954
|
-
- `this` -
|
|
955
|
-
- `inputs` - - Array of input vectors; each must have length == network.input.
|
|
956
|
-
- `training` - - Whether each activation should keep training traces.
|
|
973
|
+
- `this` - Bound network instance.
|
|
957
974
|
|
|
958
|
-
|
|
975
|
+
### cloneImpl
|
|
959
976
|
|
|
960
|
-
|
|
977
|
+
```ts
|
|
978
|
+
cloneImpl(): default
|
|
979
|
+
```
|
|
961
980
|
|
|
962
|
-
|
|
963
|
-
|
|
981
|
+
Create a deep copy of one network through the verbose JSON round-trip.
|
|
982
|
+
|
|
983
|
+
This keeps cloning behavior aligned with the same versioned payload contract
|
|
984
|
+
used by `toJSON()` and `fromJSON()`, so clone semantics stay stable as the
|
|
985
|
+
serialization chapter evolves.
|
|
986
|
+
|
|
987
|
+
Parameters:
|
|
988
|
+
- `this` - Target network instance.
|
|
989
|
+
|
|
990
|
+
Returns: Deep-cloned network instance.
|
|
991
|
+
|
|
992
|
+
### computeTopoOrder
|
|
993
|
+
|
|
994
|
+
```ts
|
|
995
|
+
computeTopoOrder(): void
|
|
996
|
+
```
|
|
997
|
+
|
|
998
|
+
Compute a topological ordering (Kahn's algorithm) for the current directed acyclic graph.
|
|
999
|
+
If cycles are detected (order shorter than node count) we fall back to raw node order to avoid breaking callers.
|
|
1000
|
+
In non-acyclic mode we simply clear cached order to signal use of sequential node array.
|
|
964
1001
|
|
|
965
1002
|
### connect
|
|
966
1003
|
|
|
@@ -1009,174 +1046,194 @@ Example:
|
|
|
1009
1046
|
|
|
1010
1047
|
const [edge] = net.connect(nodeA, nodeB, 0.5);
|
|
1011
1048
|
|
|
1012
|
-
###
|
|
1049
|
+
### createMLP
|
|
1013
1050
|
|
|
1014
1051
|
```ts
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1052
|
+
createMLP(
|
|
1053
|
+
inputCount: number,
|
|
1054
|
+
hiddenCounts: number[],
|
|
1055
|
+
outputCount: number,
|
|
1056
|
+
): default
|
|
1019
1057
|
```
|
|
1020
1058
|
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
Only a single direct edge is removed because typical graph configurations maintain at most
|
|
1024
|
-
one logical connection between a given pair of nodes (excluding potential future multi‑edge
|
|
1025
|
-
semantics). If the target edge is gated we first call {@link Network.ungate} to maintain
|
|
1026
|
-
gating invariants (ensuring the gater node's internal gate list remains consistent).
|
|
1027
|
-
|
|
1028
|
-
Algorithm outline:
|
|
1029
|
-
1. Choose the correct list (selfconns vs connections) based on whether from === to.
|
|
1030
|
-
2. Linear scan to find the first edge with matching endpoints.
|
|
1031
|
-
3. If gated, ungate to detach gater bookkeeping.
|
|
1032
|
-
4. Splice the edge out; exit loop (only one expected).
|
|
1033
|
-
5. Delegate per‑node cleanup via from.disconnect(to) (clears reverse references, traces, etc.).
|
|
1034
|
-
6. Mark structural caches dirty for lazy recomputation.
|
|
1035
|
-
|
|
1036
|
-
Complexity:
|
|
1037
|
-
- Time: O(m) where m is length of the searched list (connections or selfconns).
|
|
1038
|
-
- Space: O(1) extra.
|
|
1039
|
-
|
|
1040
|
-
Idempotence: If no such edge exists we still perform node-level disconnect and flag caches dirty –
|
|
1041
|
-
this conservative approach simplifies callers (they need not pre‑check existence).
|
|
1059
|
+
Build a strictly layered and fully connected MLP network.
|
|
1042
1060
|
|
|
1043
1061
|
Parameters:
|
|
1044
|
-
- `this` -
|
|
1045
|
-
- `
|
|
1046
|
-
- `
|
|
1047
|
-
|
|
1048
|
-
Example:
|
|
1062
|
+
- `this` - Network constructor.
|
|
1063
|
+
- `inputCount` - Number of input nodes.
|
|
1064
|
+
- `hiddenCounts` - Hidden-layer node counts.
|
|
1065
|
+
- `outputCount` - Number of output nodes.
|
|
1049
1066
|
|
|
1050
|
-
|
|
1067
|
+
Returns: Newly created MLP network.
|
|
1051
1068
|
|
|
1052
|
-
###
|
|
1069
|
+
### crossOver
|
|
1053
1070
|
|
|
1054
1071
|
```ts
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1072
|
+
crossOver(
|
|
1073
|
+
parentNetwork1: default,
|
|
1074
|
+
parentNetwork2: default,
|
|
1075
|
+
equal: boolean,
|
|
1076
|
+
): default
|
|
1058
1077
|
```
|
|
1059
1078
|
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
Overview:
|
|
1063
|
-
- Use this before training, mutation, or stochastic operations when you need repeatable runs.
|
|
1064
|
-
- The same seed and operation order produce the same random sequence and reproducible outcomes.
|
|
1065
|
-
- This method delegates to setup utilities so behavior stays centralized across deterministic APIs.
|
|
1066
|
-
|
|
1067
|
-
Parameters:
|
|
1068
|
-
- `this` - - Bound network instance whose RNG state is being initialized.
|
|
1069
|
-
- `seed` - - Seed value used to derive deterministic RNG state (low 32 bits are applied).
|
|
1070
|
-
|
|
1071
|
-
Returns: Nothing.
|
|
1079
|
+
NEAT-inspired crossover between two parent networks producing a single offspring.
|
|
1072
1080
|
|
|
1073
|
-
|
|
1081
|
+
Conceptual model:
|
|
1082
|
+
- A "gene" corresponds to either a node choice at a structural index or a connection
|
|
1083
|
+
keyed by innovation identity.
|
|
1084
|
+
- The offspring is assembled in two phases: node assignment first, then connection
|
|
1085
|
+
materialization constrained by available offspring endpoints.
|
|
1086
|
+
- Fitness controls inheritance pressure unless `equal` is enabled, in which case both
|
|
1087
|
+
parents contribute symmetrically where possible.
|
|
1074
1088
|
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1089
|
+
Simplifications relative to canonical NEAT:
|
|
1090
|
+
- Innovation ID is synthesized from (from.index, to.index) via Connection.innovationID instead of
|
|
1091
|
+
maintaining a global innovation number per mutation event.
|
|
1092
|
+
- Node alignment relies on current index ordering. This is weaker than historical innovation
|
|
1093
|
+
tracking, but adequate for many lightweight evolutionary experiments.
|
|
1078
1094
|
|
|
1079
|
-
|
|
1095
|
+
Compatibility assumptions:
|
|
1096
|
+
- Both parents must expose identical input/output counts.
|
|
1097
|
+
- Parent node index ordering should represent comparable structural positions.
|
|
1098
|
+
- Parent fitness scores are interpreted by setup helpers when deciding fitter-parent inheritance.
|
|
1080
1099
|
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1100
|
+
High-level algorithm:
|
|
1101
|
+
1. Validate that parents have identical I/O dimensionality (required for compatibility).
|
|
1102
|
+
2. Decide offspring node array length:
|
|
1103
|
+
- If equal flag set or scores tied: random length in [minNodes, maxNodes].
|
|
1104
|
+
- Else: length of fitter parent.
|
|
1105
|
+
3. For each index up to chosen size, pick a node gene from parents per rules:
|
|
1106
|
+
- Input indices: always from parent1 (assumes identical input interface).
|
|
1107
|
+
- Output indices (aligned from end): randomly choose if both present else take existing.
|
|
1108
|
+
- Hidden indices: if both present pick randomly; else inherit from fitter (or either if equal).
|
|
1109
|
+
4. Reindex offspring nodes.
|
|
1110
|
+
5. Collect connections (standard + self) from each parent into maps keyed by innovationID capturing
|
|
1111
|
+
weight, enabled flag, and gater index.
|
|
1112
|
+
6. For overlapping genes (present in both), randomly choose one; if either disabled apply optional
|
|
1113
|
+
re-enable probability (reenableProb) to possibly re-activate.
|
|
1114
|
+
7. For disjoint/excess genes, inherit only from fitter parent (or both if equal flag set / scores tied).
|
|
1115
|
+
8. Materialize selected connection genes if their endpoints both exist in offspring; set weight & enabled state.
|
|
1116
|
+
9. Reattach gating if gater node exists in offspring.
|
|
1086
1117
|
|
|
1087
|
-
|
|
1088
|
-
-
|
|
1089
|
-
-
|
|
1090
|
-
- This is useful when comparing alternate algorithm branches from an identical random timeline.
|
|
1118
|
+
Enabled reactivation probability:
|
|
1119
|
+
- Parents may carry disabled connections; offspring may re-enable them with a probability derived
|
|
1120
|
+
from parent-specific _reenableProb (or default 0.25). This allows dormant structures to resurface.
|
|
1091
1121
|
|
|
1092
1122
|
Parameters:
|
|
1093
|
-
- `
|
|
1123
|
+
- `parentNetwork1` - - First parent (ties resolved in its favor when scores equal and equal=false for some cases).
|
|
1124
|
+
- `parentNetwork2` - - Second parent.
|
|
1125
|
+
- `equal` - - Force symmetric treatment regardless of fitness (true => node count random between sizes and both parents equally contribute disjoint genes).
|
|
1094
1126
|
|
|
1095
|
-
Returns:
|
|
1127
|
+
Returns: Offspring network instance.
|
|
1096
1128
|
|
|
1097
1129
|
Example:
|
|
1098
1130
|
|
|
1099
1131
|
```ts
|
|
1100
|
-
const
|
|
1132
|
+
const offspring = crossOver(parentA, parentB);
|
|
1133
|
+
offspring.mutate();
|
|
1101
1134
|
```
|
|
1102
1135
|
|
|
1103
|
-
###
|
|
1136
|
+
### describeArchitecture
|
|
1104
1137
|
|
|
1105
1138
|
```ts
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
):
|
|
1139
|
+
describeArchitecture(
|
|
1140
|
+
network: default,
|
|
1141
|
+
): NetworkArchitectureDescriptor
|
|
1109
1142
|
```
|
|
1110
1143
|
|
|
1111
|
-
|
|
1144
|
+
Describes network architecture for diagnostics, telemetry, and UI rendering.
|
|
1112
1145
|
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1146
|
+
This function prefers factual sources over heuristics so downstream tooling
|
|
1147
|
+
can rely on the descriptor while still receiving useful output for partially
|
|
1148
|
+
specified runtime graphs.
|
|
1149
|
+
|
|
1150
|
+
Resolution priority is intentionally explicit:
|
|
1151
|
+
1) node `layer` metadata (factual when present)
|
|
1152
|
+
2) graph-derived feed-forward depth layering (factual for acyclic graphs)
|
|
1153
|
+
3) hidden-node count fallback (heuristic inference)
|
|
1117
1154
|
|
|
1118
1155
|
Parameters:
|
|
1119
|
-
- `
|
|
1120
|
-
- `fn` - - Deterministic RNG function to install (expected to return values in `[0, 1)`).
|
|
1156
|
+
- `network` - - Runtime network instance.
|
|
1121
1157
|
|
|
1122
|
-
Returns:
|
|
1158
|
+
Returns: Stable architecture descriptor.
|
|
1123
1159
|
|
|
1124
1160
|
Example:
|
|
1125
1161
|
|
|
1126
1162
|
```ts
|
|
1127
|
-
network
|
|
1163
|
+
const descriptor = describeArchitecture(network);
|
|
1164
|
+
// descriptor.hiddenLayerSizes -> [8, 4]
|
|
1165
|
+
// descriptor.source -> 'layer-metadata' | 'graph-topology' | 'inferred'
|
|
1128
1166
|
```
|
|
1129
1167
|
|
|
1130
|
-
###
|
|
1168
|
+
### deserialize
|
|
1131
1169
|
|
|
1132
1170
|
```ts
|
|
1133
|
-
|
|
1171
|
+
deserialize(
|
|
1172
|
+
data: CompactSerializedNetworkTuple,
|
|
1173
|
+
inputSize: number | undefined,
|
|
1174
|
+
outputSize: number | undefined,
|
|
1175
|
+
): default
|
|
1134
1176
|
```
|
|
1135
1177
|
|
|
1136
|
-
|
|
1178
|
+
Rebuilds a network instance from compact tuple form.
|
|
1137
1179
|
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
- The value can be persisted and later reapplied through `setRNGState`.
|
|
1141
|
-
- This is commonly used by tests that assert deterministic continuity across operations.
|
|
1180
|
+
Use this importer for compact payloads produced by `serialize`.
|
|
1181
|
+
Optional `inputSize` and `outputSize` let callers enforce shape overrides at import time.
|
|
1142
1182
|
|
|
1143
1183
|
Parameters:
|
|
1144
|
-
- `
|
|
1184
|
+
- `data` - - Compact tuple payload.
|
|
1185
|
+
- `inputSize` - - Optional input-size override that takes precedence over serialized input.
|
|
1186
|
+
- `outputSize` - - Optional output-size override that takes precedence over serialized output.
|
|
1145
1187
|
|
|
1146
|
-
Returns:
|
|
1188
|
+
Returns: Reconstructed network instance.
|
|
1147
1189
|
|
|
1148
1190
|
Example:
|
|
1149
1191
|
|
|
1150
1192
|
```ts
|
|
1151
|
-
|
|
1193
|
+
import { deserialize } from './network.serialize.utils';
|
|
1194
|
+
|
|
1195
|
+
const rebuiltNetwork = deserialize(compactTuple, 2, 1);
|
|
1152
1196
|
```
|
|
1153
1197
|
|
|
1154
|
-
###
|
|
1198
|
+
### disconnect
|
|
1155
1199
|
|
|
1156
1200
|
```ts
|
|
1157
|
-
|
|
1158
|
-
|
|
1201
|
+
disconnect(
|
|
1202
|
+
from: default,
|
|
1203
|
+
to: default,
|
|
1159
1204
|
): void
|
|
1160
1205
|
```
|
|
1161
1206
|
|
|
1162
|
-
|
|
1207
|
+
Remove (at most) one directed connection from source 'from' to target 'to'.
|
|
1163
1208
|
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1209
|
+
Only a single direct edge is removed because typical graph configurations maintain at most
|
|
1210
|
+
one logical connection between a given pair of nodes (excluding potential future multi‑edge
|
|
1211
|
+
semantics). If the target edge is gated we first call {@link Network.ungate} to maintain
|
|
1212
|
+
gating invariants (ensuring the gater node's internal gate list remains consistent).
|
|
1168
1213
|
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1214
|
+
Algorithm outline:
|
|
1215
|
+
1. Choose the correct list (selfconns vs connections) based on whether from === to.
|
|
1216
|
+
2. Linear scan to find the first edge with matching endpoints.
|
|
1217
|
+
3. If gated, ungate to detach gater bookkeeping.
|
|
1218
|
+
4. Splice the edge out; exit loop (only one expected).
|
|
1219
|
+
5. Delegate per‑node cleanup via from.disconnect(to) (clears reverse references, traces, etc.).
|
|
1220
|
+
6. Mark structural caches dirty for lazy recomputation.
|
|
1172
1221
|
|
|
1173
|
-
|
|
1222
|
+
Complexity:
|
|
1223
|
+
- Time: O(m) where m is length of the searched list (connections or selfconns).
|
|
1224
|
+
- Space: O(1) extra.
|
|
1225
|
+
|
|
1226
|
+
Idempotence: If no such edge exists we still perform node-level disconnect and flag caches dirty –
|
|
1227
|
+
this conservative approach simplifies callers (they need not pre‑check existence).
|
|
1228
|
+
|
|
1229
|
+
Parameters:
|
|
1230
|
+
- `this` - - Bound Network instance.
|
|
1231
|
+
- `from` - - Source node.
|
|
1232
|
+
- `to` - - Target node.
|
|
1174
1233
|
|
|
1175
1234
|
Example:
|
|
1176
1235
|
|
|
1177
|
-
|
|
1178
|
-
network.setRNGState(savedState);
|
|
1179
|
-
```
|
|
1236
|
+
net.disconnect(nodeA, nodeB);
|
|
1180
1237
|
|
|
1181
1238
|
### evolveNetwork
|
|
1182
1239
|
|
|
@@ -1219,6 +1276,57 @@ const summary = await network.evolve(trainingSet, {
|
|
|
1219
1276
|
console.log(summary.error, summary.iterations, summary.time);
|
|
1220
1277
|
```
|
|
1221
1278
|
|
|
1279
|
+
### fastSlabActivate
|
|
1280
|
+
|
|
1281
|
+
```ts
|
|
1282
|
+
fastSlabActivate(
|
|
1283
|
+
input: number[],
|
|
1284
|
+
): number[]
|
|
1285
|
+
```
|
|
1286
|
+
|
|
1287
|
+
High‑performance forward pass using packed slabs + CSR adjacency.
|
|
1288
|
+
|
|
1289
|
+
Fallback Conditions (auto‑detected):
|
|
1290
|
+
- Missing slabs / adjacency structures.
|
|
1291
|
+
- Topology/gating/stochastic predicates fail (see `_canUseFastSlab`).
|
|
1292
|
+
- Gating present, when applicable (explicit guard).
|
|
1293
|
+
|
|
1294
|
+
Implementation Notes:
|
|
1295
|
+
- Reuses internal activation/state buffers to reduce per‑step allocation churn.
|
|
1296
|
+
- Applies gain multiplication if optional gain slab exists.
|
|
1297
|
+
- Assumes acyclic graph; topological order recomputed on demand if marked dirty.
|
|
1298
|
+
|
|
1299
|
+
Parameters:
|
|
1300
|
+
- `input` - Input vector (length must equal `network.input`).
|
|
1301
|
+
|
|
1302
|
+
Returns: Output activations (detached plain array) of length `network.output`.
|
|
1303
|
+
|
|
1304
|
+
### fromJSONImpl
|
|
1305
|
+
|
|
1306
|
+
```ts
|
|
1307
|
+
fromJSONImpl(
|
|
1308
|
+
json: NetworkJSON,
|
|
1309
|
+
): default
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
Reconstructs a network instance from the verbose JSON payload.
|
|
1313
|
+
|
|
1314
|
+
This importer validates payload shape, restores dropout and topology, and then rebuilds
|
|
1315
|
+
connections, gating relationships, and optional enabled flags.
|
|
1316
|
+
|
|
1317
|
+
Parameters:
|
|
1318
|
+
- `json` - - Verbose JSON payload.
|
|
1319
|
+
|
|
1320
|
+
Returns: Reconstructed network instance.
|
|
1321
|
+
|
|
1322
|
+
Example:
|
|
1323
|
+
|
|
1324
|
+
```ts
|
|
1325
|
+
import { fromJSONImpl } from './network.serialize.utils';
|
|
1326
|
+
|
|
1327
|
+
const rebuiltNetwork = fromJSONImpl(snapshotJson);
|
|
1328
|
+
```
|
|
1329
|
+
|
|
1222
1330
|
### gate
|
|
1223
1331
|
|
|
1224
1332
|
```ts
|
|
@@ -1242,110 +1350,152 @@ Parameters:
|
|
|
1242
1350
|
- `node` - - Candidate gater node (must belong to network).
|
|
1243
1351
|
- `connection` - - Connection to gate.
|
|
1244
1352
|
|
|
1245
|
-
###
|
|
1353
|
+
### gaussianRand
|
|
1246
1354
|
|
|
1247
1355
|
```ts
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
):
|
|
1356
|
+
gaussianRand(
|
|
1357
|
+
rng: () => number,
|
|
1358
|
+
): number
|
|
1251
1359
|
```
|
|
1252
1360
|
|
|
1253
|
-
|
|
1361
|
+
Produce a normally distributed random sample using the Box-Muller transform.
|
|
1254
1362
|
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
without modulation by a gater activation.
|
|
1363
|
+
Parameters:
|
|
1364
|
+
- `rng` - Pseudo-random source in the interval [0, 1).
|
|
1258
1365
|
|
|
1259
|
-
|
|
1366
|
+
Returns: Standard normal sample with mean 0 and variance 1.
|
|
1367
|
+
|
|
1368
|
+
### generateStandalone
|
|
1369
|
+
|
|
1370
|
+
```ts
|
|
1371
|
+
generateStandalone(
|
|
1372
|
+
net: default,
|
|
1373
|
+
): string
|
|
1374
|
+
```
|
|
1375
|
+
|
|
1376
|
+
Generate a standalone JavaScript source string that returns an `activate(input:number[])` function.
|
|
1377
|
+
|
|
1378
|
+
Implementation Steps:
|
|
1379
|
+
1. Validate presence of output nodes (must produce something observable).
|
|
1380
|
+
2. Assign stable sequential indices to nodes (used as array offsets in generated code).
|
|
1381
|
+
3. Collect initial activation/state values into typed array initializers for warm starting.
|
|
1382
|
+
4. For each non-input node, build a line computing S[i] (pre-activation sum with bias) and A[i]
|
|
1383
|
+
(post-activation output). Gating multiplies activation by gate activations; self-connection adds
|
|
1384
|
+
recurrent term S[i] * weight before activation.
|
|
1385
|
+
5. De-duplicate activation functions: each unique squash name is emitted once; references become
|
|
1386
|
+
indices into array F of function references for compactness.
|
|
1387
|
+
6. Emit an IIFE producing the activate function with internal arrays A (activations) and S (states).
|
|
1260
1388
|
|
|
1261
1389
|
Parameters:
|
|
1262
|
-
- `
|
|
1263
|
-
- `connection` - - Connection to ungate.
|
|
1390
|
+
- `net` - Network instance to snapshot.
|
|
1264
1391
|
|
|
1265
|
-
|
|
1392
|
+
Returns: Source string (ES5-compatible) – safe to eval in sandbox to obtain activate function.
|
|
1393
|
+
|
|
1394
|
+
### getConnectionSlab
|
|
1266
1395
|
|
|
1267
1396
|
```ts
|
|
1268
|
-
|
|
1269
|
-
parentNetwork1: default,
|
|
1270
|
-
parentNetwork2: default,
|
|
1271
|
-
equal: boolean,
|
|
1272
|
-
): default
|
|
1397
|
+
getConnectionSlab(): ConnectionSlabView
|
|
1273
1398
|
```
|
|
1274
1399
|
|
|
1275
|
-
|
|
1400
|
+
Obtain (and lazily rebuild if dirty) the current packed SoA view of connections.
|
|
1276
1401
|
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
- The offspring is assembled in two phases: node assignment first, then connection
|
|
1281
|
-
materialization constrained by available offspring endpoints.
|
|
1282
|
-
- Fitness controls inheritance pressure unless `equal` is enabled, in which case both
|
|
1283
|
-
parents contribute symmetrically where possible.
|
|
1402
|
+
Gain Omission: If the internal gain slab is absent (all gains neutral) a synthetic
|
|
1403
|
+
neutral array is created and returned (NOT retained) to keep external educational
|
|
1404
|
+
tooling branch‑free while preserving omission memory savings internally.
|
|
1284
1405
|
|
|
1285
|
-
|
|
1286
|
-
- Innovation ID is synthesized from (from.index, to.index) via Connection.innovationID instead of
|
|
1287
|
-
maintaining a global innovation number per mutation event.
|
|
1288
|
-
- Node alignment relies on current index ordering. This is weaker than historical innovation
|
|
1289
|
-
tracking, but adequate for many lightweight evolutionary experiments.
|
|
1406
|
+
Returns: Read‑only style view (do not mutate) containing typed arrays + metadata.
|
|
1290
1407
|
|
|
1291
|
-
|
|
1292
|
-
- Both parents must expose identical input/output counts.
|
|
1293
|
-
- Parent node index ordering should represent comparable structural positions.
|
|
1294
|
-
- Parent fitness scores are interpreted by setup helpers when deciding fitter-parent inheritance.
|
|
1408
|
+
### getCurrentSparsity
|
|
1295
1409
|
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
- If equal flag set or scores tied: random length in [minNodes, maxNodes].
|
|
1300
|
-
- Else: length of fitter parent.
|
|
1301
|
-
3. For each index up to chosen size, pick a node gene from parents per rules:
|
|
1302
|
-
- Input indices: always from parent1 (assumes identical input interface).
|
|
1303
|
-
- Output indices (aligned from end): randomly choose if both present else take existing.
|
|
1304
|
-
- Hidden indices: if both present pick randomly; else inherit from fitter (or either if equal).
|
|
1305
|
-
4. Reindex offspring nodes.
|
|
1306
|
-
5. Collect connections (standard + self) from each parent into maps keyed by innovationID capturing
|
|
1307
|
-
weight, enabled flag, and gater index.
|
|
1308
|
-
6. For overlapping genes (present in both), randomly choose one; if either disabled apply optional
|
|
1309
|
-
re-enable probability (reenableProb) to possibly re-activate.
|
|
1310
|
-
7. For disjoint/excess genes, inherit only from fitter parent (or both if equal flag set / scores tied).
|
|
1311
|
-
8. Materialize selected connection genes if their endpoints both exist in offspring; set weight & enabled state.
|
|
1312
|
-
9. Reattach gating if gater node exists in offspring.
|
|
1410
|
+
```ts
|
|
1411
|
+
getCurrentSparsity(): number
|
|
1412
|
+
```
|
|
1313
1413
|
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1414
|
+
Current sparsity fraction relative to the training-time pruning baseline.
|
|
1415
|
+
|
|
1416
|
+
Returns: Current sparsity in the [0,1] range when baseline is available.
|
|
1417
|
+
|
|
1418
|
+
### getRegularizationStats
|
|
1419
|
+
|
|
1420
|
+
```ts
|
|
1421
|
+
getRegularizationStats(): Record<string, unknown> | null
|
|
1422
|
+
```
|
|
1423
|
+
|
|
1424
|
+
Obtain the last recorded regularization / stochastic statistics snapshot.
|
|
1425
|
+
|
|
1426
|
+
Returns a defensive deep copy so callers can inspect metrics without risking mutation of the
|
|
1427
|
+
internal `_lastStats` object maintained by the training loop (e.g., during pruning, dropout, or
|
|
1428
|
+
noise scheduling updates).
|
|
1429
|
+
|
|
1430
|
+
Returns: A deep-cloned stats object or null if no stats have been recorded yet.
|
|
1431
|
+
|
|
1432
|
+
### getRNGState
|
|
1433
|
+
|
|
1434
|
+
```ts
|
|
1435
|
+
getRNGState(): number | undefined
|
|
1436
|
+
```
|
|
1437
|
+
|
|
1438
|
+
Returns the current deterministic RNG numeric state, when available.
|
|
1439
|
+
|
|
1440
|
+
Overview:
|
|
1441
|
+
- Use this for lightweight checkpointing when full lifecycle snapshots are unnecessary.
|
|
1442
|
+
- The value can be persisted and later reapplied through `setRNGState`.
|
|
1443
|
+
- This is commonly used by tests that assert deterministic continuity across operations.
|
|
1317
1444
|
|
|
1318
1445
|
Parameters:
|
|
1319
|
-
- `
|
|
1320
|
-
- `parentNetwork2` - - Second parent.
|
|
1321
|
-
- `equal` - - Force symmetric treatment regardless of fitness (true => node count random between sizes and both parents equally contribute disjoint genes).
|
|
1446
|
+
- `this` - - Bound network instance queried for deterministic RNG numeric state.
|
|
1322
1447
|
|
|
1323
|
-
Returns:
|
|
1448
|
+
Returns: Numeric RNG state value, or `undefined` when no deterministic state exists yet.
|
|
1324
1449
|
|
|
1325
1450
|
Example:
|
|
1326
1451
|
|
|
1327
1452
|
```ts
|
|
1328
|
-
const
|
|
1329
|
-
offspring.mutate();
|
|
1453
|
+
const state = network.getRNGState();
|
|
1330
1454
|
```
|
|
1331
1455
|
|
|
1332
|
-
###
|
|
1456
|
+
### getSlabAllocationStats
|
|
1333
1457
|
|
|
1334
1458
|
```ts
|
|
1335
|
-
|
|
1459
|
+
getSlabAllocationStats(): { pool: { [x: string]: PoolKeyMetrics; }; fresh: number; pooled: number; }
|
|
1336
1460
|
```
|
|
1337
1461
|
|
|
1338
|
-
|
|
1462
|
+
Allocation statistics snapshot for slab typed arrays.
|
|
1339
1463
|
|
|
1340
|
-
|
|
1341
|
-
-
|
|
1342
|
-
-
|
|
1343
|
-
|
|
1464
|
+
Includes:
|
|
1465
|
+
- fresh: number of newly constructed typed arrays since process start / metrics reset.
|
|
1466
|
+
- pooled: number of arrays served from the pool.
|
|
1467
|
+
- pool: per‑key metrics (created, reused, maxRetained) for educational inspection.
|
|
1344
1468
|
|
|
1345
|
-
|
|
1346
|
-
- `this` - Target network instance.
|
|
1469
|
+
NOTE: Stats are cumulative (not auto‑reset); callers may diff successive snapshots.
|
|
1347
1470
|
|
|
1348
|
-
Returns:
|
|
1471
|
+
Returns: Plain object copy (safe to serialize) of current allocator counters.
|
|
1472
|
+
|
|
1473
|
+
### hasPath
|
|
1474
|
+
|
|
1475
|
+
```ts
|
|
1476
|
+
hasPath(
|
|
1477
|
+
from: default,
|
|
1478
|
+
to: default,
|
|
1479
|
+
): boolean
|
|
1480
|
+
```
|
|
1481
|
+
|
|
1482
|
+
Depth-first reachability test (avoids infinite loops via visited set).
|
|
1483
|
+
|
|
1484
|
+
### maybePrune
|
|
1485
|
+
|
|
1486
|
+
```ts
|
|
1487
|
+
maybePrune(
|
|
1488
|
+
iteration: number,
|
|
1489
|
+
): void
|
|
1490
|
+
```
|
|
1491
|
+
|
|
1492
|
+
Perform scheduled pruning at a given training iteration if conditions are met.
|
|
1493
|
+
|
|
1494
|
+
Scheduling fields (cfg): start, end, frequency, targetSparsity, method ('magnitude' | 'snip'), regrowFraction.
|
|
1495
|
+
The target sparsity ramps linearly from 0 at start to cfg.targetSparsity at end.
|
|
1496
|
+
|
|
1497
|
+
Parameters:
|
|
1498
|
+
- `iteration` - Current (0-based or 1-based) training iteration counter used for scheduling.
|
|
1349
1499
|
|
|
1350
1500
|
### mutateImpl
|
|
1351
1501
|
|
|
@@ -1380,21 +1530,75 @@ network.mutate('ADD_NODE');
|
|
|
1380
1530
|
network.mutate({ name: 'MOD_WEIGHT', min: -0.1, max: 0.1 });
|
|
1381
1531
|
```
|
|
1382
1532
|
|
|
1383
|
-
###
|
|
1533
|
+
### noTraceActivate
|
|
1384
1534
|
|
|
1385
1535
|
```ts
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
):
|
|
1536
|
+
noTraceActivate(
|
|
1537
|
+
input: number[],
|
|
1538
|
+
): number[]
|
|
1389
1539
|
```
|
|
1390
1540
|
|
|
1391
|
-
Perform
|
|
1541
|
+
Perform a forward pass without creating or updating training / gradient traces.
|
|
1392
1542
|
|
|
1393
|
-
|
|
1394
|
-
|
|
1543
|
+
This is the most allocation‑sensitive activation path. Internally it will attempt
|
|
1544
|
+
to leverage a compact "fast slab" routine (an optimized, vectorized broadcast over
|
|
1545
|
+
contiguous activation buffers) when the Network instance indicates that such a path
|
|
1546
|
+
is currently valid. If that attempt fails (for instance because the slab is stale
|
|
1547
|
+
after a structural mutation) execution gracefully falls back to a node‑by‑node loop.
|
|
1548
|
+
|
|
1549
|
+
Algorithm outline:
|
|
1550
|
+
1. (Optional) Refresh cached topological order if the network enforces acyclicity
|
|
1551
|
+
and a structural change marked the order as dirty.
|
|
1552
|
+
2. Validate the input dimensionality.
|
|
1553
|
+
3. Try the fast slab path; if it throws, continue with the standard path.
|
|
1554
|
+
4. Acquire a pooled output buffer sized to the number of output neurons.
|
|
1555
|
+
5. Iterate all nodes in their internal order:
|
|
1556
|
+
- Input nodes: directly assign provided input values.
|
|
1557
|
+
- Hidden nodes: compute activation via Node.noTraceActivate (no bookkeeping).
|
|
1558
|
+
- Output nodes: compute activation and store it (in sequence) inside the
|
|
1559
|
+
pooled output buffer.
|
|
1560
|
+
6. Copy the pooled buffer into a fresh array (detaches user from the pool) and
|
|
1561
|
+
release the pooled buffer back to the pool.
|
|
1562
|
+
|
|
1563
|
+
Complexity considerations:
|
|
1564
|
+
- Time: O(N + E) where N = number of nodes, E = number of inbound edges processed
|
|
1565
|
+
inside each Node.noTraceActivate call (not explicit here but inside the node).
|
|
1566
|
+
- Space: O(O) transient (O = number of outputs) due to the pooled output buffer.
|
|
1395
1567
|
|
|
1396
1568
|
Parameters:
|
|
1397
|
-
- `
|
|
1569
|
+
- `this` - - Bound Network instance.
|
|
1570
|
+
- `input` - - Flat numeric vector whose length must equal network.input.
|
|
1571
|
+
|
|
1572
|
+
Returns: Array of output neuron activations (length == network.output).
|
|
1573
|
+
|
|
1574
|
+
Example:
|
|
1575
|
+
|
|
1576
|
+
const out = net.noTraceActivate([0.1, 0.2, 0.3]);
|
|
1577
|
+
console.log(out); // => e.g. [0.5123, 0.0441]
|
|
1578
|
+
|
|
1579
|
+
### propagate
|
|
1580
|
+
|
|
1581
|
+
```ts
|
|
1582
|
+
propagate(
|
|
1583
|
+
rate: number,
|
|
1584
|
+
momentum: number,
|
|
1585
|
+
update: boolean,
|
|
1586
|
+
target: number[],
|
|
1587
|
+
regularization: number,
|
|
1588
|
+
costDerivative: CostDerivative | undefined,
|
|
1589
|
+
): void
|
|
1590
|
+
```
|
|
1591
|
+
|
|
1592
|
+
Propagate output and hidden errors backward through the network.
|
|
1593
|
+
|
|
1594
|
+
Parameters:
|
|
1595
|
+
- `this` - Bound network instance.
|
|
1596
|
+
- `rate` - Learning rate.
|
|
1597
|
+
- `momentum` - Momentum factor.
|
|
1598
|
+
- `update` - Whether to apply updates immediately.
|
|
1599
|
+
- `target` - Output target values.
|
|
1600
|
+
- `regularization` - L2 regularization factor.
|
|
1601
|
+
- `costDerivative` - Optional output-node derivative override.
|
|
1398
1602
|
|
|
1399
1603
|
### pruneToSparsity
|
|
1400
1604
|
|
|
@@ -1415,496 +1619,309 @@ Parameters:
|
|
|
1415
1619
|
|
|
1416
1620
|
Returns: Nothing.
|
|
1417
1621
|
|
|
1418
|
-
###
|
|
1622
|
+
### rebuildConnections
|
|
1419
1623
|
|
|
1420
1624
|
```ts
|
|
1421
|
-
|
|
1625
|
+
rebuildConnections(
|
|
1626
|
+
networkInstance: default,
|
|
1627
|
+
): void
|
|
1422
1628
|
```
|
|
1423
1629
|
|
|
1424
|
-
|
|
1630
|
+
Rebuild the canonical connection array from per-node outgoing lists.
|
|
1425
1631
|
|
|
1426
|
-
|
|
1632
|
+
Parameters:
|
|
1633
|
+
- `networkInstance` - Target network.
|
|
1427
1634
|
|
|
1428
|
-
###
|
|
1635
|
+
### rebuildConnectionSlab
|
|
1429
1636
|
|
|
1430
1637
|
```ts
|
|
1431
|
-
|
|
1432
|
-
|
|
1638
|
+
rebuildConnectionSlab(
|
|
1639
|
+
force: boolean,
|
|
1433
1640
|
): void
|
|
1434
1641
|
```
|
|
1435
1642
|
|
|
1436
|
-
|
|
1643
|
+
Build (or refresh) the packed connection slabs for the network synchronously.
|
|
1644
|
+
|
|
1645
|
+
ACTIONS
|
|
1646
|
+
-------
|
|
1647
|
+
1. Optionally reindex nodes if structural mutations invalidated indices.
|
|
1648
|
+
2. Grow (geometric) or reuse existing typed arrays to ensure capacity >= active connections.
|
|
1649
|
+
3. Populate the logical slice [0, connectionCount) with weight/from/to/flag data.
|
|
1650
|
+
4. Lazily allocate gain & plastic slabs only on first non‑neutral / plastic encounter; omit otherwise.
|
|
1651
|
+
5. Release previously allocated optional slabs when they revert to neutral / unused (omission optimization).
|
|
1652
|
+
6. Update internal bookkeeping: logical count, dirty flags, version counter.
|
|
1653
|
+
|
|
1654
|
+
PERFORMANCE
|
|
1655
|
+
-----------
|
|
1656
|
+
O(C) over active connections with amortized allocation cost due to geometric growth.
|
|
1437
1657
|
|
|
1438
1658
|
Parameters:
|
|
1439
|
-
- `
|
|
1440
|
-
- `node` - The node object to remove (must be of type 'hidden').
|
|
1659
|
+
- `force` - When true forces rebuild even if network not marked dirty (useful for timing tests).
|
|
1441
1660
|
|
|
1442
|
-
###
|
|
1661
|
+
### rebuildConnectionSlabAsync
|
|
1443
1662
|
|
|
1444
1663
|
```ts
|
|
1445
|
-
|
|
1664
|
+
rebuildConnectionSlabAsync(
|
|
1665
|
+
chunkSize: number,
|
|
1666
|
+
): Promise<void>
|
|
1446
1667
|
```
|
|
1447
1668
|
|
|
1448
|
-
|
|
1669
|
+
Cooperative asynchronous slab rebuild (Browser only).
|
|
1449
1670
|
|
|
1450
|
-
|
|
1451
|
-
|
|
1671
|
+
Strategy:
|
|
1672
|
+
- Perform capacity decision + allocation up front (mirrors sync path).
|
|
1673
|
+
- Populate connection data in microtask slices (yield via resolved Promise) to avoid long main‑thread stalls.
|
|
1674
|
+
- Adaptive slice sizing for very large graphs if `config.browserSlabChunkTargetMs` set.
|
|
1675
|
+
|
|
1676
|
+
Metrics: Increments `_slabAsyncBuilds` for observability.
|
|
1677
|
+
Fallback: On Node (no `window`) defers to synchronous rebuild for simplicity.
|
|
1452
1678
|
|
|
1453
1679
|
Parameters:
|
|
1454
|
-
- `
|
|
1680
|
+
- `chunkSize` - Initial maximum connections per slice (may be reduced adaptively for huge graphs).
|
|
1455
1681
|
|
|
1456
|
-
Returns:
|
|
1682
|
+
Returns: Promise resolving once rebuild completes.
|
|
1457
1683
|
|
|
1458
|
-
|
|
1684
|
+
### removeNode
|
|
1459
1685
|
|
|
1460
1686
|
```ts
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
const sourceNetwork = new Network(2, 1);
|
|
1465
|
-
const compactTuple = serialize.call(sourceNetwork);
|
|
1466
|
-
const rebuiltNetwork = deserialize(compactTuple);
|
|
1687
|
+
removeNode(
|
|
1688
|
+
node: default,
|
|
1689
|
+
): void
|
|
1467
1690
|
```
|
|
1468
1691
|
|
|
1469
|
-
|
|
1692
|
+
Remove a hidden node from the network while minimally repairing connectivity.
|
|
1470
1693
|
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1694
|
+
Parameters:
|
|
1695
|
+
- `this` - Network instance (bound implicitly via method-style call).
|
|
1696
|
+
- `node` - The node object to remove (must be of type 'hidden').
|
|
1697
|
+
|
|
1698
|
+
### resolveArchitectureDescriptor
|
|
1699
|
+
|
|
1700
|
+
```ts
|
|
1701
|
+
resolveArchitectureDescriptor(
|
|
1702
|
+
network: default,
|
|
1703
|
+
): NetworkArchitectureDescriptor
|
|
1477
1704
|
```
|
|
1478
1705
|
|
|
1479
|
-
|
|
1706
|
+
Resolve the public architecture descriptor, preferring live graph facts and
|
|
1707
|
+
falling back to hydrated serialization metadata only when the live result is
|
|
1708
|
+
still purely inferred.
|
|
1480
1709
|
|
|
1481
|
-
|
|
1482
|
-
|
|
1710
|
+
This helper keeps the descriptor ownership story in one chapter: topology
|
|
1711
|
+
owns the live analysis while serialization can optionally hydrate a cached
|
|
1712
|
+
descriptor that remains safe to reuse when the runtime graph shape matches.
|
|
1483
1713
|
|
|
1484
1714
|
Parameters:
|
|
1485
|
-
- `
|
|
1486
|
-
- `inputSize` - - Optional input-size override that takes precedence over serialized input.
|
|
1487
|
-
- `outputSize` - - Optional output-size override that takes precedence over serialized output.
|
|
1715
|
+
- `network` - Runtime network instance.
|
|
1488
1716
|
|
|
1489
|
-
Returns:
|
|
1717
|
+
Returns: Public architecture descriptor for telemetry and UI consumers.
|
|
1490
1718
|
|
|
1491
|
-
|
|
1719
|
+
### restoreRNG
|
|
1492
1720
|
|
|
1493
1721
|
```ts
|
|
1494
|
-
|
|
1722
|
+
restoreRNG(
|
|
1723
|
+
fn: () => number,
|
|
1724
|
+
): void
|
|
1725
|
+
```
|
|
1495
1726
|
|
|
1496
|
-
|
|
1727
|
+
Restores deterministic RNG lifecycle behavior from a provided RNG function.
|
|
1728
|
+
|
|
1729
|
+
Overview:
|
|
1730
|
+
- Use this when replaying deterministic flows after custom serialization, hydration, or test setup.
|
|
1731
|
+
- The restored RNG function becomes the active random source used by the network lifecycle helpers.
|
|
1732
|
+
- This keeps deterministic plumbing explicit when external code owns RNG reconstruction.
|
|
1733
|
+
|
|
1734
|
+
Parameters:
|
|
1735
|
+
- `this` - - Bound network instance receiving the restored RNG lifecycle function.
|
|
1736
|
+
- `fn` - - Deterministic RNG function to install (expected to return values in `[0, 1)`).
|
|
1737
|
+
|
|
1738
|
+
Returns: Nothing.
|
|
1739
|
+
|
|
1740
|
+
Example:
|
|
1741
|
+
|
|
1742
|
+
```ts
|
|
1743
|
+
network.restoreRNG(restoredRandomFunction);
|
|
1497
1744
|
```
|
|
1498
1745
|
|
|
1499
|
-
###
|
|
1746
|
+
### serialize
|
|
1500
1747
|
|
|
1501
1748
|
```ts
|
|
1502
|
-
|
|
1749
|
+
serialize(): CompactSerializedNetworkTuple
|
|
1503
1750
|
```
|
|
1504
1751
|
|
|
1505
|
-
Serializes a network instance into the
|
|
1752
|
+
Serializes a network instance into the compact tuple format.
|
|
1506
1753
|
|
|
1507
|
-
Use this format when
|
|
1508
|
-
and
|
|
1754
|
+
Use this format when payload size and serialization speed matter more than readability.
|
|
1755
|
+
The tuple layout is positional and optimized for transport/storage efficiency.
|
|
1509
1756
|
|
|
1510
1757
|
Parameters:
|
|
1511
1758
|
- `this` - - Bound network instance.
|
|
1512
1759
|
|
|
1513
|
-
Returns:
|
|
1760
|
+
Returns: Compact tuple payload containing activations, states, squash keys, connections, and input/output sizes.
|
|
1514
1761
|
|
|
1515
1762
|
Example:
|
|
1516
1763
|
|
|
1517
1764
|
```ts
|
|
1518
1765
|
import Network from '../../network';
|
|
1519
|
-
import {
|
|
1766
|
+
import { deserialize, serialize } from './network.serialize.utils';
|
|
1520
1767
|
|
|
1521
|
-
const sourceNetwork = new Network(
|
|
1522
|
-
const
|
|
1523
|
-
const rebuiltNetwork =
|
|
1768
|
+
const sourceNetwork = new Network(2, 1);
|
|
1769
|
+
const compactTuple = serialize.call(sourceNetwork);
|
|
1770
|
+
const rebuiltNetwork = deserialize(compactTuple);
|
|
1524
1771
|
```
|
|
1525
1772
|
|
|
1526
|
-
###
|
|
1773
|
+
### setRNGState
|
|
1527
1774
|
|
|
1528
1775
|
```ts
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
):
|
|
1776
|
+
setRNGState(
|
|
1777
|
+
state: number,
|
|
1778
|
+
): void
|
|
1532
1779
|
```
|
|
1533
1780
|
|
|
1534
|
-
|
|
1781
|
+
Applies a deterministic RNG numeric state to continue from a known checkpoint.
|
|
1535
1782
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1783
|
+
Overview:
|
|
1784
|
+
- Pair this with `getRNGState` to pause/resume deterministic sequences.
|
|
1785
|
+
- Useful for reproducible tests, multi-stage training workflows, and deterministic replay.
|
|
1786
|
+
- Delegation keeps the write path consistent with the rest of deterministic state utilities.
|
|
1538
1787
|
|
|
1539
1788
|
Parameters:
|
|
1540
|
-
- `
|
|
1789
|
+
- `this` - - Bound network instance receiving deterministic RNG state.
|
|
1790
|
+
- `state` - - Numeric RNG state checkpoint to install.
|
|
1541
1791
|
|
|
1542
|
-
Returns:
|
|
1792
|
+
Returns: Nothing.
|
|
1543
1793
|
|
|
1544
1794
|
Example:
|
|
1545
1795
|
|
|
1546
1796
|
```ts
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
const rebuiltNetwork = fromJSONImpl(snapshotJson);
|
|
1797
|
+
network.setRNGState(savedState);
|
|
1550
1798
|
```
|
|
1551
1799
|
|
|
1552
|
-
###
|
|
1800
|
+
### setSeed
|
|
1553
1801
|
|
|
1554
1802
|
```ts
|
|
1555
|
-
|
|
1803
|
+
setSeed(
|
|
1804
|
+
seed: number,
|
|
1805
|
+
): void
|
|
1556
1806
|
```
|
|
1557
1807
|
|
|
1558
|
-
|
|
1808
|
+
Sets deterministic randomness for a network by installing a seed-backed RNG.
|
|
1559
1809
|
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1810
|
+
Overview:
|
|
1811
|
+
- Use this before training, mutation, or stochastic operations when you need repeatable runs.
|
|
1812
|
+
- The same seed and operation order produce the same random sequence and reproducible outcomes.
|
|
1813
|
+
- This method delegates to setup utilities so behavior stays centralized across deterministic APIs.
|
|
1563
1814
|
|
|
1564
1815
|
Parameters:
|
|
1565
|
-
- `this` -
|
|
1816
|
+
- `this` - - Bound network instance whose RNG state is being initialized.
|
|
1817
|
+
- `seed` - - Seed value used to derive deterministic RNG state (low 32 bits are applied).
|
|
1566
1818
|
|
|
1567
|
-
Returns:
|
|
1819
|
+
Returns: Nothing.
|
|
1568
1820
|
|
|
1569
|
-
|
|
1821
|
+
Example:
|
|
1570
1822
|
|
|
1571
1823
|
```ts
|
|
1572
|
-
|
|
1573
|
-
force: boolean,
|
|
1574
|
-
): void
|
|
1824
|
+
network.setSeed(42);
|
|
1575
1825
|
```
|
|
1576
1826
|
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
ACTIONS
|
|
1580
|
-
-------
|
|
1581
|
-
1. Optionally reindex nodes if structural mutations invalidated indices.
|
|
1582
|
-
2. Grow (geometric) or reuse existing typed arrays to ensure capacity >= active connections.
|
|
1583
|
-
3. Populate the logical slice [0, connectionCount) with weight/from/to/flag data.
|
|
1584
|
-
4. Lazily allocate gain & plastic slabs only on first non‑neutral / plastic encounter; omit otherwise.
|
|
1585
|
-
5. Release previously allocated optional slabs when they revert to neutral / unused (omission optimization).
|
|
1586
|
-
6. Update internal bookkeeping: logical count, dirty flags, version counter.
|
|
1587
|
-
|
|
1588
|
-
PERFORMANCE
|
|
1589
|
-
-----------
|
|
1590
|
-
O(C) over active connections with amortized allocation cost due to geometric growth.
|
|
1591
|
-
|
|
1592
|
-
Parameters:
|
|
1593
|
-
- `force` - When true forces rebuild even if network not marked dirty (useful for timing tests).
|
|
1594
|
-
|
|
1595
|
-
### rebuildConnectionSlabAsync
|
|
1827
|
+
### snapshotRNG
|
|
1596
1828
|
|
|
1597
1829
|
```ts
|
|
1598
|
-
|
|
1599
|
-
chunkSize: number,
|
|
1600
|
-
): Promise<void>
|
|
1830
|
+
snapshotRNG(): RNGSnapshot
|
|
1601
1831
|
```
|
|
1602
1832
|
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
Strategy:
|
|
1606
|
-
- Perform capacity decision + allocation up front (mirrors sync path).
|
|
1607
|
-
- Populate connection data in microtask slices (yield via resolved Promise) to avoid long main‑thread stalls.
|
|
1608
|
-
- Adaptive slice sizing for very large graphs if `config.browserSlabChunkTargetMs` set.
|
|
1833
|
+
Captures the current deterministic RNG lifecycle state as a portable snapshot.
|
|
1609
1834
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1835
|
+
Overview:
|
|
1836
|
+
- Use this before temporary experiments, branching simulations, or stateful debug sessions.
|
|
1837
|
+
- The snapshot preserves enough information to resume from the same deterministic point later.
|
|
1838
|
+
- This is useful when comparing alternate algorithm branches from an identical random timeline.
|
|
1612
1839
|
|
|
1613
1840
|
Parameters:
|
|
1614
|
-
- `
|
|
1841
|
+
- `this` - - Bound network instance whose RNG lifecycle state is captured.
|
|
1615
1842
|
|
|
1616
|
-
Returns:
|
|
1843
|
+
Returns: Snapshot containing deterministic progress metadata and RNG state payload.
|
|
1617
1844
|
|
|
1618
|
-
|
|
1845
|
+
Example:
|
|
1619
1846
|
|
|
1620
1847
|
```ts
|
|
1621
|
-
|
|
1622
|
-
input: number[],
|
|
1623
|
-
): number[]
|
|
1848
|
+
const snapshot = network.snapshotRNG();
|
|
1624
1849
|
```
|
|
1625
1850
|
|
|
1626
|
-
|
|
1851
|
+
### testNetwork
|
|
1627
1852
|
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1853
|
+
```ts
|
|
1854
|
+
testNetwork(
|
|
1855
|
+
set: TestSample[],
|
|
1856
|
+
cost: CostFunction | undefined,
|
|
1857
|
+
): TestNetworkResult
|
|
1858
|
+
```
|
|
1632
1859
|
|
|
1633
|
-
|
|
1634
|
-
- Reuses internal activation/state buffers to reduce per‑step allocation churn.
|
|
1635
|
-
- Applies gain multiplication if optional gain slab exists.
|
|
1636
|
-
- Assumes acyclic graph; topological order recomputed on demand if marked dirty.
|
|
1860
|
+
Evaluate a dataset and return average error and elapsed time.
|
|
1637
1861
|
|
|
1638
1862
|
Parameters:
|
|
1639
|
-
- `
|
|
1863
|
+
- `this` - Bound network instance.
|
|
1864
|
+
- `set` - Evaluation samples.
|
|
1865
|
+
- `cost` - Optional cost function override.
|
|
1640
1866
|
|
|
1641
|
-
Returns:
|
|
1867
|
+
Returns: Mean error and evaluation duration.
|
|
1642
1868
|
|
|
1643
|
-
###
|
|
1869
|
+
### toJSONImpl
|
|
1644
1870
|
|
|
1645
1871
|
```ts
|
|
1646
|
-
|
|
1647
|
-
training: boolean,
|
|
1648
|
-
): boolean
|
|
1872
|
+
toJSONImpl(): NetworkJSON
|
|
1649
1873
|
```
|
|
1650
1874
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1875
|
+
Serializes a network instance into the verbose JSON format.
|
|
1876
|
+
|
|
1877
|
+
Use this format when you need human-readable snapshots, explicit schema versioning,
|
|
1878
|
+
and better forward/backward compatibility handling.
|
|
1653
1879
|
|
|
1654
1880
|
Parameters:
|
|
1655
|
-
- `
|
|
1881
|
+
- `this` - - Bound network instance.
|
|
1656
1882
|
|
|
1657
|
-
Returns:
|
|
1883
|
+
Returns: Versioned JSON payload with shape metadata, nodes, and connections.
|
|
1658
1884
|
|
|
1659
|
-
|
|
1885
|
+
Example:
|
|
1660
1886
|
|
|
1661
1887
|
```ts
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
Obtain (and lazily rebuild if dirty) the current packed SoA view of connections.
|
|
1666
|
-
|
|
1667
|
-
Gain Omission: If the internal gain slab is absent (all gains neutral) a synthetic
|
|
1668
|
-
neutral array is created and returned (NOT retained) to keep external educational
|
|
1669
|
-
tooling branch‑free while preserving omission memory savings internally.
|
|
1888
|
+
import Network from '../../network';
|
|
1889
|
+
import { fromJSONImpl, toJSONImpl } from './network.serialize.utils';
|
|
1670
1890
|
|
|
1671
|
-
|
|
1891
|
+
const sourceNetwork = new Network(3, 1);
|
|
1892
|
+
const snapshotJson = toJSONImpl.call(sourceNetwork);
|
|
1893
|
+
const rebuiltNetwork = fromJSONImpl(snapshotJson);
|
|
1894
|
+
```
|
|
1672
1895
|
|
|
1673
|
-
###
|
|
1896
|
+
### trainImpl
|
|
1674
1897
|
|
|
1675
1898
|
```ts
|
|
1676
|
-
|
|
1899
|
+
trainImpl(
|
|
1900
|
+
net: default,
|
|
1901
|
+
set: TrainingSample[],
|
|
1902
|
+
options: TrainingOptions,
|
|
1903
|
+
): { error: number; iterations: number; time: number; }
|
|
1677
1904
|
```
|
|
1678
1905
|
|
|
1679
|
-
|
|
1906
|
+
High-level training orchestration with early stopping, smoothing & callbacks.
|
|
1680
1907
|
|
|
1681
|
-
|
|
1682
|
-
- fresh: number of newly constructed typed arrays since process start / metrics reset.
|
|
1683
|
-
- pooled: number of arrays served from the pool.
|
|
1684
|
-
- pool: per‑key metrics (created, reused, maxRetained) for educational inspection.
|
|
1908
|
+
This is the main entrypoint used by `Network.train(...)`-style APIs.
|
|
1685
1909
|
|
|
1686
|
-
|
|
1910
|
+
Parameters:
|
|
1911
|
+
- `net` - - Network instance to train.
|
|
1912
|
+
- `set` - - Training dataset.
|
|
1913
|
+
- `options` - - Training options (stopping conditions, optimizer, hooks, etc.).
|
|
1687
1914
|
|
|
1688
|
-
Returns:
|
|
1915
|
+
Returns: Summary payload containing final error, iteration count, and elapsed time.
|
|
1689
1916
|
|
|
1690
|
-
|
|
1917
|
+
Example:
|
|
1691
1918
|
|
|
1692
1919
|
```ts
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
): string
|
|
1920
|
+
const result = net.train(set, { iterations: 500, rate: 0.3 });
|
|
1921
|
+
console.log(result.error);
|
|
1696
1922
|
```
|
|
1697
1923
|
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
Implementation Steps:
|
|
1701
|
-
1. Validate presence of output nodes (must produce something observable).
|
|
1702
|
-
2. Assign stable sequential indices to nodes (used as array offsets in generated code).
|
|
1703
|
-
3. Collect initial activation/state values into typed array initializers for warm starting.
|
|
1704
|
-
4. For each non-input node, build a line computing S[i] (pre-activation sum with bias) and A[i]
|
|
1705
|
-
(post-activation output). Gating multiplies activation by gate activations; self-connection adds
|
|
1706
|
-
recurrent term S[i] * weight before activation.
|
|
1707
|
-
5. De-duplicate activation functions: each unique squash name is emitted once; references become
|
|
1708
|
-
indices into array F of function references for compactness.
|
|
1709
|
-
6. Emit an IIFE producing the activate function with internal arrays A (activations) and S (states).
|
|
1710
|
-
|
|
1711
|
-
Parameters:
|
|
1712
|
-
- `net` - Network instance to snapshot.
|
|
1713
|
-
|
|
1714
|
-
Returns: Source string (ES5-compatible) – safe to eval in sandbox to obtain activate function.
|
|
1715
|
-
|
|
1716
|
-
### getRegularizationStats
|
|
1717
|
-
|
|
1718
|
-
```ts
|
|
1719
|
-
getRegularizationStats(): Record<string, unknown> | null
|
|
1720
|
-
```
|
|
1721
|
-
|
|
1722
|
-
Obtain the last recorded regularization / stochastic statistics snapshot.
|
|
1723
|
-
|
|
1724
|
-
Returns a defensive deep copy so callers can inspect metrics without risking mutation of the
|
|
1725
|
-
internal `_lastStats` object maintained by the training loop (e.g., during pruning, dropout, or
|
|
1726
|
-
noise scheduling updates).
|
|
1727
|
-
|
|
1728
|
-
Returns: A deep-cloned stats object or null if no stats have been recorded yet.
|
|
1729
|
-
|
|
1730
|
-
### testNetwork
|
|
1731
|
-
|
|
1732
|
-
```ts
|
|
1733
|
-
testNetwork(
|
|
1734
|
-
set: TestSample[],
|
|
1735
|
-
cost: CostFunction | undefined,
|
|
1736
|
-
): TestNetworkResult
|
|
1737
|
-
```
|
|
1738
|
-
|
|
1739
|
-
Evaluate a dataset and return average error and elapsed time.
|
|
1740
|
-
|
|
1741
|
-
Parameters:
|
|
1742
|
-
- `this` - Bound network instance.
|
|
1743
|
-
- `set` - Evaluation samples.
|
|
1744
|
-
- `cost` - Optional cost function override.
|
|
1745
|
-
|
|
1746
|
-
Returns: Mean error and evaluation duration.
|
|
1747
|
-
|
|
1748
|
-
### computeTopoOrder
|
|
1749
|
-
|
|
1750
|
-
```ts
|
|
1751
|
-
computeTopoOrder(): void
|
|
1752
|
-
```
|
|
1753
|
-
|
|
1754
|
-
Compute a topological ordering (Kahn's algorithm) for the current directed acyclic graph.
|
|
1755
|
-
If cycles are detected (order shorter than node count) we fall back to raw node order to avoid breaking callers.
|
|
1756
|
-
In non-acyclic mode we simply clear cached order to signal use of sequential node array.
|
|
1757
|
-
|
|
1758
|
-
### hasPath
|
|
1759
|
-
|
|
1760
|
-
```ts
|
|
1761
|
-
hasPath(
|
|
1762
|
-
from: default,
|
|
1763
|
-
to: default,
|
|
1764
|
-
): boolean
|
|
1765
|
-
```
|
|
1766
|
-
|
|
1767
|
-
Depth-first reachability test (avoids infinite loops via visited set).
|
|
1768
|
-
|
|
1769
|
-
### createMLP
|
|
1770
|
-
|
|
1771
|
-
```ts
|
|
1772
|
-
createMLP(
|
|
1773
|
-
inputCount: number,
|
|
1774
|
-
hiddenCounts: number[],
|
|
1775
|
-
outputCount: number,
|
|
1776
|
-
): default
|
|
1777
|
-
```
|
|
1778
|
-
|
|
1779
|
-
Build a strictly layered and fully connected MLP network.
|
|
1780
|
-
|
|
1781
|
-
Parameters:
|
|
1782
|
-
- `this` - Network constructor.
|
|
1783
|
-
- `inputCount` - Number of input nodes.
|
|
1784
|
-
- `hiddenCounts` - Hidden-layer node counts.
|
|
1785
|
-
- `outputCount` - Number of output nodes.
|
|
1786
|
-
|
|
1787
|
-
Returns: Newly created MLP network.
|
|
1788
|
-
|
|
1789
|
-
### rebuildConnections
|
|
1790
|
-
|
|
1791
|
-
```ts
|
|
1792
|
-
rebuildConnections(
|
|
1793
|
-
networkInstance: default,
|
|
1794
|
-
): void
|
|
1795
|
-
```
|
|
1796
|
-
|
|
1797
|
-
Rebuild the canonical connection array from per-node outgoing lists.
|
|
1798
|
-
|
|
1799
|
-
Parameters:
|
|
1800
|
-
- `networkInstance` - Target network.
|
|
1801
|
-
|
|
1802
|
-
### describeArchitecture
|
|
1803
|
-
|
|
1804
|
-
```ts
|
|
1805
|
-
describeArchitecture(
|
|
1806
|
-
network: default,
|
|
1807
|
-
): NetworkArchitectureDescriptor
|
|
1808
|
-
```
|
|
1809
|
-
|
|
1810
|
-
Describes network architecture for diagnostics, telemetry, and UI rendering.
|
|
1811
|
-
|
|
1812
|
-
This function prefers factual sources over heuristics so downstream tooling
|
|
1813
|
-
can rely on the descriptor while still receiving useful output for partially
|
|
1814
|
-
specified runtime graphs.
|
|
1815
|
-
|
|
1816
|
-
Resolution priority is intentionally explicit:
|
|
1817
|
-
1) node `layer` metadata (factual when present)
|
|
1818
|
-
2) graph-derived feed-forward depth layering (factual for acyclic graphs)
|
|
1819
|
-
3) hidden-node count fallback (heuristic inference)
|
|
1820
|
-
|
|
1821
|
-
Parameters:
|
|
1822
|
-
- `network` - - Runtime network instance.
|
|
1823
|
-
|
|
1824
|
-
Returns: Stable architecture descriptor.
|
|
1825
|
-
|
|
1826
|
-
Example:
|
|
1827
|
-
|
|
1828
|
-
```ts
|
|
1829
|
-
const descriptor = describeArchitecture(network);
|
|
1830
|
-
// descriptor.hiddenLayerSizes -> [8, 4]
|
|
1831
|
-
// descriptor.source -> 'layer-metadata' | 'graph-topology' | 'inferred'
|
|
1832
|
-
```
|
|
1833
|
-
|
|
1834
|
-
### resolveArchitectureDescriptor
|
|
1835
|
-
|
|
1836
|
-
```ts
|
|
1837
|
-
resolveArchitectureDescriptor(
|
|
1838
|
-
network: default,
|
|
1839
|
-
): NetworkArchitectureDescriptor
|
|
1840
|
-
```
|
|
1841
|
-
|
|
1842
|
-
Resolve the public architecture descriptor, preferring live graph facts and
|
|
1843
|
-
falling back to hydrated serialization metadata only when the live result is
|
|
1844
|
-
still purely inferred.
|
|
1845
|
-
|
|
1846
|
-
This helper keeps the descriptor ownership story in one chapter: topology
|
|
1847
|
-
owns the live analysis while serialization can optionally hydrate a cached
|
|
1848
|
-
descriptor that remains safe to reuse when the runtime graph shape matches.
|
|
1849
|
-
|
|
1850
|
-
Parameters:
|
|
1851
|
-
- `network` - Runtime network instance.
|
|
1852
|
-
|
|
1853
|
-
Returns: Public architecture descriptor for telemetry and UI consumers.
|
|
1854
|
-
|
|
1855
|
-
### applyGradientClippingImpl
|
|
1856
|
-
|
|
1857
|
-
```ts
|
|
1858
|
-
applyGradientClippingImpl(
|
|
1859
|
-
net: default,
|
|
1860
|
-
cfg: GradientClipRuntimeConfig,
|
|
1861
|
-
): void
|
|
1862
|
-
```
|
|
1863
|
-
|
|
1864
|
-
Apply gradient clipping to a network using a normalized runtime configuration.
|
|
1865
|
-
|
|
1866
|
-
This is a small wrapper that forwards to the concrete implementation used by training.
|
|
1867
|
-
|
|
1868
|
-
Parameters:
|
|
1869
|
-
- `net` - - Network instance to update.
|
|
1870
|
-
- `cfg` - - Normalized clipping settings.
|
|
1871
|
-
|
|
1872
|
-
### propagate
|
|
1873
|
-
|
|
1874
|
-
```ts
|
|
1875
|
-
propagate(
|
|
1876
|
-
rate: number,
|
|
1877
|
-
momentum: number,
|
|
1878
|
-
update: boolean,
|
|
1879
|
-
target: number[],
|
|
1880
|
-
regularization: number,
|
|
1881
|
-
costDerivative: CostDerivative | undefined,
|
|
1882
|
-
): void
|
|
1883
|
-
```
|
|
1884
|
-
|
|
1885
|
-
Propagate output and hidden errors backward through the network.
|
|
1886
|
-
|
|
1887
|
-
Parameters:
|
|
1888
|
-
- `this` - Bound network instance.
|
|
1889
|
-
- `rate` - Learning rate.
|
|
1890
|
-
- `momentum` - Momentum factor.
|
|
1891
|
-
- `update` - Whether to apply updates immediately.
|
|
1892
|
-
- `target` - Output target values.
|
|
1893
|
-
- `regularization` - L2 regularization factor.
|
|
1894
|
-
- `costDerivative` - Optional output-node derivative override.
|
|
1895
|
-
|
|
1896
|
-
### clearState
|
|
1897
|
-
|
|
1898
|
-
```ts
|
|
1899
|
-
clearState(): void
|
|
1900
|
-
```
|
|
1901
|
-
|
|
1902
|
-
Clear all node runtime traces and states.
|
|
1903
|
-
|
|
1904
|
-
Parameters:
|
|
1905
|
-
- `this` - Bound network instance.
|
|
1906
|
-
|
|
1907
|
-
### trainSetImpl
|
|
1924
|
+
### trainSetImpl
|
|
1908
1925
|
|
|
1909
1926
|
```ts
|
|
1910
1927
|
trainSetImpl(
|
|
@@ -1938,1010 +1955,978 @@ Parameters:
|
|
|
1938
1955
|
|
|
1939
1956
|
Returns: Mean cost across the processed samples.
|
|
1940
1957
|
|
|
1941
|
-
###
|
|
1958
|
+
### ungate
|
|
1942
1959
|
|
|
1943
1960
|
```ts
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
options: TrainingOptions,
|
|
1948
|
-
): { error: number; iterations: number; time: number; }
|
|
1961
|
+
ungate(
|
|
1962
|
+
connection: default,
|
|
1963
|
+
): void
|
|
1949
1964
|
```
|
|
1950
1965
|
|
|
1951
|
-
|
|
1966
|
+
Remove gating from a connection, restoring its static weight contribution.
|
|
1952
1967
|
|
|
1953
|
-
|
|
1968
|
+
Idempotent: If the connection is not currently gated, the call performs no structural changes
|
|
1969
|
+
(and optionally logs a warning). After ungating, the connection's weight will be used directly
|
|
1970
|
+
without modulation by a gater activation.
|
|
1971
|
+
|
|
1972
|
+
Complexity: O(n) where n = number of gated connections (indexOf lookup) – typically small.
|
|
1954
1973
|
|
|
1955
1974
|
Parameters:
|
|
1956
|
-
- `
|
|
1957
|
-
- `
|
|
1958
|
-
- `options` - - Training options (stopping conditions, optimizer, hooks, etc.).
|
|
1975
|
+
- `this` - - Bound Network instance.
|
|
1976
|
+
- `connection` - - Connection to ungate.
|
|
1959
1977
|
|
|
1960
|
-
|
|
1978
|
+
## architecture/network/network.types.ts
|
|
1961
1979
|
|
|
1962
|
-
|
|
1980
|
+
### ActivateNetworkInternals
|
|
1981
|
+
|
|
1982
|
+
Runtime interface for activation internals.
|
|
1983
|
+
|
|
1984
|
+
### ActivationFunction
|
|
1963
1985
|
|
|
1964
1986
|
```ts
|
|
1965
|
-
|
|
1966
|
-
|
|
1987
|
+
ActivationFunction(
|
|
1988
|
+
x: number,
|
|
1989
|
+
derivate: boolean | undefined,
|
|
1990
|
+
): number
|
|
1967
1991
|
```
|
|
1968
1992
|
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
Test-only internal helper bundle.
|
|
1993
|
+
Runtime activation function signature used by ONNX activation import/export paths.
|
|
1972
1994
|
|
|
1973
|
-
|
|
1974
|
-
|
|
1995
|
+
Neataptic-style activations support a dual-purpose call pattern:
|
|
1996
|
+
- `derivate === false | undefined`: return activation output $f(x)$
|
|
1997
|
+
- `derivate === true`: return derivative $f'(x)$
|
|
1975
1998
|
|
|
1976
|
-
|
|
1999
|
+
This matches historical Neataptic semantics and keeps ONNX import/export compatible.
|
|
1977
2000
|
|
|
1978
|
-
|
|
2001
|
+
Example:
|
|
1979
2002
|
|
|
1980
|
-
|
|
2003
|
+
```ts
|
|
2004
|
+
const y = activation(x);
|
|
2005
|
+
const dy = activation(x, true);
|
|
2006
|
+
```
|
|
1981
2007
|
|
|
1982
|
-
|
|
2008
|
+
### ActivationSquashFunction
|
|
1983
2009
|
|
|
1984
|
-
|
|
2010
|
+
```ts
|
|
2011
|
+
ActivationSquashFunction(
|
|
2012
|
+
x: number,
|
|
2013
|
+
derivate: boolean | undefined,
|
|
2014
|
+
): number
|
|
2015
|
+
```
|
|
1985
2016
|
|
|
1986
|
-
|
|
2017
|
+
Activation function signature used by ONNX layer emission helpers.
|
|
1987
2018
|
|
|
1988
|
-
###
|
|
2019
|
+
### BackwardCandidateTraversalContext
|
|
1989
2020
|
|
|
1990
|
-
|
|
2021
|
+
Immutable context for backward candidate traversal.
|
|
1991
2022
|
|
|
1992
|
-
|
|
2023
|
+
### BuildAdjacencyContext
|
|
1993
2024
|
|
|
1994
|
-
|
|
2025
|
+
Shared immutable inputs used across the adjacency build pipeline.
|
|
1995
2026
|
|
|
1996
|
-
|
|
2027
|
+
### CheckpointConfig
|
|
1997
2028
|
|
|
1998
|
-
|
|
1999
|
-
forward-only contract. Use `unconstrained` when recurrent, gated, or other
|
|
2000
|
-
cyclic structures may be introduced.
|
|
2029
|
+
Checkpoint callback configuration.
|
|
2001
2030
|
|
|
2002
|
-
|
|
2031
|
+
Training can periodically call `save(...)` with a serialized network snapshot.
|
|
2032
|
+
You can persist these snapshots to disk, upload them, or keep them in-memory.
|
|
2003
2033
|
|
|
2004
|
-
|
|
2034
|
+
### CompactConnectionRebuildContext
|
|
2005
2035
|
|
|
2006
|
-
|
|
2007
|
-
remains available for backward compatibility and must not contradict the
|
|
2008
|
-
declared topology intent.
|
|
2036
|
+
Context for compact-connection reconstruction.
|
|
2009
2037
|
|
|
2010
|
-
|
|
2038
|
+
Connection rows are processed independently so malformed entries can be skipped without aborting import.
|
|
2011
2039
|
|
|
2012
|
-
|
|
2040
|
+
### CompactNodeRebuildContext
|
|
2013
2041
|
|
|
2014
|
-
|
|
2042
|
+
Context for compact-node reconstruction.
|
|
2015
2043
|
|
|
2016
|
-
|
|
2044
|
+
Arrays are expected to be index-aligned so each node can be hydrated deterministically.
|
|
2017
2045
|
|
|
2018
|
-
###
|
|
2046
|
+
### CompactPayloadContext
|
|
2019
2047
|
|
|
2020
|
-
|
|
2048
|
+
Context carrying compact payload fields.
|
|
2021
2049
|
|
|
2022
|
-
|
|
2050
|
+
This named-object form replaces tuple index access in internal orchestration code.
|
|
2023
2051
|
|
|
2024
|
-
|
|
2052
|
+
### CompactSerializedNetworkTuple
|
|
2025
2053
|
|
|
2026
|
-
|
|
2054
|
+
Compact tuple payload used by `serialize` output.
|
|
2027
2055
|
|
|
2028
|
-
|
|
2056
|
+
Tuple slots are intentionally positional to reduce payload size:
|
|
2057
|
+
0) activations, 1) states, 2) squash keys, 3) connections, 4) input size, 5) output size.
|
|
2029
2058
|
|
|
2030
|
-
|
|
2059
|
+
Example:
|
|
2031
2060
|
|
|
2032
|
-
|
|
2061
|
+
```ts
|
|
2062
|
+
const compactTuple: CompactSerializedNetworkTuple = [
|
|
2063
|
+
[0.1, 0.2],
|
|
2064
|
+
[0, 0],
|
|
2065
|
+
['identity', 'tanh'],
|
|
2066
|
+
[{ from: 0, to: 1, weight: 0.5, gater: null }],
|
|
2067
|
+
1,
|
|
2068
|
+
1,
|
|
2069
|
+
];
|
|
2070
|
+
```
|
|
2033
2071
|
|
|
2034
|
-
###
|
|
2072
|
+
### ConnectionGene
|
|
2035
2073
|
|
|
2036
|
-
|
|
2074
|
+
Crossover connection-gene descriptor.
|
|
2037
2075
|
|
|
2038
|
-
###
|
|
2076
|
+
### ConnectionGeneSelectionContext
|
|
2039
2077
|
|
|
2040
|
-
|
|
2078
|
+
Immutable context for selecting inherited genes.
|
|
2041
2079
|
|
|
2042
|
-
###
|
|
2080
|
+
### ConnectionGeneticProps
|
|
2043
2081
|
|
|
2044
|
-
|
|
2082
|
+
Extended connection shape used during genetic crossover.
|
|
2045
2083
|
|
|
2046
|
-
###
|
|
2084
|
+
### ConnectionGroupReinitContext
|
|
2047
2085
|
|
|
2048
|
-
|
|
2086
|
+
Context for reinitializing connection group weights.
|
|
2049
2087
|
|
|
2050
|
-
###
|
|
2088
|
+
### ConnectionInternals
|
|
2051
2089
|
|
|
2052
|
-
Internal
|
|
2090
|
+
Internal Connection properties accessed during slab operations.
|
|
2053
2091
|
|
|
2054
|
-
###
|
|
2092
|
+
### ConnectionInternalsWithEnabled
|
|
2055
2093
|
|
|
2056
|
-
|
|
2094
|
+
Connection view with optional enabled flag.
|
|
2057
2095
|
|
|
2058
|
-
|
|
2096
|
+
Some serialized formats preserve per-edge enablement, while others treat missing values
|
|
2097
|
+
as implicitly enabled.
|
|
2059
2098
|
|
|
2060
|
-
|
|
2099
|
+
### ConnectionSlabView
|
|
2061
2100
|
|
|
2062
|
-
|
|
2101
|
+
Shape returned by getConnectionSlab describing the packed SoA view.
|
|
2063
2102
|
|
|
2064
|
-
|
|
2103
|
+
### ConnectionSplitResult
|
|
2065
2104
|
|
|
2066
|
-
|
|
2105
|
+
Result of replacing a connection with split hidden node.
|
|
2067
2106
|
|
|
2068
|
-
|
|
2107
|
+
### ConnectionWeightNoiseProps
|
|
2069
2108
|
|
|
2070
|
-
|
|
2109
|
+
Internal runtime properties attached to Connection instances.
|
|
2071
2110
|
|
|
2072
|
-
|
|
2111
|
+
### ConnectNetworkInternals
|
|
2073
2112
|
|
|
2074
|
-
|
|
2113
|
+
Runtime interface for connect internals.
|
|
2075
2114
|
|
|
2076
|
-
|
|
2115
|
+
### Conv2DMapping
|
|
2077
2116
|
|
|
2078
|
-
|
|
2117
|
+
Mapping declaration for treating a fully-connected layer as a 2D convolution during export.
|
|
2079
2118
|
|
|
2080
|
-
|
|
2119
|
+
This does **not** magically turn an MLP into a convolutional network at runtime.
|
|
2120
|
+
It annotates a particular export-layer index with a conv interpretation so that:
|
|
2121
|
+
- The exported graph uses conv-shaped tensors/operators, and
|
|
2122
|
+
- Import can re-attach pooling/flatten metadata appropriately.
|
|
2081
2123
|
|
|
2082
|
-
|
|
2124
|
+
Pitfall: mappings must match the actual layer sizes. If `inHeight * inWidth * inChannels`
|
|
2125
|
+
does not correspond to the prior layer width (and similarly for outputs), export or import
|
|
2126
|
+
may reject the model.
|
|
2083
2127
|
|
|
2084
|
-
|
|
2128
|
+
### ConvKernelConsistencyContext
|
|
2085
2129
|
|
|
2086
|
-
|
|
2130
|
+
Context for kernel-coordinate consistency checks at one output position.
|
|
2087
2131
|
|
|
2088
|
-
|
|
2132
|
+
### ConvLayerPairContext
|
|
2089
2133
|
|
|
2090
|
-
|
|
2134
|
+
Context for one resolved Conv mapping layer pair.
|
|
2091
2135
|
|
|
2092
|
-
|
|
2136
|
+
### ConvOutputCoordinate
|
|
2093
2137
|
|
|
2094
|
-
|
|
2138
|
+
Coordinate for one Conv output neuron position.
|
|
2095
2139
|
|
|
2096
|
-
|
|
2140
|
+
### ConvRepresentativeKernelContext
|
|
2097
2141
|
|
|
2098
|
-
|
|
2142
|
+
Context for representative Conv kernel collection per output channel.
|
|
2099
2143
|
|
|
2100
|
-
|
|
2144
|
+
### ConvSharingValidationContext
|
|
2101
2145
|
|
|
2102
|
-
|
|
2146
|
+
Context for validating Conv sharing across all declared mappings.
|
|
2103
2147
|
|
|
2104
|
-
|
|
2148
|
+
### ConvSharingValidationResult
|
|
2105
2149
|
|
|
2106
|
-
|
|
2150
|
+
Result of Conv sharing validation across declared mappings.
|
|
2107
2151
|
|
|
2108
|
-
|
|
2152
|
+
### CostFunction
|
|
2109
2153
|
|
|
2110
|
-
|
|
2154
|
+
```ts
|
|
2155
|
+
CostFunction(
|
|
2156
|
+
target: number[],
|
|
2157
|
+
output: number[],
|
|
2158
|
+
): number
|
|
2159
|
+
```
|
|
2111
2160
|
|
|
2112
|
-
|
|
2161
|
+
Cost / loss function used during supervised training.
|
|
2113
2162
|
|
|
2114
|
-
|
|
2163
|
+
A cost function compares an expected `target` vector with the network's produced `output`
|
|
2164
|
+
vector, returning a scalar error where **lower is better**.
|
|
2115
2165
|
|
|
2116
|
-
|
|
2166
|
+
Design notes:
|
|
2167
|
+
- This is called frequently (often once per training sample), so implementations should be
|
|
2168
|
+
**pure** and **allocation-light**.
|
|
2169
|
+
- Most built-in training loops assume the returned value is non-negative.
|
|
2117
2170
|
|
|
2118
|
-
|
|
2171
|
+
Example (mean squared error):
|
|
2119
2172
|
|
|
2120
|
-
|
|
2173
|
+
```ts
|
|
2174
|
+
export const mse: CostFunction = (target, output) => {
|
|
2175
|
+
const sum = target.reduce((acc, targetValue, index) => {
|
|
2176
|
+
const diff = targetValue - (output[index] ?? 0);
|
|
2177
|
+
return acc + diff * diff;
|
|
2178
|
+
}, 0);
|
|
2179
|
+
return sum / Math.max(1, target.length);
|
|
2180
|
+
};
|
|
2181
|
+
```
|
|
2121
2182
|
|
|
2122
|
-
###
|
|
2183
|
+
### CostFunctionOrObject
|
|
2123
2184
|
|
|
2124
|
-
|
|
2185
|
+
Cost function object compatibility shape.
|
|
2125
2186
|
|
|
2126
|
-
###
|
|
2187
|
+
### CostFunctionOrRef
|
|
2127
2188
|
|
|
2128
|
-
|
|
2189
|
+
Evolve-side serializable cost-function reference.
|
|
2129
2190
|
|
|
2130
|
-
###
|
|
2191
|
+
### CrossoverContext
|
|
2131
2192
|
|
|
2132
|
-
|
|
2193
|
+
Immutable baseline context for one crossover run.
|
|
2133
2194
|
|
|
2134
|
-
###
|
|
2195
|
+
### CrossoverNodeBuildContext
|
|
2135
2196
|
|
|
2136
|
-
|
|
2197
|
+
Node-build context derived from crossover baseline.
|
|
2137
2198
|
|
|
2138
|
-
###
|
|
2199
|
+
### DenseActivationContext
|
|
2139
2200
|
|
|
2140
|
-
|
|
2201
|
+
Dense activation emission context.
|
|
2141
2202
|
|
|
2142
|
-
###
|
|
2203
|
+
### DenseActivationNodePayload
|
|
2143
2204
|
|
|
2144
|
-
|
|
2205
|
+
Strongly typed activation node payload used by dense export helpers.
|
|
2145
2206
|
|
|
2146
|
-
|
|
2147
|
-
topology without exposing private implementation details in public APIs.
|
|
2207
|
+
### DenseGemmNodePayload
|
|
2148
2208
|
|
|
2149
|
-
|
|
2209
|
+
Strongly typed Gemm node payload used by dense export helpers.
|
|
2150
2210
|
|
|
2151
|
-
|
|
2211
|
+
### DenseGraphNames
|
|
2152
2212
|
|
|
2153
|
-
|
|
2213
|
+
Dense graph tensor names.
|
|
2154
2214
|
|
|
2155
|
-
###
|
|
2215
|
+
### DenseInitializerValues
|
|
2156
2216
|
|
|
2157
|
-
|
|
2217
|
+
Dense initializer value arrays.
|
|
2158
2218
|
|
|
2159
|
-
|
|
2219
|
+
### DenseLayerContext
|
|
2160
2220
|
|
|
2161
|
-
|
|
2221
|
+
Dense layer context enriched with resolved activation function.
|
|
2162
2222
|
|
|
2163
|
-
|
|
2223
|
+
### DenseLayerParams
|
|
2164
2224
|
|
|
2165
|
-
|
|
2166
|
-
as implicitly enabled.
|
|
2225
|
+
Parameters for dense layer emission.
|
|
2167
2226
|
|
|
2168
|
-
###
|
|
2227
|
+
### DenseOrderedNodePayload
|
|
2169
2228
|
|
|
2170
|
-
|
|
2229
|
+
Dense node payload union used by ordered append helpers.
|
|
2171
2230
|
|
|
2172
|
-
|
|
2231
|
+
### DenseTensorNames
|
|
2173
2232
|
|
|
2174
|
-
|
|
2233
|
+
Dense initializer tensor names.
|
|
2175
2234
|
|
|
2176
|
-
|
|
2235
|
+
### DenseWeightBuildContext
|
|
2177
2236
|
|
|
2178
|
-
|
|
2179
|
-
0) activations, 1) states, 2) squash keys, 3) connections, 4) input size, 5) output size.
|
|
2237
|
+
Context for building dense layer initializers from two adjacent layers.
|
|
2180
2238
|
|
|
2181
|
-
|
|
2239
|
+
### DenseWeightBuildResult
|
|
2182
2240
|
|
|
2183
|
-
|
|
2184
|
-
const compactTuple: CompactSerializedNetworkTuple = [
|
|
2185
|
-
[0.1, 0.2],
|
|
2186
|
-
[0, 0],
|
|
2187
|
-
['identity', 'tanh'],
|
|
2188
|
-
[{ from: 0, to: 1, weight: 0.5, gater: null }],
|
|
2189
|
-
1,
|
|
2190
|
-
1,
|
|
2191
|
-
];
|
|
2192
|
-
```
|
|
2241
|
+
Dense layer initializer fold output.
|
|
2193
2242
|
|
|
2194
|
-
###
|
|
2243
|
+
### DenseWeightRow
|
|
2195
2244
|
|
|
2196
|
-
|
|
2245
|
+
One collected dense row before fold to flattened initializers.
|
|
2197
2246
|
|
|
2198
|
-
|
|
2247
|
+
### DenseWeightRowCollectionContext
|
|
2199
2248
|
|
|
2200
|
-
|
|
2249
|
+
Context for collecting one dense row.
|
|
2201
2250
|
|
|
2202
|
-
|
|
2251
|
+
### DeterministicChainMutationContext
|
|
2203
2252
|
|
|
2204
|
-
|
|
2253
|
+
Context for deterministic-chain add-node mutation.
|
|
2205
2254
|
|
|
2206
|
-
###
|
|
2255
|
+
### DeterministicNetworkInternals
|
|
2207
2256
|
|
|
2208
|
-
|
|
2257
|
+
Runtime interface for deterministic internals.
|
|
2209
2258
|
|
|
2210
|
-
|
|
2259
|
+
### DiagonalRecurrentBuildContext
|
|
2211
2260
|
|
|
2212
|
-
|
|
2261
|
+
Context for building a diagonal recurrent matrix from self-connections.
|
|
2213
2262
|
|
|
2214
|
-
|
|
2215
|
-
const payload: NetworkJSON = {
|
|
2216
|
-
formatVersion: 2,
|
|
2217
|
-
input: 2,
|
|
2218
|
-
output: 1,
|
|
2219
|
-
dropout: 0,
|
|
2220
|
-
nodes: [{ type: 'input', bias: 0, squash: 'identity', index: 0 }],
|
|
2221
|
-
connections: [],
|
|
2222
|
-
};
|
|
2223
|
-
```
|
|
2263
|
+
### DirectionalConnectionContext
|
|
2224
2264
|
|
|
2225
|
-
|
|
2265
|
+
Indexed context for directional connection metadata.
|
|
2226
2266
|
|
|
2227
|
-
|
|
2267
|
+
### DistinctNodePair
|
|
2228
2268
|
|
|
2229
|
-
|
|
2269
|
+
Selected distinct node pair for swap mutation.
|
|
2230
2270
|
|
|
2231
|
-
###
|
|
2271
|
+
### EvolutionaryTargetContext
|
|
2232
2272
|
|
|
2233
|
-
|
|
2273
|
+
Context for evolutionary sparsity target computation.
|
|
2234
2274
|
|
|
2235
|
-
|
|
2275
|
+
### EvolutionaryTargetResult
|
|
2236
2276
|
|
|
2237
|
-
|
|
2277
|
+
Result of evolutionary sparsity target computation.
|
|
2238
2278
|
|
|
2239
|
-
|
|
2279
|
+
### EvolutionConfig
|
|
2240
2280
|
|
|
2241
|
-
|
|
2281
|
+
Internal normalized evolution config.
|
|
2242
2282
|
|
|
2243
|
-
###
|
|
2283
|
+
### EvolutionFitnessFunction
|
|
2244
2284
|
|
|
2245
|
-
|
|
2285
|
+
```ts
|
|
2286
|
+
EvolutionFitnessFunction(
|
|
2287
|
+
arg0: default & default[],
|
|
2288
|
+
): number | Promise<void>
|
|
2289
|
+
```
|
|
2246
2290
|
|
|
2247
|
-
|
|
2291
|
+
Unified evolution fitness callback shape.
|
|
2248
2292
|
|
|
2249
|
-
###
|
|
2293
|
+
### EvolutionLoopState
|
|
2250
2294
|
|
|
2251
|
-
|
|
2295
|
+
Mutable state tracked during evolution loop.
|
|
2252
2296
|
|
|
2253
|
-
|
|
2297
|
+
### EvolutionSettings
|
|
2254
2298
|
|
|
2255
|
-
|
|
2299
|
+
Scalar evolution settings used by orchestration.
|
|
2256
2300
|
|
|
2257
|
-
|
|
2301
|
+
### EvolutionStopConditions
|
|
2258
2302
|
|
|
2259
|
-
|
|
2303
|
+
Effective evolution stopping conditions.
|
|
2260
2304
|
|
|
2261
|
-
###
|
|
2305
|
+
### EvolveCostFunction
|
|
2262
2306
|
|
|
2263
2307
|
```ts
|
|
2264
|
-
|
|
2308
|
+
EvolveCostFunction(
|
|
2265
2309
|
target: number[],
|
|
2266
2310
|
output: number[],
|
|
2267
2311
|
): number
|
|
2268
2312
|
```
|
|
2269
2313
|
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
A cost function compares an expected `target` vector with the network's produced `output`
|
|
2273
|
-
vector, returning a scalar error where **lower is better**.
|
|
2274
|
-
|
|
2275
|
-
Design notes:
|
|
2276
|
-
- This is called frequently (often once per training sample), so implementations should be
|
|
2277
|
-
**pure** and **allocation-light**.
|
|
2278
|
-
- Most built-in training loops assume the returned value is non-negative.
|
|
2279
|
-
|
|
2280
|
-
Example (mean squared error):
|
|
2281
|
-
|
|
2282
|
-
```ts
|
|
2283
|
-
export const mse: CostFunction = (target, output) => {
|
|
2284
|
-
const sum = target.reduce((acc, targetValue, index) => {
|
|
2285
|
-
const diff = targetValue - (output[index] ?? 0);
|
|
2286
|
-
return acc + diff * diff;
|
|
2287
|
-
}, 0);
|
|
2288
|
-
return sum / Math.max(1, target.length);
|
|
2289
|
-
};
|
|
2290
|
-
```
|
|
2314
|
+
Evolve-side cost function signature.
|
|
2291
2315
|
|
|
2292
|
-
###
|
|
2316
|
+
### EvolveOptions
|
|
2293
2317
|
|
|
2294
|
-
|
|
2318
|
+
Evolve options bag.
|
|
2295
2319
|
|
|
2296
|
-
|
|
2297
|
-
It is most useful for recurrent networks and noisy datasets.
|
|
2320
|
+
### FanOutCollectionContext
|
|
2298
2321
|
|
|
2299
|
-
|
|
2300
|
-
- `norm`: clip by a global $L_2$ norm threshold.
|
|
2301
|
-
- `percentile`: clip using a running percentile estimate (robust to outliers).
|
|
2302
|
-
- `layerwise*`: apply the same idea per-layer (useful when layers have very different scales).
|
|
2322
|
+
Context for fan-out collection: build inputs plus the output count buffer.
|
|
2303
2323
|
|
|
2304
|
-
###
|
|
2324
|
+
### FastSlabNodeRuntime
|
|
2305
2325
|
|
|
2306
|
-
|
|
2326
|
+
Node shape required by fast slab activation kernels.
|
|
2307
2327
|
|
|
2308
|
-
|
|
2309
|
-
in a numerically stable range. If an overflow is detected, the scale is reduced.
|
|
2328
|
+
### FitnessSetup
|
|
2310
2329
|
|
|
2311
|
-
|
|
2330
|
+
Result of fitness-strategy setup.
|
|
2312
2331
|
|
|
2313
|
-
|
|
2332
|
+
### FlattenAfterPoolingContext
|
|
2314
2333
|
|
|
2315
|
-
|
|
2316
|
-
keeping a stable FP32 master copy of parameters when needed.
|
|
2334
|
+
Flatten emission context after optional pooling.
|
|
2317
2335
|
|
|
2318
|
-
###
|
|
2336
|
+
### ForwardCandidateTraversalContext
|
|
2319
2337
|
|
|
2320
|
-
|
|
2338
|
+
Immutable context for forward candidate traversal.
|
|
2321
2339
|
|
|
2322
|
-
|
|
2323
|
-
This object form is useful when you want to pin numeric hyperparameters or wrap a base
|
|
2324
|
-
optimizer (e.g. lookahead).
|
|
2340
|
+
### FusedRecurrentEmissionExecutionContext
|
|
2325
2341
|
|
|
2326
|
-
|
|
2342
|
+
Shared execution context for emitting one fused recurrent layer payload.
|
|
2327
2343
|
|
|
2328
|
-
|
|
2329
|
-
net.train(set, {
|
|
2330
|
-
iterations: 1_000,
|
|
2331
|
-
rate: 0.001,
|
|
2332
|
-
optimizer: { type: 'adamw', beta1: 0.9, beta2: 0.999, eps: 1e-8, weightDecay: 0.01 },
|
|
2333
|
-
});
|
|
2334
|
-
```
|
|
2344
|
+
### FusedRecurrentGraphNames
|
|
2335
2345
|
|
|
2336
|
-
|
|
2337
|
-
- Exact supported `type` values are validated by training utilities.
|
|
2338
|
-
- Unspecified fields fall back to sensible defaults per optimizer.
|
|
2346
|
+
Context for ONNX fused recurrent node payload names.
|
|
2339
2347
|
|
|
2340
|
-
###
|
|
2348
|
+
### FusedRecurrentInitializerNames
|
|
2341
2349
|
|
|
2342
|
-
|
|
2350
|
+
Context for ONNX fused recurrent initializer names.
|
|
2343
2351
|
|
|
2344
|
-
|
|
2345
|
-
structures. Treat this as an opaque snapshot blob.
|
|
2352
|
+
### GatingNetworkProps
|
|
2346
2353
|
|
|
2347
|
-
|
|
2354
|
+
Internal network properties accessed during gating operations.
|
|
2348
2355
|
|
|
2349
|
-
|
|
2356
|
+
### GeneEndpointsContext
|
|
2350
2357
|
|
|
2351
|
-
|
|
2352
|
-
You can persist these snapshots to disk, upload them, or keep them in-memory.
|
|
2358
|
+
Endpoints for one gene traversal step.
|
|
2353
2359
|
|
|
2354
|
-
###
|
|
2360
|
+
### GeneticNetwork
|
|
2355
2361
|
|
|
2356
|
-
|
|
2362
|
+
Runtime network shape used by crossover internals.
|
|
2357
2363
|
|
|
2358
|
-
|
|
2359
|
-
Typical uses include logging, custom learning-rate schedules, or diagnostics.
|
|
2364
|
+
### GeneTraversalContext
|
|
2360
2365
|
|
|
2361
|
-
|
|
2366
|
+
Traversal context for one connection gene.
|
|
2362
2367
|
|
|
2363
|
-
|
|
2364
|
-
MetricsHook(
|
|
2365
|
-
m: { iteration: number; error: number; plateauError?: number | undefined; gradNorm: number; },
|
|
2366
|
-
): void
|
|
2367
|
-
```
|
|
2368
|
+
### GlobalThisWithStructuredClone
|
|
2368
2369
|
|
|
2369
|
-
|
|
2370
|
+
GlobalThis extension exposing optional structuredClone.
|
|
2370
2371
|
|
|
2371
|
-
|
|
2372
|
-
It is designed for lightweight telemetry, not heavy data export.
|
|
2372
|
+
### GradientClipConfig
|
|
2373
2373
|
|
|
2374
|
-
|
|
2374
|
+
Gradient clipping configuration.
|
|
2375
2375
|
|
|
2376
|
-
|
|
2376
|
+
Clipping prevents rare large gradients from causing unstable weight updates.
|
|
2377
|
+
It is most useful for recurrent networks and noisy datasets.
|
|
2377
2378
|
|
|
2378
|
-
|
|
2379
|
-
|
|
2379
|
+
Conceptual modes:
|
|
2380
|
+
- `norm`: clip by a global $L_2$ norm threshold.
|
|
2381
|
+
- `percentile`: clip using a running percentile estimate (robust to outliers).
|
|
2382
|
+
- `layerwise*`: apply the same idea per-layer (useful when layers have very different scales).
|
|
2380
2383
|
|
|
2381
|
-
###
|
|
2384
|
+
### GruEmissionContext
|
|
2382
2385
|
|
|
2383
|
-
|
|
2386
|
+
Context for heuristic GRU emission when a layer matches expected shape.
|
|
2384
2387
|
|
|
2385
|
-
|
|
2386
|
-
1) forward activation
|
|
2387
|
-
2) backward propagation
|
|
2388
|
-
3) optimizer update
|
|
2389
|
-
repeated until a stopping condition is met.
|
|
2388
|
+
### HiddenLayerActivationTraversalContext
|
|
2390
2389
|
|
|
2391
|
-
|
|
2390
|
+
Hidden-layer traversal context for assigning imported activation functions.
|
|
2392
2391
|
|
|
2393
|
-
|
|
2394
|
-
net.train(set, {
|
|
2395
|
-
iterations: 500,
|
|
2396
|
-
rate: 0.3,
|
|
2397
|
-
batchSize: 16,
|
|
2398
|
-
gradientClip: { mode: 'norm', maxNorm: 1 },
|
|
2399
|
-
});
|
|
2400
|
-
```
|
|
2392
|
+
### HiddenLayerHeuristicContext
|
|
2401
2393
|
|
|
2402
|
-
|
|
2403
|
-
- Provide at least one of `iterations` or `error`.
|
|
2404
|
-
- `earlyStopPatience` adds an additional "stop when no improvement" guard.
|
|
2394
|
+
Context for one hidden layer during heuristic recurrent emission.
|
|
2405
2395
|
|
|
2406
|
-
###
|
|
2396
|
+
### IndexedMetadataAppendContext
|
|
2407
2397
|
|
|
2408
|
-
|
|
2398
|
+
Append-an-index metadata context for JSON-array metadata keys.
|
|
2409
2399
|
|
|
2410
|
-
###
|
|
2400
|
+
### InputOutputEndpoints
|
|
2411
2401
|
|
|
2412
|
-
|
|
2402
|
+
Required endpoint pair for input/output edge seeding.
|
|
2413
2403
|
|
|
2414
|
-
###
|
|
2404
|
+
### JsonConnectionRebuildContext
|
|
2415
2405
|
|
|
2416
|
-
|
|
2406
|
+
Context for JSON-connection reconstruction.
|
|
2417
2407
|
|
|
2418
|
-
|
|
2408
|
+
Connection rows may include optional gater and enabled metadata.
|
|
2419
2409
|
|
|
2420
|
-
|
|
2410
|
+
### JsonNodeRebuildContext
|
|
2421
2411
|
|
|
2422
|
-
|
|
2412
|
+
Context for JSON-node reconstruction.
|
|
2423
2413
|
|
|
2424
|
-
|
|
2414
|
+
Node entries are rebuilt in order and pushed into mutable runtime internals.
|
|
2425
2415
|
|
|
2426
|
-
###
|
|
2416
|
+
### LayerActivationContext
|
|
2427
2417
|
|
|
2428
|
-
|
|
2418
|
+
Activation analysis context for one layer.
|
|
2429
2419
|
|
|
2430
|
-
###
|
|
2420
|
+
### LayerActivationValidationContext
|
|
2431
2421
|
|
|
2432
|
-
|
|
2422
|
+
Activation-homogeneity decision context for one current layer.
|
|
2433
2423
|
|
|
2434
|
-
###
|
|
2424
|
+
### LayerBuildContext
|
|
2435
2425
|
|
|
2436
|
-
|
|
2426
|
+
Layer build context used while emitting one ONNX graph layer segment.
|
|
2437
2427
|
|
|
2438
|
-
###
|
|
2428
|
+
### LayerConnectivityValidationContext
|
|
2439
2429
|
|
|
2440
|
-
|
|
2430
|
+
Connectivity decision context for one source-target node pair.
|
|
2441
2431
|
|
|
2442
|
-
###
|
|
2432
|
+
### LayerOrderingNodeGroups
|
|
2443
2433
|
|
|
2444
|
-
|
|
2434
|
+
Node partitions used by ONNX layered-ordering inference traversal.
|
|
2445
2435
|
|
|
2446
|
-
###
|
|
2436
|
+
### LayerOrderingResolutionContext
|
|
2447
2437
|
|
|
2448
|
-
|
|
2449
|
-
EvolveCostFunction(
|
|
2450
|
-
target: number[],
|
|
2451
|
-
output: number[],
|
|
2452
|
-
): number
|
|
2453
|
-
```
|
|
2438
|
+
Mutable traversal state while resolving hidden-layer ordering.
|
|
2454
2439
|
|
|
2455
|
-
|
|
2440
|
+
### LayerRecurrentDecisionContext
|
|
2456
2441
|
|
|
2457
|
-
|
|
2442
|
+
Context used to decide recurrent emission branch usage.
|
|
2458
2443
|
|
|
2459
|
-
|
|
2444
|
+
### LayerTraversalContext
|
|
2460
2445
|
|
|
2461
|
-
|
|
2446
|
+
Layer traversal context with adjacent layers and output classification.
|
|
2462
2447
|
|
|
2463
|
-
|
|
2448
|
+
### LayerValidationTraversalContext
|
|
2464
2449
|
|
|
2465
|
-
|
|
2450
|
+
Layer-wise validation context for activation and connectivity checks.
|
|
2466
2451
|
|
|
2467
|
-
|
|
2452
|
+
### LstmEmissionContext
|
|
2468
2453
|
|
|
2469
|
-
|
|
2454
|
+
Context for heuristic LSTM emission when a layer matches expected shape.
|
|
2470
2455
|
|
|
2471
|
-
|
|
2456
|
+
### MetricsHook
|
|
2472
2457
|
|
|
2473
|
-
|
|
2458
|
+
```ts
|
|
2459
|
+
MetricsHook(
|
|
2460
|
+
m: { iteration: number; error: number; plateauError?: number | undefined; gradNorm: number; },
|
|
2461
|
+
): void
|
|
2462
|
+
```
|
|
2474
2463
|
|
|
2475
|
-
|
|
2464
|
+
Metrics hook signature.
|
|
2476
2465
|
|
|
2477
|
-
|
|
2466
|
+
If provided, this callback receives summarized metrics after each iteration.
|
|
2467
|
+
It is designed for lightweight telemetry, not heavy data export.
|
|
2478
2468
|
|
|
2479
|
-
|
|
2469
|
+
### MixedPrecisionConfig
|
|
2480
2470
|
|
|
2481
|
-
|
|
2471
|
+
Mixed-precision configuration.
|
|
2482
2472
|
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
genome: default,
|
|
2486
|
-
): number
|
|
2487
|
-
```
|
|
2473
|
+
Mixed precision can improve throughput by running some math in lower precision while
|
|
2474
|
+
keeping a stable FP32 master copy of parameters when needed.
|
|
2488
2475
|
|
|
2489
|
-
|
|
2476
|
+
### MixedPrecisionDynamicConfig
|
|
2490
2477
|
|
|
2491
|
-
|
|
2478
|
+
Dynamic mixed-precision configuration.
|
|
2492
2479
|
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
population: default[],
|
|
2496
|
-
): Promise<void>
|
|
2497
|
-
```
|
|
2480
|
+
When enabled, training uses a loss-scaling heuristic that attempts to keep gradients
|
|
2481
|
+
in a numerically stable range. If an overflow is detected, the scale is reduced.
|
|
2498
2482
|
|
|
2499
|
-
|
|
2483
|
+
### MonitoredSmoothingConfig
|
|
2500
2484
|
|
|
2501
|
-
|
|
2485
|
+
Config for monitored smoothing computation.
|
|
2502
2486
|
|
|
2503
|
-
|
|
2504
|
-
EvolutionFitnessFunction(
|
|
2505
|
-
arg0: default & default[],
|
|
2506
|
-
): number | Promise<void>
|
|
2507
|
-
```
|
|
2487
|
+
### MovingAverageType
|
|
2508
2488
|
|
|
2509
|
-
|
|
2489
|
+
Moving-average strategy identifier.
|
|
2510
2490
|
|
|
2511
|
-
|
|
2491
|
+
These strategies are used to smooth the monitored error curve during training.
|
|
2492
|
+
Smoothing can make early stopping and progress logging less noisy.
|
|
2512
2493
|
|
|
2513
|
-
|
|
2494
|
+
### MutationHandler
|
|
2514
2495
|
|
|
2515
|
-
|
|
2496
|
+
```ts
|
|
2497
|
+
MutationHandler(
|
|
2498
|
+
method: MutationMethod | undefined,
|
|
2499
|
+
): void
|
|
2500
|
+
```
|
|
2516
2501
|
|
|
2517
|
-
|
|
2502
|
+
Mutation handler function contract.
|
|
2518
2503
|
|
|
2519
|
-
###
|
|
2504
|
+
### MutationMethod
|
|
2520
2505
|
|
|
2521
|
-
|
|
2506
|
+
Mutation method descriptor shape.
|
|
2522
2507
|
|
|
2523
|
-
###
|
|
2508
|
+
### MutationMethodObject
|
|
2524
2509
|
|
|
2525
|
-
|
|
2510
|
+
Object-only form of mutation method descriptor.
|
|
2526
2511
|
|
|
2527
|
-
###
|
|
2512
|
+
### NeatRuntime
|
|
2528
2513
|
|
|
2529
|
-
|
|
2514
|
+
Minimal runtime contract consumed from NEAT in evolve utilities.
|
|
2530
2515
|
|
|
2531
|
-
###
|
|
2516
|
+
### NetworkActivationRuntime
|
|
2532
2517
|
|
|
2533
|
-
|
|
2518
|
+
Runtime activation contract used by slab-based execution paths.
|
|
2534
2519
|
|
|
2535
|
-
###
|
|
2520
|
+
### NetworkArchitectureDescriptor
|
|
2536
2521
|
|
|
2537
|
-
|
|
2522
|
+
Stable architecture descriptor for UI/telemetry consumers.
|
|
2538
2523
|
|
|
2539
|
-
|
|
2524
|
+
Hidden-layer sizes are ordered from input-side to output-side.
|
|
2540
2525
|
|
|
2541
|
-
|
|
2526
|
+
### NetworkArchitectureSource
|
|
2542
2527
|
|
|
2543
|
-
|
|
2528
|
+
Provenance of hidden-layer architecture information.
|
|
2544
2529
|
|
|
2545
|
-
|
|
2530
|
+
### NetworkBootstrapInternals
|
|
2546
2531
|
|
|
2547
|
-
|
|
2532
|
+
Internal constructor-time surface used by bootstrap helpers.
|
|
2548
2533
|
|
|
2549
|
-
|
|
2534
|
+
### NetworkConstructor
|
|
2550
2535
|
|
|
2551
|
-
|
|
2536
|
+
Constructor signature for runtime Network import.
|
|
2552
2537
|
|
|
2553
|
-
|
|
2538
|
+
### NetworkConstructorOptions
|
|
2554
2539
|
|
|
2555
|
-
|
|
2540
|
+
Public constructor options for `Network`.
|
|
2556
2541
|
|
|
2557
|
-
|
|
2542
|
+
`topologyIntent` is the semantic, DX-first contract. `enforceAcyclic`
|
|
2543
|
+
remains available for backward compatibility and must not contradict the
|
|
2544
|
+
declared topology intent.
|
|
2558
2545
|
|
|
2559
|
-
###
|
|
2546
|
+
### NetworkGeneticProps
|
|
2560
2547
|
|
|
2561
|
-
|
|
2548
|
+
Runtime properties used during genetic operations.
|
|
2562
2549
|
|
|
2563
|
-
###
|
|
2550
|
+
### NetworkInternalsWithDropout
|
|
2564
2551
|
|
|
2565
|
-
|
|
2552
|
+
Serialize internals with optional dropout field.
|
|
2566
2553
|
|
|
2567
|
-
|
|
2554
|
+
Verbose JSON snapshots normalize this value so readers can treat dropout as numeric data.
|
|
2568
2555
|
|
|
2569
|
-
|
|
2556
|
+
### NetworkJSON
|
|
2570
2557
|
|
|
2571
|
-
|
|
2558
|
+
Verbose JSON payload representation used by `toJSONImpl` and `fromJSONImpl`.
|
|
2572
2559
|
|
|
2573
|
-
|
|
2560
|
+
`formatVersion` enables compatibility checks and migration handling.
|
|
2574
2561
|
|
|
2575
|
-
|
|
2562
|
+
Example:
|
|
2576
2563
|
|
|
2577
|
-
|
|
2564
|
+
```ts
|
|
2565
|
+
const payload: NetworkJSON = {
|
|
2566
|
+
formatVersion: 2,
|
|
2567
|
+
input: 2,
|
|
2568
|
+
output: 1,
|
|
2569
|
+
dropout: 0,
|
|
2570
|
+
nodes: [{ type: 'input', bias: 0, squash: 'identity', index: 0 }],
|
|
2571
|
+
connections: [],
|
|
2572
|
+
};
|
|
2573
|
+
```
|
|
2578
2574
|
|
|
2579
|
-
###
|
|
2575
|
+
### NetworkJSONConnection
|
|
2580
2576
|
|
|
2581
|
-
|
|
2577
|
+
Verbose JSON connection representation.
|
|
2582
2578
|
|
|
2583
|
-
|
|
2579
|
+
Includes optional gater and explicit enabled state for portability.
|
|
2584
2580
|
|
|
2585
|
-
|
|
2581
|
+
### NetworkJSONNode
|
|
2586
2582
|
|
|
2587
|
-
|
|
2583
|
+
Verbose JSON node representation.
|
|
2588
2584
|
|
|
2589
|
-
|
|
2585
|
+
Node entries are self-describing and intended for readable, versioned snapshots.
|
|
2590
2586
|
|
|
2591
2587
|
### NetworkMutationProps
|
|
2592
2588
|
|
|
2593
2589
|
Internal network properties accessed during mutations.
|
|
2594
2590
|
|
|
2595
|
-
###
|
|
2591
|
+
### NetworkPruningProps
|
|
2596
2592
|
|
|
2597
|
-
|
|
2598
|
-
MutationHandler(
|
|
2599
|
-
method: MutationMethod | undefined,
|
|
2600
|
-
): void
|
|
2601
|
-
```
|
|
2593
|
+
Internal network properties accessed during pruning operations.
|
|
2602
2594
|
|
|
2603
|
-
|
|
2595
|
+
### NetworkRemoveProps
|
|
2604
2596
|
|
|
2605
|
-
|
|
2597
|
+
Internal network properties accessed during remove operations.
|
|
2606
2598
|
|
|
2607
|
-
|
|
2599
|
+
### NetworkRuntimeControlInternals
|
|
2608
2600
|
|
|
2609
|
-
|
|
2601
|
+
Internal network properties accessed by runtime-control helpers.
|
|
2610
2602
|
|
|
2611
|
-
|
|
2603
|
+
### NetworkRuntimeDiagnosticsInternals
|
|
2612
2604
|
|
|
2613
|
-
|
|
2605
|
+
Internal network properties accessed by runtime diagnostics helpers.
|
|
2614
2606
|
|
|
2615
|
-
|
|
2607
|
+
### NetworkRuntimeProps
|
|
2616
2608
|
|
|
2617
|
-
|
|
2609
|
+
Internal runtime properties attached to Network instances.
|
|
2618
2610
|
|
|
2619
|
-
|
|
2611
|
+
### NetworkSlabProps
|
|
2620
2612
|
|
|
2621
|
-
|
|
2613
|
+
Internal Network properties for slab operations.
|
|
2622
2614
|
|
|
2623
|
-
|
|
2615
|
+
### NetworkStandaloneProps
|
|
2624
2616
|
|
|
2625
|
-
|
|
2617
|
+
Internal standalone generation network view.
|
|
2626
2618
|
|
|
2627
|
-
|
|
2619
|
+
### NetworkTopologyIntent
|
|
2628
2620
|
|
|
2629
|
-
|
|
2621
|
+
Public topology intent exposed by the network API.
|
|
2630
2622
|
|
|
2631
|
-
|
|
2623
|
+
Use `feed-forward` when the caller wants the library to preserve an acyclic,
|
|
2624
|
+
forward-only contract. Use `unconstrained` when recurrent, gated, or other
|
|
2625
|
+
cyclic structures may be introduced.
|
|
2632
2626
|
|
|
2633
|
-
###
|
|
2627
|
+
### NetworkTopoRuntime
|
|
2634
2628
|
|
|
2635
|
-
|
|
2629
|
+
Runtime topology contract used to lazily rebuild topological order.
|
|
2636
2630
|
|
|
2637
|
-
###
|
|
2631
|
+
### NetworkWithOnnxImportPooling
|
|
2638
2632
|
|
|
2639
|
-
|
|
2633
|
+
Network instance augmented with optional imported ONNX pooling metadata.
|
|
2640
2634
|
|
|
2641
|
-
###
|
|
2635
|
+
### NodeConnectionSnapshotContext
|
|
2642
2636
|
|
|
2643
|
-
|
|
2637
|
+
Snapshot of node adjacency prior to removal.
|
|
2644
2638
|
|
|
2645
|
-
###
|
|
2639
|
+
### NodeInternals
|
|
2646
2640
|
|
|
2647
|
-
|
|
2641
|
+
Runtime interface for accessing node internal properties.
|
|
2648
2642
|
|
|
2649
|
-
|
|
2643
|
+
This is intentionally "internal": it exposes mutable fields that the ONNX exporter/importer
|
|
2644
|
+
needs (connections, bias, squash). Regular library users should generally interact with
|
|
2645
|
+
the public `Node` API instead.
|
|
2650
2646
|
|
|
2651
|
-
|
|
2647
|
+
### NodeInternalsWithExportIndex
|
|
2648
|
+
|
|
2649
|
+
Runtime node internals augmented with optional export index metadata.
|
|
2652
2650
|
|
|
2653
2651
|
### NodePair
|
|
2654
2652
|
|
|
2655
2653
|
Canonical source-target node pair tuple.
|
|
2656
2654
|
|
|
2657
|
-
###
|
|
2655
|
+
### NodeRemovalContext
|
|
2658
2656
|
|
|
2659
|
-
|
|
2657
|
+
Immutable context for validated node-removal request.
|
|
2660
2658
|
|
|
2661
|
-
|
|
2662
|
-
It annotates a particular export-layer index with a conv interpretation so that:
|
|
2663
|
-
- The exported graph uses conv-shaped tensors/operators, and
|
|
2664
|
-
- Import can re-attach pooling/flatten metadata appropriately.
|
|
2659
|
+
### NodeWithIndex
|
|
2665
2660
|
|
|
2666
|
-
|
|
2667
|
-
does not correspond to the prior layer width (and similarly for outputs), export or import
|
|
2668
|
-
may reject the model.
|
|
2661
|
+
Node with generated index for standalone-code emission.
|
|
2669
2662
|
|
|
2670
|
-
###
|
|
2663
|
+
### OffspringMaterializationContext
|
|
2671
2664
|
|
|
2672
|
-
|
|
2665
|
+
Immutable context for offspring materialization.
|
|
2673
2666
|
|
|
2674
|
-
|
|
2675
|
-
current exporter. It intentionally avoids protobuf-level complexity while
|
|
2676
|
-
still preserving the attribute variants needed by the importer.
|
|
2667
|
+
### OnnxActivationAssignmentContext
|
|
2677
2668
|
|
|
2678
|
-
|
|
2669
|
+
Shared activation-assignment context for hidden and output traversal.
|
|
2679
2670
|
|
|
2680
|
-
|
|
2671
|
+
### OnnxActivationLayerOperations
|
|
2681
2672
|
|
|
2682
|
-
|
|
2683
|
-
such as a batch dimension.
|
|
2673
|
+
Layer-indexed activation operator lookup extracted from ONNX graph nodes.
|
|
2684
2674
|
|
|
2685
|
-
###
|
|
2675
|
+
### OnnxActivationOperation
|
|
2686
2676
|
|
|
2687
|
-
|
|
2677
|
+
Supported ONNX activation operators recognized during activation import.
|
|
2688
2678
|
|
|
2689
|
-
|
|
2690
|
-
- `inputs` and `outputs` describe graph boundaries,
|
|
2691
|
-
- `initializer` stores constant tensors such as weights and biases,
|
|
2692
|
-
- `node` stores the ordered operator payloads that consume those tensors.
|
|
2679
|
+
### OnnxActivationOperationResolutionContext
|
|
2693
2680
|
|
|
2694
|
-
|
|
2681
|
+
Activation operation resolution context for one neuron or layer default.
|
|
2695
2682
|
|
|
2696
|
-
|
|
2683
|
+
### OnnxActivationParseResult
|
|
2697
2684
|
|
|
2698
|
-
|
|
2685
|
+
Parsed ONNX activation-node naming payload.
|
|
2699
2686
|
|
|
2700
|
-
|
|
2687
|
+
### OnnxAttribute
|
|
2701
2688
|
|
|
2702
|
-
|
|
2689
|
+
ONNX node attribute payload.
|
|
2703
2690
|
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
```
|
|
2691
|
+
This simplified JSON-first shape is enough for the operators emitted by the
|
|
2692
|
+
current exporter. It intentionally avoids protobuf-level complexity while
|
|
2693
|
+
still preserving the attribute variants needed by the importer.
|
|
2708
2694
|
|
|
2709
|
-
|
|
2710
|
-
- `metadata_props` contains NeatapticTS-specific keys (layer sizes, recurrent flags,
|
|
2711
|
-
conv/pool mappings, etc.). This is where most round-trip hints live.
|
|
2712
|
-
- Initializers currently store floating-point weights in `float_data`.
|
|
2695
|
+
### OnnxBaseModelBuildContext
|
|
2713
2696
|
|
|
2714
|
-
|
|
2715
|
-
- Treat this as untrusted input if it comes from outside your process.
|
|
2697
|
+
Context for constructing a base ONNX model shell.
|
|
2716
2698
|
|
|
2717
|
-
###
|
|
2699
|
+
### OnnxBuildResolvedOptions
|
|
2718
2700
|
|
|
2719
|
-
|
|
2701
|
+
Resolved options used by ONNX model build orchestration.
|
|
2720
2702
|
|
|
2721
|
-
|
|
2722
|
-
exported payload easy to serialize, inspect, and diff as plain JSON.
|
|
2703
|
+
### OnnxConvEmissionContext
|
|
2723
2704
|
|
|
2724
|
-
|
|
2705
|
+
Context used after resolving Conv mapping for one layer.
|
|
2725
2706
|
|
|
2726
|
-
|
|
2707
|
+
### OnnxConvEmissionParams
|
|
2727
2708
|
|
|
2728
|
-
|
|
2709
|
+
Parameters accepted by Conv layer emission.
|
|
2729
2710
|
|
|
2730
|
-
|
|
2711
|
+
### OnnxConvKernelCoordinate
|
|
2731
2712
|
|
|
2732
|
-
|
|
2733
|
-
`float_data`, along with the tensor name, element type, and logical shape.
|
|
2713
|
+
Coordinate for one Conv kernel weight lookup.
|
|
2734
2714
|
|
|
2735
|
-
###
|
|
2715
|
+
### OnnxConvParameters
|
|
2736
2716
|
|
|
2737
|
-
ONNX
|
|
2717
|
+
Flattened Conv parameters for ONNX initializers.
|
|
2738
2718
|
|
|
2739
|
-
###
|
|
2719
|
+
### OnnxConvTensorNames
|
|
2740
2720
|
|
|
2741
|
-
|
|
2721
|
+
Tensor names generated for Conv parameters.
|
|
2742
2722
|
|
|
2743
|
-
###
|
|
2723
|
+
### OnnxDimension
|
|
2744
2724
|
|
|
2745
|
-
|
|
2725
|
+
One dimension inside an ONNX tensor shape.
|
|
2746
2726
|
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
network (when supported).
|
|
2727
|
+
Use `dim_value` for fixed numeric widths and `dim_param` for symbolic names
|
|
2728
|
+
such as a batch dimension.
|
|
2750
2729
|
|
|
2751
|
-
###
|
|
2730
|
+
### OnnxExportOptions
|
|
2752
2731
|
|
|
2753
|
-
|
|
2754
|
-
ActivationSquashFunction(
|
|
2755
|
-
x: number,
|
|
2756
|
-
derivate: boolean | undefined,
|
|
2757
|
-
): number
|
|
2758
|
-
```
|
|
2732
|
+
Options controlling ONNX-like export.
|
|
2759
2733
|
|
|
2760
|
-
|
|
2734
|
+
These options trade off strictness, portability, and fidelity:
|
|
2761
2735
|
|
|
2762
|
-
|
|
2736
|
+
- **Strict (default-ish)** export tries to keep the graph easy to interpret:
|
|
2737
|
+
layered topology, homogeneous activations per layer, and fully-connected layers.
|
|
2763
2738
|
|
|
2764
|
-
|
|
2739
|
+
- **Relaxed** export (`allowPartialConnectivity` / `allowMixedActivations`) can represent
|
|
2740
|
+
more networks, but it may generate graphs that are primarily meant for NeatapticTS’s
|
|
2741
|
+
importer (and may be less friendly to external ONNX tooling).
|
|
2765
2742
|
|
|
2766
|
-
|
|
2743
|
+
- **Recurrent export** (`allowRecurrent`) is intentionally conservative and currently
|
|
2744
|
+
focuses on a constrained single-step representation and optional fused heuristics.
|
|
2745
|
+
|
|
2746
|
+
Key fields (high-level):
|
|
2747
|
+
- `includeMetadata`: includes `metadata_props` with architecture hints.
|
|
2748
|
+
- `opset`: numeric opset version stored in the exported model metadata (default is
|
|
2749
|
+
resolved by the exporter; commonly 18 in this codebase).
|
|
2750
|
+
- `legacyNodeOrdering`: keeps older node ordering for backward compatibility.
|
|
2751
|
+
- `conv2dMappings` / `pool2dMappings`: encode conv/pool semantics for fully-connected
|
|
2752
|
+
layers via explicit mapping declarations.
|
|
2767
2753
|
|
|
2768
|
-
|
|
2754
|
+
### OnnxFusedGateApplicationContext
|
|
2769
2755
|
|
|
2770
|
-
|
|
2756
|
+
Gate-weight application context for one reconstructed fused layer.
|
|
2771
2757
|
|
|
2772
|
-
|
|
2758
|
+
### OnnxFusedGateRowAssignmentContext
|
|
2773
2759
|
|
|
2774
|
-
|
|
2760
|
+
Context for assigning one gate-neuron row from flattened ONNX tensors.
|
|
2775
2761
|
|
|
2776
|
-
|
|
2762
|
+
### OnnxFusedLayerNeighborhood
|
|
2777
2763
|
|
|
2778
|
-
|
|
2764
|
+
Hidden-layer neighborhood slices around a reconstructed fused layer.
|
|
2779
2765
|
|
|
2780
|
-
|
|
2766
|
+
### OnnxFusedLayerReconstructionContext
|
|
2781
2767
|
|
|
2782
|
-
|
|
2768
|
+
Execution context for one fused recurrent layer reconstruction.
|
|
2783
2769
|
|
|
2784
|
-
|
|
2770
|
+
### OnnxFusedLayerRuntime
|
|
2785
2771
|
|
|
2786
|
-
|
|
2772
|
+
Runtime interface of a reconstructed fused recurrent layer instance.
|
|
2787
2773
|
|
|
2788
|
-
|
|
2774
|
+
The importer only relies on a narrow runtime contract: access to the
|
|
2775
|
+
reconstructed nodes, an input wiring hook, and an optional output group that
|
|
2776
|
+
can be reconnected to the next restored layer.
|
|
2789
2777
|
|
|
2790
|
-
###
|
|
2778
|
+
### OnnxFusedRecurrentKind
|
|
2791
2779
|
|
|
2792
|
-
|
|
2780
|
+
Supported fused recurrent operator families recognized during ONNX import.
|
|
2793
2781
|
|
|
2794
|
-
###
|
|
2782
|
+
### OnnxFusedRecurrentSpec
|
|
2795
2783
|
|
|
2796
|
-
|
|
2784
|
+
Fused recurrent family specification used during import reconstruction.
|
|
2797
2785
|
|
|
2798
|
-
|
|
2786
|
+
This tells the importer how to interpret one emitted ONNX recurrent family:
|
|
2787
|
+
how many gates to expect, what order those gates were serialized in, and
|
|
2788
|
+
which gate owns the self-recurrent diagonal replay.
|
|
2799
2789
|
|
|
2800
|
-
|
|
2790
|
+
### OnnxFusedTensorPayload
|
|
2801
2791
|
|
|
2802
|
-
|
|
2792
|
+
Fused recurrent tensor payload read from ONNX initializers.
|
|
2803
2793
|
|
|
2804
|
-
|
|
2794
|
+
The importer resolves the three recurrent tensor families up front so the
|
|
2795
|
+
reconstruction pass can focus on wiring and row assignment instead of
|
|
2796
|
+
repeatedly re-looking up initializers.
|
|
2805
2797
|
|
|
2806
|
-
###
|
|
2798
|
+
### OnnxGraph
|
|
2807
2799
|
|
|
2808
|
-
|
|
2800
|
+
Graph body of an ONNX-like model.
|
|
2809
2801
|
|
|
2810
|
-
|
|
2802
|
+
The exporter writes three main collections here:
|
|
2803
|
+
- `inputs` and `outputs` describe graph boundaries,
|
|
2804
|
+
- `initializer` stores constant tensors such as weights and biases,
|
|
2805
|
+
- `node` stores the ordered operator payloads that consume those tensors.
|
|
2811
2806
|
|
|
2812
|
-
|
|
2807
|
+
### OnnxGraphDimensionBuildContext
|
|
2813
2808
|
|
|
2814
|
-
|
|
2809
|
+
Context for constructing input/output ONNX graph dimensions.
|
|
2815
2810
|
|
|
2816
|
-
|
|
2811
|
+
### OnnxGraphDimensions
|
|
2817
2812
|
|
|
2818
|
-
|
|
2813
|
+
Output dimensions used by ONNX graph input/output value info payloads.
|
|
2819
2814
|
|
|
2820
|
-
|
|
2815
|
+
### OnnxImportAggregatedLayerAssignmentContext
|
|
2821
2816
|
|
|
2822
|
-
|
|
2817
|
+
Context for assigning aggregated dense tensors for one layer.
|
|
2823
2818
|
|
|
2824
|
-
|
|
2819
|
+
### OnnxImportAggregatedNeuronAssignmentContext
|
|
2825
2820
|
|
|
2826
|
-
|
|
2821
|
+
Context for assigning one aggregated dense target neuron row.
|
|
2827
2822
|
|
|
2828
|
-
|
|
2823
|
+
### OnnxImportArchitectureContext
|
|
2829
2824
|
|
|
2830
|
-
|
|
2825
|
+
Shared architecture extraction context with resolved graph dimensions.
|
|
2831
2826
|
|
|
2832
|
-
|
|
2827
|
+
### OnnxImportArchitectureResult
|
|
2833
2828
|
|
|
2834
|
-
|
|
2829
|
+
Parsed architecture dimensions extracted from ONNX import graph payloads.
|
|
2835
2830
|
|
|
2836
|
-
|
|
2831
|
+
### OnnxImportConvCoordinateAssignmentContext
|
|
2837
2832
|
|
|
2838
|
-
|
|
2833
|
+
Context for applying Conv weights and bias at one output coordinate.
|
|
2839
2834
|
|
|
2840
|
-
|
|
2835
|
+
### OnnxImportConvKernelAssignmentContext
|
|
2841
2836
|
|
|
2842
|
-
|
|
2837
|
+
Context for assigning one concrete Conv kernel connection weight.
|
|
2843
2838
|
|
|
2844
|
-
|
|
2839
|
+
### OnnxImportConvLayerContext
|
|
2845
2840
|
|
|
2846
|
-
|
|
2841
|
+
Context for reconstructing one Conv layer's imported connectivity.
|
|
2847
2842
|
|
|
2848
|
-
|
|
2843
|
+
### OnnxImportConvLayerContextBuildParams
|
|
2849
2844
|
|
|
2850
|
-
|
|
2845
|
+
Build params for creating one Conv reconstruction layer context.
|
|
2851
2846
|
|
|
2852
|
-
|
|
2847
|
+
### OnnxImportConvMetadata
|
|
2853
2848
|
|
|
2854
|
-
|
|
2849
|
+
Parsed Conv metadata payload used for optional reconstruction pass.
|
|
2855
2850
|
|
|
2856
|
-
|
|
2851
|
+
### OnnxImportConvNodeSlices
|
|
2857
2852
|
|
|
2858
|
-
|
|
2853
|
+
Layer node slices used while applying Conv reconstruction assignments.
|
|
2859
2854
|
|
|
2860
|
-
|
|
2855
|
+
### OnnxImportConvOutputCoordinate
|
|
2861
2856
|
|
|
2862
|
-
|
|
2857
|
+
Coordinate for one Conv output neuron traversal position.
|
|
2863
2858
|
|
|
2864
|
-
|
|
2859
|
+
### OnnxImportConvTensorContext
|
|
2865
2860
|
|
|
2866
|
-
|
|
2861
|
+
Resolved Conv initializer tensors and dimensions for one layer.
|
|
2867
2862
|
|
|
2868
|
-
|
|
2863
|
+
### OnnxImportDimensionRecord
|
|
2869
2864
|
|
|
2870
|
-
|
|
2865
|
+
Loose ONNX shape-dimension record used by legacy import payload access.
|
|
2871
2866
|
|
|
2872
|
-
|
|
2867
|
+
### OnnxImportHiddenLayerSpan
|
|
2873
2868
|
|
|
2874
|
-
|
|
2869
|
+
Hidden-layer span payload with one-based layer numbering and global offset.
|
|
2875
2870
|
|
|
2876
|
-
|
|
2871
|
+
### OnnxImportHiddenSizeDerivationContext
|
|
2877
2872
|
|
|
2878
|
-
|
|
2873
|
+
Context for deriving hidden layer sizes from initializer tensors and metadata.
|
|
2879
2874
|
|
|
2880
|
-
|
|
2875
|
+
### OnnxImportInboundConnectionMap
|
|
2881
2876
|
|
|
2882
|
-
|
|
2877
|
+
Inbound connection lookup map keyed by source node for one target neuron.
|
|
2883
2878
|
|
|
2884
|
-
|
|
2879
|
+
### OnnxImportLayerConnectionContext
|
|
2885
2880
|
|
|
2886
|
-
|
|
2881
|
+
Execution context for assigning one hidden-layer recurrent diagonal tensor.
|
|
2887
2882
|
|
|
2888
|
-
|
|
2883
|
+
### OnnxImportLayerNodePair
|
|
2889
2884
|
|
|
2890
|
-
|
|
2885
|
+
Node slices for one sequential imported layer assignment pass.
|
|
2891
2886
|
|
|
2892
|
-
|
|
2887
|
+
### OnnxImportLayerNodePairBuildParams
|
|
2893
2888
|
|
|
2894
|
-
|
|
2889
|
+
Build params for one sequential layer node-pair slice operation.
|
|
2895
2890
|
|
|
2896
|
-
|
|
2891
|
+
### OnnxImportLayerTensorNames
|
|
2897
2892
|
|
|
2898
|
-
|
|
2893
|
+
Weight tensor names for one imported layer index.
|
|
2899
2894
|
|
|
2900
|
-
|
|
2895
|
+
### OnnxImportLayerWeightBucket
|
|
2901
2896
|
|
|
2902
|
-
|
|
2897
|
+
Bucketed ONNX dense/per-neuron tensors for one exported layer index.
|
|
2903
2898
|
|
|
2904
|
-
|
|
2899
|
+
### OnnxImportPerNeuronAssignmentContext
|
|
2905
2900
|
|
|
2906
|
-
|
|
2901
|
+
Context for assigning one per-neuron imported target node.
|
|
2907
2902
|
|
|
2908
|
-
|
|
2903
|
+
### OnnxImportPerNeuronLayerAssignmentContext
|
|
2909
2904
|
|
|
2910
|
-
|
|
2905
|
+
Context for assigning per-neuron tensors for one layer.
|
|
2911
2906
|
|
|
2912
|
-
|
|
2907
|
+
### OnnxImportPoolingMetadata
|
|
2913
2908
|
|
|
2914
|
-
|
|
2909
|
+
Parsed pooling metadata payload attached to imported network instances.
|
|
2915
2910
|
|
|
2916
|
-
|
|
2911
|
+
### OnnxImportRecurrentRestorationContext
|
|
2917
2912
|
|
|
2918
|
-
|
|
2913
|
+
Context for recurrent self-connection restoration from ONNX metadata and tensors.
|
|
2919
2914
|
|
|
2920
|
-
|
|
2921
|
-
layered topology, homogeneous activations per layer, and fully-connected layers.
|
|
2915
|
+
### OnnxImportSelfConnectionUpsertContext
|
|
2922
2916
|
|
|
2923
|
-
|
|
2924
|
-
more networks, but it may generate graphs that are primarily meant for NeatapticTS’s
|
|
2925
|
-
importer (and may be less friendly to external ONNX tooling).
|
|
2917
|
+
Context for upserting one hidden node self-connection from recurrent weight.
|
|
2926
2918
|
|
|
2927
|
-
|
|
2928
|
-
focuses on a constrained single-step representation and optional fused heuristics.
|
|
2919
|
+
### OnnxImportWeightAssignmentBuildParams
|
|
2929
2920
|
|
|
2930
|
-
|
|
2931
|
-
- `includeMetadata`: includes `metadata_props` with architecture hints.
|
|
2932
|
-
- `opset`: numeric opset version stored in the exported model metadata (default is
|
|
2933
|
-
resolved by the exporter; commonly 18 in this codebase).
|
|
2934
|
-
- `legacyNodeOrdering`: keeps older node ordering for backward compatibility.
|
|
2935
|
-
- `conv2dMappings` / `pool2dMappings`: encode conv/pool semantics for fully-connected
|
|
2936
|
-
layers via explicit mapping declarations.
|
|
2921
|
+
Build params for creating shared ONNX import weight-assignment context.
|
|
2937
2922
|
|
|
2938
|
-
###
|
|
2923
|
+
### OnnxImportWeightAssignmentContext
|
|
2939
2924
|
|
|
2940
|
-
|
|
2925
|
+
Shared weight-assignment context built once per ONNX import.
|
|
2941
2926
|
|
|
2942
|
-
###
|
|
2927
|
+
### OnnxIncomingWeightAssignmentContext
|
|
2943
2928
|
|
|
2944
|
-
|
|
2929
|
+
Context for assigning dense incoming weights for one gate-neuron row.
|
|
2945
2930
|
|
|
2946
2931
|
### OnnxLayerEmissionContext
|
|
2947
2932
|
|
|
@@ -2951,526 +2936,541 @@ Context for emitting non-input layers during model build.
|
|
|
2951
2936
|
|
|
2952
2937
|
Result of emitting non-input export layers.
|
|
2953
2938
|
|
|
2954
|
-
###
|
|
2955
|
-
|
|
2956
|
-
Context for applying optional ONNX model metadata.
|
|
2957
|
-
|
|
2958
|
-
### OnnxPostProcessingContext
|
|
2959
|
-
|
|
2960
|
-
Context for post-processing and export metadata finalization.
|
|
2961
|
-
|
|
2962
|
-
### OnnxRecurrentCollectionContext
|
|
2963
|
-
|
|
2964
|
-
Context for collecting recurrent layer indices during model build.
|
|
2965
|
-
|
|
2966
|
-
### OnnxRecurrentInputValueInfoContext
|
|
2939
|
+
### OnnxLayerFactory
|
|
2967
2940
|
|
|
2968
|
-
|
|
2941
|
+
Runtime factory map used to construct dynamic recurrent layer modules.
|
|
2969
2942
|
|
|
2970
|
-
###
|
|
2943
|
+
### OnnxMetadataProperty
|
|
2971
2944
|
|
|
2972
|
-
|
|
2945
|
+
Canonical metadata key-value pair used in ONNX model metadata_props.
|
|
2973
2946
|
|
|
2974
|
-
###
|
|
2947
|
+
### OnnxModel
|
|
2975
2948
|
|
|
2976
|
-
|
|
2949
|
+
ONNX-like model container (JSON-serializable).
|
|
2977
2950
|
|
|
2978
|
-
|
|
2951
|
+
This is the main “wire format” object in this folder. Persist it as JSON text:
|
|
2979
2952
|
|
|
2980
|
-
|
|
2953
|
+
```ts
|
|
2954
|
+
const jsonText = JSON.stringify(model);
|
|
2955
|
+
const restoredModel = JSON.parse(jsonText) as OnnxModel;
|
|
2956
|
+
```
|
|
2981
2957
|
|
|
2982
|
-
|
|
2958
|
+
Notes:
|
|
2959
|
+
- `metadata_props` contains NeatapticTS-specific keys (layer sizes, recurrent flags,
|
|
2960
|
+
conv/pool mappings, etc.). This is where most round-trip hints live.
|
|
2961
|
+
- Initializers currently store floating-point weights in `float_data`.
|
|
2983
2962
|
|
|
2984
|
-
|
|
2963
|
+
Security/trust boundary:
|
|
2964
|
+
- Treat this as untrusted input if it comes from outside your process.
|
|
2985
2965
|
|
|
2986
|
-
###
|
|
2966
|
+
### OnnxModelMetadataContext
|
|
2987
2967
|
|
|
2988
|
-
|
|
2968
|
+
Context for applying optional ONNX model metadata.
|
|
2989
2969
|
|
|
2990
|
-
###
|
|
2970
|
+
### OnnxNode
|
|
2991
2971
|
|
|
2992
|
-
|
|
2972
|
+
One ONNX operator invocation inside the graph.
|
|
2993
2973
|
|
|
2994
|
-
|
|
2974
|
+
Nodes connect named tensors rather than object references, which keeps the
|
|
2975
|
+
exported payload easy to serialize, inspect, and diff as plain JSON.
|
|
2995
2976
|
|
|
2996
|
-
|
|
2977
|
+
### OnnxPerceptronBuildContext
|
|
2997
2978
|
|
|
2998
|
-
|
|
2979
|
+
Build context for mapping ONNX layer sizes into a Neataptic MLP factory call.
|
|
2999
2980
|
|
|
3000
|
-
|
|
2981
|
+
### OnnxPerceptronSizeValidationContext
|
|
3001
2982
|
|
|
3002
|
-
|
|
2983
|
+
Validation context for perceptron size-list checks during ONNX import.
|
|
3003
2984
|
|
|
3004
|
-
|
|
2985
|
+
### OnnxPostProcessingContext
|
|
3005
2986
|
|
|
3006
|
-
|
|
2987
|
+
Context for post-processing and export metadata finalization.
|
|
3007
2988
|
|
|
3008
|
-
|
|
2989
|
+
### OnnxRecurrentCollectionContext
|
|
3009
2990
|
|
|
3010
|
-
|
|
2991
|
+
Context for collecting recurrent layer indices during model build.
|
|
3011
2992
|
|
|
3012
|
-
|
|
2993
|
+
### OnnxRecurrentInputValueInfoContext
|
|
3013
2994
|
|
|
3014
|
-
|
|
2995
|
+
Context for constructing one recurrent previous-state graph input payload.
|
|
3015
2996
|
|
|
3016
|
-
|
|
2997
|
+
### OnnxRecurrentLayerProcessingContext
|
|
3017
2998
|
|
|
3018
|
-
|
|
2999
|
+
Execution context for processing one hidden recurrent layer.
|
|
3019
3000
|
|
|
3020
|
-
|
|
3001
|
+
### OnnxRecurrentLayerTraversalContext
|
|
3021
3002
|
|
|
3022
|
-
|
|
3003
|
+
Traversal context for one hidden layer during recurrent-input collection.
|
|
3023
3004
|
|
|
3024
|
-
|
|
3005
|
+
### OnnxRuntimeFactories
|
|
3025
3006
|
|
|
3026
|
-
|
|
3007
|
+
Runtime factories consumed during ONNX import network reconstruction.
|
|
3027
3008
|
|
|
3028
|
-
|
|
3009
|
+
### OnnxRuntimeLayerFactory
|
|
3029
3010
|
|
|
3030
|
-
|
|
3011
|
+
```ts
|
|
3012
|
+
OnnxRuntimeLayerFactory(
|
|
3013
|
+
size: number,
|
|
3014
|
+
): default
|
|
3015
|
+
```
|
|
3031
3016
|
|
|
3032
|
-
|
|
3017
|
+
Runtime layer-constructor signature used for recurrent layer reconstruction.
|
|
3033
3018
|
|
|
3034
|
-
###
|
|
3019
|
+
### OnnxRuntimeLayerFactoryMap
|
|
3035
3020
|
|
|
3036
|
-
|
|
3021
|
+
Runtime layer module shape widened for fused-recurrent reconstruction wiring.
|
|
3037
3022
|
|
|
3038
|
-
###
|
|
3023
|
+
### OnnxRuntimeLayerModule
|
|
3039
3024
|
|
|
3040
|
-
|
|
3025
|
+
Runtime layer module shape consumed by ONNX import orchestration.
|
|
3041
3026
|
|
|
3042
|
-
###
|
|
3027
|
+
### OnnxRuntimePerceptronFactory
|
|
3043
3028
|
|
|
3044
|
-
|
|
3029
|
+
```ts
|
|
3030
|
+
OnnxRuntimePerceptronFactory(
|
|
3031
|
+
sizes: number[],
|
|
3032
|
+
): default
|
|
3033
|
+
```
|
|
3045
3034
|
|
|
3046
|
-
|
|
3035
|
+
Runtime perceptron factory signature used by ONNX import orchestration.
|
|
3047
3036
|
|
|
3048
|
-
|
|
3037
|
+
### OnnxShape
|
|
3049
3038
|
|
|
3050
|
-
|
|
3039
|
+
ONNX tensor type shape.
|
|
3051
3040
|
|
|
3052
|
-
|
|
3041
|
+
### OnnxTensor
|
|
3053
3042
|
|
|
3054
|
-
|
|
3043
|
+
Serialized tensor payload stored inside graph initializers.
|
|
3055
3044
|
|
|
3056
|
-
|
|
3045
|
+
NeatapticTS currently writes floating-point parameter vectors and matrices to
|
|
3046
|
+
`float_data`, along with the tensor name, element type, and logical shape.
|
|
3057
3047
|
|
|
3058
|
-
###
|
|
3048
|
+
### OnnxTensorType
|
|
3059
3049
|
|
|
3060
|
-
|
|
3050
|
+
ONNX tensor type.
|
|
3061
3051
|
|
|
3062
|
-
###
|
|
3052
|
+
### OnnxValueInfo
|
|
3063
3053
|
|
|
3064
|
-
|
|
3054
|
+
ONNX value info (input/output description).
|
|
3065
3055
|
|
|
3066
|
-
###
|
|
3056
|
+
### OptimizerConfigBase
|
|
3067
3057
|
|
|
3068
|
-
|
|
3058
|
+
Base optimizer configuration.
|
|
3069
3059
|
|
|
3070
|
-
|
|
3060
|
+
Training accepts either an optimizer name (`"adam"`, `"sgd"`, ...) or an object.
|
|
3061
|
+
This object form is useful when you want to pin numeric hyperparameters or wrap a base
|
|
3062
|
+
optimizer (e.g. lookahead).
|
|
3071
3063
|
|
|
3072
|
-
|
|
3064
|
+
Example:
|
|
3073
3065
|
|
|
3074
|
-
|
|
3066
|
+
```ts
|
|
3067
|
+
net.train(set, {
|
|
3068
|
+
iterations: 1_000,
|
|
3069
|
+
rate: 0.001,
|
|
3070
|
+
optimizer: { type: 'adamw', beta1: 0.9, beta2: 0.999, eps: 1e-8, weightDecay: 0.01 },
|
|
3071
|
+
});
|
|
3072
|
+
```
|
|
3075
3073
|
|
|
3076
|
-
|
|
3074
|
+
Notes:
|
|
3075
|
+
- Exact supported `type` values are validated by training utilities.
|
|
3076
|
+
- Unspecified fields fall back to sensible defaults per optimizer.
|
|
3077
3077
|
|
|
3078
|
-
###
|
|
3078
|
+
### OptionalLayerOutputParams
|
|
3079
3079
|
|
|
3080
|
-
Shared parameters for
|
|
3080
|
+
Shared parameters for optional pooling/flatten output emission.
|
|
3081
3081
|
|
|
3082
|
-
###
|
|
3082
|
+
### OptionalPoolingAndFlattenParams
|
|
3083
3083
|
|
|
3084
|
-
|
|
3084
|
+
Parameters for optional pooling + flatten emission after a layer output.
|
|
3085
3085
|
|
|
3086
|
-
###
|
|
3086
|
+
### OutgoingOrderBuildContext
|
|
3087
3087
|
|
|
3088
|
-
|
|
3088
|
+
Context for constructing source-grouped outgoing connection order.
|
|
3089
3089
|
|
|
3090
|
-
###
|
|
3090
|
+
### OutputLayerActivationContext
|
|
3091
3091
|
|
|
3092
|
-
|
|
3092
|
+
Output-layer activation assignment context.
|
|
3093
3093
|
|
|
3094
|
-
###
|
|
3094
|
+
### Parent1GeneTraversalContext
|
|
3095
3095
|
|
|
3096
|
-
|
|
3096
|
+
Traversal state for parent-1 innovation walk.
|
|
3097
3097
|
|
|
3098
|
-
###
|
|
3098
|
+
### Parent1TraversalSelectionResult
|
|
3099
3099
|
|
|
3100
|
-
|
|
3100
|
+
Fold result for parent-1 traversal selection.
|
|
3101
3101
|
|
|
3102
|
-
###
|
|
3102
|
+
### ParentMetrics
|
|
3103
3103
|
|
|
3104
|
-
|
|
3104
|
+
Compact parent metrics summary.
|
|
3105
3105
|
|
|
3106
|
-
###
|
|
3106
|
+
### PathSearchContext
|
|
3107
3107
|
|
|
3108
|
-
|
|
3108
|
+
Mutable context used while running iterative path search.
|
|
3109
3109
|
|
|
3110
|
-
###
|
|
3110
|
+
### PerNeuronConcatNodePayload
|
|
3111
3111
|
|
|
3112
|
-
|
|
3112
|
+
Per-neuron concat node payload.
|
|
3113
3113
|
|
|
3114
|
-
###
|
|
3114
|
+
### PerNeuronGraphNames
|
|
3115
3115
|
|
|
3116
|
-
|
|
3116
|
+
Per-neuron graph tensor names.
|
|
3117
3117
|
|
|
3118
|
-
###
|
|
3118
|
+
### PerNeuronLayerContext
|
|
3119
3119
|
|
|
3120
|
-
|
|
3120
|
+
Per-neuron layer context alias.
|
|
3121
3121
|
|
|
3122
|
-
###
|
|
3122
|
+
### PerNeuronLayerParams
|
|
3123
3123
|
|
|
3124
|
-
|
|
3124
|
+
Parameters for per-neuron layer emission.
|
|
3125
3125
|
|
|
3126
|
-
###
|
|
3126
|
+
### PerNeuronNodeContext
|
|
3127
3127
|
|
|
3128
|
-
|
|
3128
|
+
Per-neuron normalized node context.
|
|
3129
3129
|
|
|
3130
|
-
###
|
|
3130
|
+
### PerNeuronSubgraphContext
|
|
3131
3131
|
|
|
3132
|
-
|
|
3132
|
+
Per-neuron subgraph emission context.
|
|
3133
3133
|
|
|
3134
|
-
###
|
|
3134
|
+
### PerNeuronTensorNames
|
|
3135
3135
|
|
|
3136
|
-
|
|
3136
|
+
Per-neuron initializer tensor names.
|
|
3137
3137
|
|
|
3138
|
-
###
|
|
3138
|
+
### PlateauSmoothingConfig
|
|
3139
3139
|
|
|
3140
|
-
|
|
3140
|
+
Config for plateau smoothing computation.
|
|
3141
3141
|
|
|
3142
|
-
###
|
|
3142
|
+
### PlateauSmoothingState
|
|
3143
3143
|
|
|
3144
|
-
|
|
3144
|
+
Mutable smoothing state for plateau metric.
|
|
3145
3145
|
|
|
3146
|
-
###
|
|
3146
|
+
### Pool2DMapping
|
|
3147
3147
|
|
|
3148
|
-
|
|
3148
|
+
Mapping describing a pooling operation inserted after a given export-layer index.
|
|
3149
3149
|
|
|
3150
|
-
|
|
3150
|
+
This is represented as metadata and optional graph nodes during export.
|
|
3151
|
+
Import uses it to attach pooling-related runtime metadata back onto the reconstructed
|
|
3152
|
+
network (when supported).
|
|
3151
3153
|
|
|
3152
|
-
|
|
3154
|
+
### PoolingAttributes
|
|
3153
3155
|
|
|
3154
|
-
|
|
3156
|
+
Pooling tensor attributes for ONNX node payloads.
|
|
3155
3157
|
|
|
3156
|
-
|
|
3158
|
+
### PoolingEmissionContext
|
|
3157
3159
|
|
|
3158
|
-
|
|
3160
|
+
Pooling emission context resolved for one layer output.
|
|
3159
3161
|
|
|
3160
|
-
|
|
3162
|
+
### PoolKeyMetrics
|
|
3161
3163
|
|
|
3162
|
-
|
|
3164
|
+
Per-pool-key allocation & reuse counters (educational / diagnostics).
|
|
3163
3165
|
|
|
3164
|
-
|
|
3166
|
+
### PopulationFitnessFunction
|
|
3165
3167
|
|
|
3166
|
-
|
|
3168
|
+
```ts
|
|
3169
|
+
PopulationFitnessFunction(
|
|
3170
|
+
population: default[],
|
|
3171
|
+
): Promise<void>
|
|
3172
|
+
```
|
|
3167
3173
|
|
|
3168
|
-
|
|
3174
|
+
Fitness signature evaluating full population asynchronously.
|
|
3169
3175
|
|
|
3170
|
-
###
|
|
3176
|
+
### PopulationWorkerEvaluationContext
|
|
3171
3177
|
|
|
3172
|
-
|
|
3178
|
+
Shared context for one population worker evaluation run.
|
|
3173
3179
|
|
|
3174
|
-
###
|
|
3180
|
+
### PrimarySmoothingState
|
|
3175
3181
|
|
|
3176
|
-
|
|
3182
|
+
Mutable smoothing state for monitored error.
|
|
3177
3183
|
|
|
3178
|
-
###
|
|
3184
|
+
### PruneSelectionContext
|
|
3179
3185
|
|
|
3180
|
-
|
|
3186
|
+
Context for selecting prune candidates.
|
|
3181
3187
|
|
|
3182
|
-
###
|
|
3188
|
+
### PruneSelectionResult
|
|
3183
3189
|
|
|
3184
|
-
|
|
3190
|
+
Result of prune candidate selection.
|
|
3185
3191
|
|
|
3186
|
-
###
|
|
3192
|
+
### PruningMethod
|
|
3187
3193
|
|
|
3188
|
-
|
|
3194
|
+
Pruning strategy identifiers.
|
|
3189
3195
|
|
|
3190
|
-
###
|
|
3196
|
+
### PublishAdjacencyContext
|
|
3191
3197
|
|
|
3192
|
-
|
|
3198
|
+
Context for publishing fully built adjacency slabs to internal network state.
|
|
3193
3199
|
|
|
3194
|
-
###
|
|
3200
|
+
### ReconnectEndpointPairContext
|
|
3195
3201
|
|
|
3196
|
-
|
|
3202
|
+
Endpoint pair for reconnecting bridged paths.
|
|
3197
3203
|
|
|
3198
|
-
###
|
|
3204
|
+
### RecurrentActivationEmissionContext
|
|
3199
3205
|
|
|
3200
|
-
Context for
|
|
3206
|
+
Context for selecting and emitting recurrent activation node payload.
|
|
3201
3207
|
|
|
3202
|
-
###
|
|
3208
|
+
### RecurrentGateBlockCollectionContext
|
|
3203
3209
|
|
|
3204
|
-
|
|
3210
|
+
Context for collecting one gate parameter block.
|
|
3205
3211
|
|
|
3206
|
-
###
|
|
3212
|
+
### RecurrentGateParameterCollectionResult
|
|
3207
3213
|
|
|
3208
|
-
|
|
3214
|
+
Flattened recurrent gate parameter vectors for one fused operator.
|
|
3209
3215
|
|
|
3210
|
-
###
|
|
3216
|
+
### RecurrentGateRow
|
|
3211
3217
|
|
|
3212
|
-
|
|
3218
|
+
One recurrent gate row payload before flatten fold.
|
|
3213
3219
|
|
|
3214
|
-
###
|
|
3220
|
+
### RecurrentGateRowCollectionContext
|
|
3215
3221
|
|
|
3216
|
-
Context for
|
|
3222
|
+
Context for collecting one recurrent gate row (one neuron).
|
|
3217
3223
|
|
|
3218
|
-
###
|
|
3224
|
+
### RecurrentGemmEmissionContext
|
|
3219
3225
|
|
|
3220
|
-
|
|
3226
|
+
Context for emitting one Gemm node for recurrent single-step export.
|
|
3221
3227
|
|
|
3222
|
-
###
|
|
3228
|
+
### RecurrentGraphNames
|
|
3223
3229
|
|
|
3224
|
-
|
|
3230
|
+
Derived graph names for one recurrent single-step layer payload.
|
|
3225
3231
|
|
|
3226
|
-
###
|
|
3232
|
+
### RecurrentHeuristicEmissionContext
|
|
3227
3233
|
|
|
3228
|
-
|
|
3234
|
+
Context for heuristic recurrent operator emission traversal.
|
|
3229
3235
|
|
|
3230
|
-
|
|
3231
|
-
reconstructed nodes, an input wiring hook, and an optional output group that
|
|
3232
|
-
can be reconnected to the next restored layer.
|
|
3236
|
+
### RecurrentInitializerEmissionContext
|
|
3233
3237
|
|
|
3234
|
-
|
|
3238
|
+
Context for pushing recurrent initializers into ONNX graph state.
|
|
3235
3239
|
|
|
3236
|
-
|
|
3240
|
+
### RecurrentInitializerNames
|
|
3237
3241
|
|
|
3238
|
-
|
|
3242
|
+
Initializer tensor names for one single-step recurrent layer.
|
|
3239
3243
|
|
|
3240
|
-
|
|
3244
|
+
### RecurrentInitializerValues
|
|
3241
3245
|
|
|
3242
|
-
|
|
3243
|
-
how many gates to expect, what order those gates were serialized in, and
|
|
3244
|
-
which gate owns the self-recurrent diagonal replay.
|
|
3246
|
+
Collected initializer vectors for one single-step recurrent layer.
|
|
3245
3247
|
|
|
3246
|
-
###
|
|
3248
|
+
### RecurrentLayerEmissionContext
|
|
3247
3249
|
|
|
3248
|
-
|
|
3250
|
+
Derived execution context for single-step recurrent layer emission.
|
|
3249
3251
|
|
|
3250
|
-
|
|
3251
|
-
reconstruction pass can focus on wiring and row assignment instead of
|
|
3252
|
-
repeatedly re-looking up initializers.
|
|
3252
|
+
### RecurrentLayerEmissionParams
|
|
3253
3253
|
|
|
3254
|
-
|
|
3254
|
+
Parameters for single-step recurrent layer emission.
|
|
3255
3255
|
|
|
3256
|
-
|
|
3256
|
+
### RecurrentLayerShape
|
|
3257
3257
|
|
|
3258
|
-
|
|
3258
|
+
Minimal recurrent-layer shape used by mutation expanders.
|
|
3259
3259
|
|
|
3260
|
-
|
|
3260
|
+
### RecurrentRowCollectionContext
|
|
3261
3261
|
|
|
3262
|
-
|
|
3262
|
+
Context for collecting one recurrent matrix row.
|
|
3263
3263
|
|
|
3264
|
-
|
|
3264
|
+
### RegrowthExecutionContext
|
|
3265
3265
|
|
|
3266
|
-
|
|
3266
|
+
Context for regrowth execution routine.
|
|
3267
3267
|
|
|
3268
|
-
|
|
3268
|
+
### RegrowthPlan
|
|
3269
3269
|
|
|
3270
|
-
|
|
3270
|
+
Derived regrowth execution plan.
|
|
3271
3271
|
|
|
3272
|
-
|
|
3273
|
-
OnnxRuntimeLayerFactory(
|
|
3274
|
-
size: number,
|
|
3275
|
-
): default
|
|
3276
|
-
```
|
|
3272
|
+
### RegrowthPlanContext
|
|
3277
3273
|
|
|
3278
|
-
|
|
3274
|
+
Context for deriving regrowth plan.
|
|
3279
3275
|
|
|
3280
|
-
###
|
|
3276
|
+
### RegularizationConfig
|
|
3281
3277
|
|
|
3282
|
-
|
|
3278
|
+
L1/L2 regularization configuration.
|
|
3283
3279
|
|
|
3284
|
-
###
|
|
3280
|
+
### ResolvedNetworkSizeContext
|
|
3285
3281
|
|
|
3286
|
-
|
|
3287
|
-
OnnxRuntimePerceptronFactory(
|
|
3288
|
-
sizes: number[],
|
|
3289
|
-
): default
|
|
3290
|
-
```
|
|
3282
|
+
Resolved input/output sizes for rebuild.
|
|
3291
3283
|
|
|
3292
|
-
|
|
3284
|
+
Values reflect override-first resolution semantics used during deserialization.
|
|
3293
3285
|
|
|
3294
|
-
###
|
|
3286
|
+
### RNGSnapshot
|
|
3295
3287
|
|
|
3296
|
-
|
|
3288
|
+
Snapshot payload for RNG state restore flows.
|
|
3297
3289
|
|
|
3298
|
-
|
|
3299
|
-
needs (connections, bias, squash). Regular library users should generally interact with
|
|
3300
|
-
the public `Node` API instead.
|
|
3290
|
+
### ScheduleConfig
|
|
3301
3291
|
|
|
3302
|
-
|
|
3292
|
+
Schedule callback configuration.
|
|
3303
3293
|
|
|
3304
|
-
|
|
3294
|
+
A schedule callback is a simple "tick hook" that runs every N iterations.
|
|
3295
|
+
Typical uses include logging, custom learning-rate schedules, or diagnostics.
|
|
3305
3296
|
|
|
3306
|
-
###
|
|
3297
|
+
### ScheduledTargetContext
|
|
3307
3298
|
|
|
3308
|
-
|
|
3309
|
-
ActivationFunction(
|
|
3310
|
-
x: number,
|
|
3311
|
-
derivate: boolean | undefined,
|
|
3312
|
-
): number
|
|
3313
|
-
```
|
|
3299
|
+
Context for scheduled-pruning target computation.
|
|
3314
3300
|
|
|
3315
|
-
|
|
3301
|
+
### ScheduledTargetResult
|
|
3316
3302
|
|
|
3317
|
-
|
|
3318
|
-
- `derivate === false | undefined`: return activation output $f(x)$
|
|
3319
|
-
- `derivate === true`: return derivative $f'(x)$
|
|
3303
|
+
Result of scheduled-pruning target computation.
|
|
3320
3304
|
|
|
3321
|
-
|
|
3305
|
+
### SerializedConnection
|
|
3322
3306
|
|
|
3323
|
-
|
|
3307
|
+
Serialized connection representation used by compact and JSON formats.
|
|
3324
3308
|
|
|
3325
|
-
|
|
3326
|
-
const y = activation(x);
|
|
3327
|
-
const dy = activation(x, true);
|
|
3328
|
-
```
|
|
3309
|
+
Endpoints are canonical node indices, which keeps payloads deterministic and language-agnostic.
|
|
3329
3310
|
|
|
3330
|
-
###
|
|
3311
|
+
### SerializedNetwork
|
|
3331
3312
|
|
|
3332
|
-
|
|
3313
|
+
Serialized network payload used in checkpoint callbacks.
|
|
3333
3314
|
|
|
3334
|
-
|
|
3315
|
+
This is intentionally loose: serialization formats evolve and may include nested
|
|
3316
|
+
structures. Treat this as an opaque snapshot blob.
|
|
3335
3317
|
|
|
3336
|
-
|
|
3318
|
+
### SerializeNetworkInternals
|
|
3337
3319
|
|
|
3338
|
-
|
|
3320
|
+
Runtime interface for accessing network internals during serialization.
|
|
3339
3321
|
|
|
3340
|
-
|
|
3322
|
+
This is an internal bridge type used by serializer helpers to read and rebuild
|
|
3323
|
+
topology without exposing private implementation details in public APIs.
|
|
3341
3324
|
|
|
3342
|
-
###
|
|
3325
|
+
### SerializeNodeInternals
|
|
3343
3326
|
|
|
3344
|
-
|
|
3327
|
+
Runtime node internals needed for serialization workflows.
|
|
3345
3328
|
|
|
3346
|
-
|
|
3329
|
+
These fields are the minimal node state required to round-trip compact and JSON payloads.
|
|
3347
3330
|
|
|
3348
|
-
|
|
3331
|
+
### SharedActivationNodeBuildParams
|
|
3349
3332
|
|
|
3350
|
-
|
|
3333
|
+
Shared parameters for constructing an activation node payload.
|
|
3351
3334
|
|
|
3352
|
-
|
|
3335
|
+
### SharedGemmNodeBuildParams
|
|
3353
3336
|
|
|
3354
|
-
|
|
3337
|
+
Shared parameters for constructing a Gemm node payload.
|
|
3355
3338
|
|
|
3356
|
-
|
|
3339
|
+
### SingleGenomeFitnessFunction
|
|
3357
3340
|
|
|
3358
|
-
|
|
3341
|
+
```ts
|
|
3342
|
+
SingleGenomeFitnessFunction(
|
|
3343
|
+
genome: default,
|
|
3344
|
+
): number
|
|
3345
|
+
```
|
|
3359
3346
|
|
|
3360
|
-
|
|
3347
|
+
Fitness signature evaluating one genome.
|
|
3361
3348
|
|
|
3362
|
-
###
|
|
3349
|
+
### SLAB_DEFAULT_ASYNC_CHUNK_SIZE
|
|
3363
3350
|
|
|
3364
|
-
|
|
3351
|
+
Default async slab rebuild chunk size when no override is provided.
|
|
3365
3352
|
|
|
3366
|
-
###
|
|
3353
|
+
### SLAB_GROWTH_FACTOR_BROWSER
|
|
3367
3354
|
|
|
3368
|
-
|
|
3355
|
+
Capacity growth factor for browser slab allocations.
|
|
3369
3356
|
|
|
3370
|
-
###
|
|
3357
|
+
### SLAB_GROWTH_FACTOR_NODE
|
|
3371
3358
|
|
|
3372
|
-
|
|
3359
|
+
Capacity growth factor for Node.js slab allocations.
|
|
3373
3360
|
|
|
3374
|
-
###
|
|
3361
|
+
### SLAB_ONE
|
|
3375
3362
|
|
|
3376
|
-
|
|
3363
|
+
Numeric one sentinel used for neutral gain defaults and index math.
|
|
3377
3364
|
|
|
3378
|
-
###
|
|
3365
|
+
### SLAB_ZERO
|
|
3379
3366
|
|
|
3380
|
-
|
|
3367
|
+
Numeric zero sentinel used across slab orchestration and helper pipelines.
|
|
3381
3368
|
|
|
3382
|
-
###
|
|
3369
|
+
### SlabBuildContext
|
|
3383
3370
|
|
|
3384
|
-
|
|
3371
|
+
Immutable inputs required to build or grow connection slab buffers.
|
|
3385
3372
|
|
|
3386
|
-
###
|
|
3373
|
+
### SlabPopulateResult
|
|
3387
3374
|
|
|
3388
|
-
|
|
3375
|
+
Result of scanning and populating optional gain/plastic slab arrays.
|
|
3389
3376
|
|
|
3390
|
-
###
|
|
3377
|
+
### SlabWriteArrays
|
|
3391
3378
|
|
|
3392
|
-
|
|
3379
|
+
Writable slab arrays targeted during connection serialization.
|
|
3393
3380
|
|
|
3394
|
-
###
|
|
3381
|
+
### SourcePeerConnectionCountContext
|
|
3395
3382
|
|
|
3396
|
-
|
|
3383
|
+
Context for source-to-peer connection counting.
|
|
3397
3384
|
|
|
3398
|
-
###
|
|
3385
|
+
### SpecMetadataAppendContext
|
|
3399
3386
|
|
|
3400
|
-
|
|
3387
|
+
Append-a-spec metadata context for JSON-array metadata keys.
|
|
3401
3388
|
|
|
3402
|
-
###
|
|
3389
|
+
### StandaloneGenerationContext
|
|
3403
3390
|
|
|
3404
|
-
|
|
3391
|
+
Shared mutable state for standalone source generation.
|
|
3405
3392
|
|
|
3406
|
-
###
|
|
3393
|
+
### StartIndicesBuildContext
|
|
3407
3394
|
|
|
3408
|
-
|
|
3395
|
+
Context for constructing CSR start offsets from precomputed fan-out counts.
|
|
3409
3396
|
|
|
3410
|
-
###
|
|
3397
|
+
### StatsNetworkProps
|
|
3411
3398
|
|
|
3412
|
-
Internal
|
|
3399
|
+
Internal network properties used by stats operations.
|
|
3413
3400
|
|
|
3414
|
-
###
|
|
3401
|
+
### SubNodeMutationConfig
|
|
3415
3402
|
|
|
3416
|
-
|
|
3403
|
+
Mutation keep-gates option surface used by sub-node removal logic.
|
|
3417
3404
|
|
|
3418
|
-
###
|
|
3405
|
+
### TargetLayerPeerContext
|
|
3419
3406
|
|
|
3420
|
-
|
|
3407
|
+
Context for target-layer peer traversal.
|
|
3421
3408
|
|
|
3422
|
-
###
|
|
3409
|
+
### TopologyBuildContext
|
|
3423
3410
|
|
|
3424
|
-
|
|
3411
|
+
Mutable context used while building topological ordering.
|
|
3425
3412
|
|
|
3426
|
-
###
|
|
3413
|
+
### TopologyNetworkProps
|
|
3427
3414
|
|
|
3428
|
-
|
|
3415
|
+
Internal topology state carrier.
|
|
3429
3416
|
|
|
3430
|
-
###
|
|
3417
|
+
### TrainingConnectionInternals
|
|
3431
3418
|
|
|
3432
|
-
Runtime
|
|
3419
|
+
Runtime connection view used by training internals.
|
|
3433
3420
|
|
|
3434
|
-
###
|
|
3421
|
+
### TrainingNetworkInternals
|
|
3435
3422
|
|
|
3436
|
-
Runtime
|
|
3423
|
+
Runtime network view used by training internals.
|
|
3437
3424
|
|
|
3438
|
-
###
|
|
3425
|
+
### TrainingNodeInternals
|
|
3439
3426
|
|
|
3440
|
-
|
|
3427
|
+
Runtime node view used by training internals.
|
|
3441
3428
|
|
|
3442
|
-
###
|
|
3429
|
+
### TrainingOptions
|
|
3443
3430
|
|
|
3444
|
-
|
|
3431
|
+
Public training options accepted by the high-level training orchestration.
|
|
3445
3432
|
|
|
3446
|
-
|
|
3433
|
+
Training in this codebase is conceptually:
|
|
3434
|
+
1) forward activation
|
|
3435
|
+
2) backward propagation
|
|
3436
|
+
3) optimizer update
|
|
3437
|
+
repeated until a stopping condition is met.
|
|
3447
3438
|
|
|
3448
|
-
|
|
3439
|
+
Minimal example:
|
|
3449
3440
|
|
|
3450
|
-
|
|
3441
|
+
```ts
|
|
3442
|
+
net.train(set, {
|
|
3443
|
+
iterations: 500,
|
|
3444
|
+
rate: 0.3,
|
|
3445
|
+
batchSize: 16,
|
|
3446
|
+
gradientClip: { mode: 'norm', maxNorm: 1 },
|
|
3447
|
+
});
|
|
3448
|
+
```
|
|
3451
3449
|
|
|
3452
|
-
|
|
3450
|
+
Stopping conditions:
|
|
3451
|
+
- Provide at least one of `iterations` or `error`.
|
|
3452
|
+
- `earlyStopPatience` adds an additional "stop when no improvement" guard.
|
|
3453
3453
|
|
|
3454
|
-
###
|
|
3454
|
+
### TrainingSample
|
|
3455
3455
|
|
|
3456
|
-
|
|
3456
|
+
A single supervised training sample used in evolution scoring.
|
|
3457
3457
|
|
|
3458
|
-
###
|
|
3458
|
+
### TypedArray
|
|
3459
3459
|
|
|
3460
|
-
|
|
3460
|
+
Union of slab typed array element container types.
|
|
3461
3461
|
|
|
3462
|
-
###
|
|
3462
|
+
### TypedArrayConstructor
|
|
3463
3463
|
|
|
3464
|
-
|
|
3464
|
+
Constructor type for typed arrays used in slabs.
|
|
3465
3465
|
|
|
3466
|
-
###
|
|
3466
|
+
### WeightSamplingRangeContext
|
|
3467
3467
|
|
|
3468
|
-
Context for
|
|
3468
|
+
Context for sampling one random weight value.
|
|
3469
3469
|
|
|
3470
|
-
###
|
|
3470
|
+
### WeightToleranceComparisonContext
|
|
3471
3471
|
|
|
3472
|
-
Context for
|
|
3472
|
+
Context for comparing two scalar weights with numeric tolerance.
|
|
3473
3473
|
|
|
3474
|
-
###
|
|
3474
|
+
### WorkerTraversalContext
|
|
3475
3475
|
|
|
3476
|
-
|
|
3476
|
+
Worker-local traversal context.
|