@reicek/neataptic-ts 0.1.21 → 0.1.23
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/agents/boundary-mapper.agent.md +31 -0
- package/.github/agents/docs-scout.agent.md +29 -0
- package/.github/agents/plan-scout.agent.md +31 -0
- package/.github/agents/solid-split.agent.md +143 -0
- package/.github/copilot-instructions.md +119 -0
- package/.github/skills/solid-split-playbook/SKILL.md +220 -0
- package/.github/skills/solid-split-playbook/assets/docs-checklist.md +34 -0
- package/.github/skills/solid-split-playbook/assets/split-plan-template.md +48 -0
- package/.github/skills/solid-split-playbook/assets/split-workflow-checklist.md +51 -0
- package/.github/skills/trace-analyzer-extension/SKILL.md +63 -0
- package/.github/skills/trace-analyzer-extension/assets/extension-checklist.md +24 -0
- package/.github/skills/trace-analyzer-extension/references/analyzer-extension-workflow.md +101 -0
- package/.github/skills/trace-audit-reporting/SKILL.md +96 -0
- package/.github/skills/trace-audit-reporting/assets/performance-report-template.md +123 -0
- package/.github/skills/trace-audit-reporting/references/trace-analysis-workflow.md +132 -0
- package/package.json +7 -3
- package/plans/ES2023 migration +13 -8
- package/plans/Evolution_Training_Interoperability_Contracts.md +1 -1
- package/plans/Flappy_Bird_Folder_Documentation_Pass.md +53 -0
- package/plans/Flappy_Evolution_Worker_Documentation_Pass.md +58 -0
- package/plans/Interactive_Examples_and_Learning_Path.md +10 -2
- package/plans/Memory_Optimization.md +3 -3
- package/plans/README.md +63 -0
- package/plans/Roadmap.md +15 -3
- package/plans/asciiMaze_SOLID_split.done.md +130 -0
- package/plans/flappy_bird_SOLID_split.done.md +67 -0
- package/scripts/analyze-trace.ts +590 -0
- package/scripts/assets/theme.css +221 -34
- package/scripts/copy-examples.mjs +9 -5
- package/scripts/export-onnx.mjs +3 -3
- package/scripts/generate-bench-tables.mjs +10 -10
- package/scripts/generate-bench-tables.ts +10 -10
- package/scripts/generate-docs.ts +1415 -449
- package/scripts/render-docs-html.ts +15 -8
- package/src/README.md +127 -222
- package/src/architecture/README.md +117 -184
- package/src/architecture/architect.ts +6 -0
- package/src/architecture/layer/README.md +38 -38
- package/src/architecture/network/README.md +49 -31
- package/src/architecture/network/activate/README.md +77 -77
- package/src/architecture/network/connect/README.md +15 -13
- package/src/architecture/network/deterministic/README.md +7 -7
- package/src/architecture/network/evolve/README.md +44 -44
- package/src/architecture/network/gating/README.md +20 -20
- package/src/architecture/network/genetic/README.md +51 -51
- package/src/architecture/network/mutate/README.md +97 -97
- package/src/architecture/network/network.types.ts +39 -0
- package/src/architecture/network/onnx/README.md +264 -264
- package/src/architecture/network/prune/README.md +39 -39
- package/src/architecture/network/remove/README.md +26 -26
- package/src/architecture/network/serialize/README.md +56 -56
- package/src/architecture/network/serialize/network.serialize.json.utils.ts +1 -0
- package/src/architecture/network/serialize/network.serialize.utils.ts +6 -1
- package/src/architecture/network/serialize/network.serialize.utils.types.ts +1 -1
- package/src/architecture/network/slab/README.md +61 -61
- package/src/architecture/network/standalone/README.md +24 -24
- package/src/architecture/network/stats/README.md +9 -9
- package/src/architecture/network/topology/README.md +46 -46
- package/src/architecture/network/training/README.md +21 -21
- package/src/architecture/network.ts +114 -10
- package/src/methods/README.md +9 -87
- package/src/multithreading/README.md +8 -77
- package/src/multithreading/workers/README.md +2 -2
- package/src/multithreading/workers/browser/README.md +0 -6
- package/src/multithreading/workers/node/README.md +0 -3
- package/src/neat/README.md +623 -568
- package/src/neat/neat.evolve.population.utils.ts +29 -5
- package/src/neat/neat.helpers.ts +16 -0
- package/src/neat/neat.topology-intent.utils.ts +160 -0
- package/src/utils/README.md +18 -18
- package/test/examples/asciiMaze/README.md +59 -59
- package/test/examples/asciiMaze/asciiMaze.e2e.test.ts +14 -9
- package/test/examples/asciiMaze/browser-entry/README.md +196 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.abort.services.ts +95 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.constants.ts +23 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.curriculum.services.ts +115 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.globals.services.ts +106 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.host.services.ts +157 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.services.ts +14 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.ts +129 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.types.ts +120 -0
- package/test/examples/asciiMaze/browser-entry/browser-entry.utils.ts +98 -0
- package/test/examples/asciiMaze/browser-entry.ts +10 -576
- package/test/examples/asciiMaze/dashboardManager/README.md +276 -0
- package/test/examples/asciiMaze/dashboardManager/archive/README.md +16 -0
- package/test/examples/asciiMaze/dashboardManager/archive/dashboardManager.archive.services.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.constants.ts +35 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.services.ts +103 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.ts +181 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.types.ts +267 -0
- package/test/examples/asciiMaze/dashboardManager/dashboardManager.utils.ts +254 -0
- package/test/examples/asciiMaze/dashboardManager/live/README.md +14 -0
- package/test/examples/asciiMaze/dashboardManager/live/dashboardManager.live.services.ts +264 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/README.md +47 -0
- package/test/examples/asciiMaze/dashboardManager/telemetry/dashboardManager.telemetry.services.ts +513 -0
- package/test/examples/asciiMaze/dashboardManager.ts +13 -2335
- package/test/examples/asciiMaze/evolutionEngine/README.md +1058 -0
- package/test/examples/asciiMaze/evolutionEngine/curriculumPhase.ts +90 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.constants.ts +36 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.ts +58 -513
- package/test/examples/asciiMaze/evolutionEngine/engineState.types.ts +212 -0
- package/test/examples/asciiMaze/evolutionEngine/engineState.utils.ts +301 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionEngine.types.ts +445 -0
- package/test/examples/asciiMaze/evolutionEngine/evolutionLoop.ts +81 -50
- package/test/examples/asciiMaze/evolutionEngine/optionsAndSetup.ts +2 -4
- package/test/examples/asciiMaze/evolutionEngine/populationDynamics.ts +17 -33
- package/test/examples/asciiMaze/evolutionEngine/populationPruning.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/rngAndTiming.ts +1 -2
- package/test/examples/asciiMaze/evolutionEngine/sampling.ts +1 -1
- package/test/examples/asciiMaze/evolutionEngine/scratchPools.ts +2 -5
- package/test/examples/asciiMaze/evolutionEngine/setupHelpers.ts +30 -37
- package/test/examples/asciiMaze/evolutionEngine/telemetryMetrics.ts +16 -58
- package/test/examples/asciiMaze/evolutionEngine/trainingWarmStart.ts +2 -2
- package/test/examples/asciiMaze/evolutionEngine.ts +55 -55
- package/test/examples/asciiMaze/fitness.ts +2 -2
- package/test/examples/asciiMaze/fitness.types.ts +65 -0
- package/test/examples/asciiMaze/interfaces.ts +64 -1352
- package/test/examples/asciiMaze/mazeMovement/README.md +356 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/README.md +49 -0
- package/test/examples/asciiMaze/mazeMovement/finalization/mazeMovement.finalization.ts +138 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.constants.ts +101 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.services.ts +230 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.ts +299 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.types.ts +185 -0
- package/test/examples/asciiMaze/mazeMovement/mazeMovement.utils.ts +153 -0
- package/test/examples/asciiMaze/mazeMovement/policy/README.md +91 -0
- package/test/examples/asciiMaze/mazeMovement/policy/mazeMovement.policy.ts +467 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/README.md +95 -0
- package/test/examples/asciiMaze/mazeMovement/runtime/mazeMovement.runtime.ts +354 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/README.md +124 -0
- package/test/examples/asciiMaze/mazeMovement/shaping/mazeMovement.shaping.ts +459 -0
- package/test/examples/asciiMaze/mazeMovement.ts +12 -2978
- package/test/examples/flappy_bird/README.md +193 -88
- package/test/examples/flappy_bird/browser-entry/README.md +1441 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.host.utils.ts +4 -324
- package/test/examples/flappy_bird/browser-entry/browser-entry.network-view.utils.ts +9 -396
- package/test/examples/flappy_bird/browser-entry/browser-entry.playback.utils.ts +6 -714
- package/test/examples/flappy_bird/browser-entry/browser-entry.render.types.ts +26 -3
- package/test/examples/flappy_bird/browser-entry/browser-entry.runtime.types.ts +16 -1
- package/test/examples/flappy_bird/browser-entry/browser-entry.simulation.types.ts +39 -5
- package/test/examples/flappy_bird/browser-entry/browser-entry.spawn.utils.ts +11 -31
- package/test/examples/flappy_bird/browser-entry/browser-entry.stats.types.ts +32 -4
- package/test/examples/flappy_bird/browser-entry/browser-entry.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.types.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.types.ts +50 -7
- package/test/examples/flappy_bird/browser-entry/browser-entry.visualization.utils.ts +21 -893
- package/test/examples/flappy_bird/browser-entry/browser-entry.worker.types.ts +91 -10
- package/test/examples/flappy_bird/browser-entry/host/README.md +318 -0
- package/test/examples/flappy_bird/browser-entry/host/host.canvas.service.ts +16 -0
- package/test/examples/flappy_bird/browser-entry/host/host.constants.ts +20 -0
- package/test/examples/flappy_bird/browser-entry/host/host.dom.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/host/host.resize.service.ts +1 -295
- package/test/examples/flappy_bird/browser-entry/host/host.stats.service.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/host/host.ts +592 -6
- package/test/examples/flappy_bird/browser-entry/host/host.types.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/README.md +309 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.constants.ts +47 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.services.ts +392 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.types.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/host/resize/host.resize.service.utils.ts +272 -0
- package/test/examples/flappy_bird/browser-entry/network-view/README.md +389 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.draw.service.ts +13 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.labels.utils.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.layout.utils.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.topology.utils.ts +267 -0
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.ts +823 -7
- package/test/examples/flappy_bird/browser-entry/network-view/network-view.types.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/README.md +845 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/README.md +355 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/README.md +1068 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.batch.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.cache.services.ts +207 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.constants.ts +197 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.batch.utils.ts +114 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.test.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.layout.utils.ts +204 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.services.ts +49 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.geometry.utils.ts +313 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.layer.services.ts +81 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.test.ts +33 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.math.utils.ts +201 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.selection.utils.ts +171 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.timing.utils.ts +124 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.test.ts +279 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.pulse.utils.ts +132 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.scene.services.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.services.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.ts +48 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.types.ts +342 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/ground-grid/playback.background.ground-grid.utils.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.cache.services.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.constants.ts +127 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.draw.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.scene.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.services.ts +6 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.types.ts +105 -0
- package/test/examples/flappy_bird/browser-entry/playback/background/playback.background.utils.ts +100 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/README.md +541 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.bird.utils.ts +180 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.canvas.services.ts +77 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.entity.services.ts +167 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.scene.services.ts +57 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.test.ts +176 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.service.ts +113 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.services.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.trail.utils.ts +248 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.types.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/frame-render/playback.frame-render.utils.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.constants.ts +1 -1
- package/test/examples/flappy_bird/browser-entry/playback/playback.frame-render.service.ts +10 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.iteration.services.ts +192 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.loop.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.orchestration.types.ts +78 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.pipe-outline.service.ts +128 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.render.service.ts +1 -116
- package/test/examples/flappy_bird/browser-entry/playback/playback.session.services.ts +184 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.test.ts +121 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.snapshot.utils.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.layer.services.ts +36 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.service.ts +11 -128
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.services.ts +268 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.types.ts +91 -0
- package/test/examples/flappy_bird/browser-entry/playback/playback.starfield.utils.ts +11 -4
- package/test/examples/flappy_bird/browser-entry/playback/playback.trail.utils.ts +9 -86
- package/test/examples/flappy_bird/browser-entry/playback/playback.ts +75 -7
- package/test/examples/flappy_bird/browser-entry/playback/playback.types.ts +12 -9
- package/test/examples/flappy_bird/browser-entry/playback/playback.worker-channel.utils.ts +11 -123
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/README.md +55 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.services.ts +103 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.test.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/snapshot/playback.snapshot.summary.utils.ts +28 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/README.md +95 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.test.ts +35 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.history.services.ts +64 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.test.ts +37 -0
- package/test/examples/flappy_bird/browser-entry/playback/trail/playback.trail.opacity.utils.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/README.md +71 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.request.services.ts +45 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.summary.services.ts +74 -0
- package/test/examples/flappy_bird/browser-entry/playback/worker-channel/playback.worker-channel.types.ts +53 -0
- package/test/examples/flappy_bird/browser-entry/runtime/README.md +304 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.browser-globals.service.ts +15 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.errors.ts +17 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-launch.service.ts +56 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.evolution-loop.service.ts +19 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.lifecycle.service.ts +96 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.startup.service.ts +92 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.telemetry.service.ts +24 -0
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.ts +31 -121
- package/test/examples/flappy_bird/browser-entry/runtime/runtime.types.ts +65 -0
- package/test/examples/flappy_bird/browser-entry/visualization/README.md +568 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.colors.utils.ts +26 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.constants.ts +110 -0
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.draw.service.ts +979 -19
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.legend.utils.ts +157 -3
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.topology.utils.ts +13 -27
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.ts +7 -20
- package/test/examples/flappy_bird/browser-entry/visualization/visualization.types.ts +14 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/README.md +238 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.errors.ts +11 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.generation.service.ts +12 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.test.ts +143 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.playback.service.ts +140 -14
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.request.service.ts +27 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.ts +8 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.types.ts +23 -0
- package/test/examples/flappy_bird/browser-entry/worker-channel/worker-channel.url.service.ts +5 -0
- package/test/examples/flappy_bird/constants/README.md +1163 -0
- package/test/examples/flappy_bird/constants/constants.birds.ts +16 -38
- package/test/examples/flappy_bird/constants/constants.difficulty.ts +21 -0
- package/test/examples/flappy_bird/constants/constants.network-view.ts +24 -0
- package/test/examples/flappy_bird/constants/constants.network.ts +1 -1
- package/test/examples/flappy_bird/constants/constants.observation.ts +7 -0
- package/test/examples/flappy_bird/constants/constants.palette.ts +9 -2
- package/test/examples/flappy_bird/constants/constants.physics.ts +9 -0
- package/test/examples/flappy_bird/constants/constants.pipe-render.ts +3 -0
- package/test/examples/flappy_bird/constants/constants.pipes.ts +22 -3
- package/test/examples/flappy_bird/constants/constants.runtime.ts +28 -4
- package/test/examples/flappy_bird/constants/constants.starfield.ts +78 -3
- package/test/examples/flappy_bird/constants/constants.ts +6 -0
- package/test/examples/flappy_bird/environment/README.md +182 -0
- package/test/examples/flappy_bird/environment/environment.collision.utils.ts +7 -0
- package/test/examples/flappy_bird/environment/environment.constants.ts +16 -3
- package/test/examples/flappy_bird/environment/environment.observation.utils.ts +12 -19
- package/test/examples/flappy_bird/environment/environment.state.service.ts +10 -0
- package/test/examples/flappy_bird/environment/environment.step.service.ts +15 -66
- package/test/examples/flappy_bird/environment/environment.types.ts +14 -0
- package/test/examples/flappy_bird/evaluation/README.md +155 -0
- package/test/examples/flappy_bird/evaluation/evaluation.constants.ts +23 -4
- package/test/examples/flappy_bird/evaluation/evaluation.fitness.utils.ts +16 -1
- package/test/examples/flappy_bird/evaluation/evaluation.rollout.service.ts +7 -374
- package/test/examples/flappy_bird/evaluation/evaluation.seed.utils.ts +4 -0
- package/test/examples/flappy_bird/evaluation/evaluation.types.ts +18 -2
- package/test/examples/flappy_bird/evaluation/rollout/README.md +355 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.constants.ts +38 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.service.ts +71 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.services.ts +338 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.types.ts +69 -0
- package/test/examples/flappy_bird/evaluation/rollout/evaluation.rollout.utils.ts +399 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/README.md +845 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.constants.ts +49 -7
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.errors.ts +34 -3
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.evolution.service.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.playback.service.ts +62 -26
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.protocol.service.ts +27 -1
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.runtime.service.ts +23 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.frame.service.ts +378 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.types.ts +22 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.simulation.utils.ts +20 -203
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.test.ts +94 -0
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.snapshot.utils.ts +78 -13
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.ts +235 -344
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.types.ts +170 -22
- package/test/examples/flappy_bird/flappy-evolution-worker/flappy-evolution-worker.warm-start.service.ts +314 -0
- package/test/examples/flappy_bird/flappy.simulation.shared.utils.ts +17 -0
- package/test/examples/flappy_bird/flappyEnvironment.ts +21 -0
- package/test/examples/flappy_bird/flappyEvaluation.ts +12 -0
- package/test/examples/flappy_bird/flappyEvolution.worker.ts +7 -0
- package/test/examples/flappy_bird/index.ts +8 -2
- package/test/examples/flappy_bird/rng.ts +10 -0
- package/test/examples/flappy_bird/simulation-shared/README.md +518 -0
- package/test/examples/flappy_bird/simulation-shared/observation/README.md +255 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.features.utils.ts +339 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.ts +19 -0
- package/test/examples/flappy_bird/simulation-shared/observation/observation.vector.utils.ts +81 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.constants.ts +3 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.control.utils.ts +6 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.difficulty.utils.ts +9 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.errors.ts +10 -1
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.memory.utils.ts +18 -0
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.observation.utils.ts +7 -402
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.spawn.utils.ts +36 -6
- package/test/examples/flappy_bird/{evaluation/evaluation.statistics.utils.ts → simulation-shared/simulation-shared.statistics.utils.ts} +30 -9
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.types.ts +38 -5
- package/test/examples/flappy_bird/trainFlappyBird.ts +13 -0
- package/test/examples/flappy_bird/trainer/README.md +676 -0
- package/test/examples/flappy_bird/trainer/evaluation/README.md +253 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.constants.ts +15 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.services.ts +86 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.ts +187 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.types.ts +32 -0
- package/test/examples/flappy_bird/trainer/evaluation/trainer.evaluation.service.utils.ts +182 -0
- package/test/examples/flappy_bird/trainer/trainer.evaluation.service.ts +13 -0
- package/test/examples/flappy_bird/trainer/trainer.fitness.service.ts +23 -1
- package/test/examples/flappy_bird/trainer/trainer.loop.service.ts +17 -1
- package/test/examples/flappy_bird/trainer/trainer.report.service.services.ts +181 -0
- package/test/examples/flappy_bird/trainer/trainer.report.service.ts +136 -0
- package/test/examples/flappy_bird/trainer/trainer.selection.utils.ts +89 -0
- package/test/examples/flappy_bird/trainer/trainer.setup.service.ts +22 -0
- package/test/examples/flappy_bird/trainer/trainer.signals.service.ts +8 -0
- package/test/examples/flappy_bird/trainer/trainer.ts +38 -553
- package/test/examples/flappy_bird/trainer/trainer.types.ts +44 -7
- package/test/neat/neat.topology-intent.test.ts +129 -0
- package/test/network/network.topology-intent.test.ts +44 -0
- package/test/examples/flappy_bird/browser-entry/browser-entry.utils.ts +0 -12
- package/test/examples/flappy_bird/environment/environment.ts +0 -7
- package/test/examples/flappy_bird/evaluation/evaluation.ts +0 -7
- package/test/examples/flappy_bird/simulation-shared/simulation-shared.ts +0 -15
- package/test/examples/flappy_bird/trainer/trainer.statistics.utils.ts +0 -78
|
@@ -49,12 +49,76 @@ import type {
|
|
|
49
49
|
NetworkArchitectureDescriptor,
|
|
50
50
|
ConnectionWeightNoiseProps,
|
|
51
51
|
MutationMethod,
|
|
52
|
+
NetworkConstructorOptions,
|
|
52
53
|
NetworkRuntimeProps,
|
|
54
|
+
NetworkTopologyIntent,
|
|
53
55
|
RNGSnapshot,
|
|
54
56
|
SerializedConnection,
|
|
55
57
|
TrainingOptions,
|
|
56
58
|
} from './network/network.types';
|
|
57
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Resolves the public topology intent for one constructor call.
|
|
62
|
+
*
|
|
63
|
+
* @param options Optional constructor options.
|
|
64
|
+
* @returns Resolved topology intent.
|
|
65
|
+
*/
|
|
66
|
+
function resolveTopologyIntent(
|
|
67
|
+
options?: NetworkConstructorOptions,
|
|
68
|
+
): NetworkTopologyIntent {
|
|
69
|
+
if (options?.topologyIntent) {
|
|
70
|
+
return options.topologyIntent;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return options?.enforceAcyclic ? 'feed-forward' : 'unconstrained';
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Validates that legacy acyclic flags do not contradict public topology intent.
|
|
78
|
+
*
|
|
79
|
+
* @param options Optional constructor options.
|
|
80
|
+
* @returns Nothing.
|
|
81
|
+
*/
|
|
82
|
+
function validateTopologyIntentConfiguration(
|
|
83
|
+
options?: NetworkConstructorOptions,
|
|
84
|
+
): void {
|
|
85
|
+
if (
|
|
86
|
+
options?.topologyIntent === 'feed-forward' &&
|
|
87
|
+
options.enforceAcyclic === false
|
|
88
|
+
) {
|
|
89
|
+
throw new Error(
|
|
90
|
+
'Conflicting topology options: feed-forward intent cannot disable acyclic enforcement.',
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (
|
|
95
|
+
options?.topologyIntent === 'unconstrained' &&
|
|
96
|
+
options.enforceAcyclic === true
|
|
97
|
+
) {
|
|
98
|
+
throw new Error(
|
|
99
|
+
'Conflicting topology options: unconstrained intent cannot enable acyclic enforcement.',
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Resolves whether acyclic enforcement should be enabled for one constructor call.
|
|
106
|
+
*
|
|
107
|
+
* @param options Optional constructor options.
|
|
108
|
+
* @param topologyIntent Resolved public topology intent.
|
|
109
|
+
* @returns True when acyclic enforcement should be enabled.
|
|
110
|
+
*/
|
|
111
|
+
function resolveAcyclicEnforcement(
|
|
112
|
+
options: NetworkConstructorOptions | undefined,
|
|
113
|
+
topologyIntent: NetworkTopologyIntent,
|
|
114
|
+
): boolean {
|
|
115
|
+
if (typeof options?.enforceAcyclic === 'boolean') {
|
|
116
|
+
return options.enforceAcyclic;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return topologyIntent === 'feed-forward';
|
|
120
|
+
}
|
|
121
|
+
|
|
58
122
|
/**
|
|
59
123
|
* Network (Evolvable / Trainable Graph)
|
|
60
124
|
* =====================================
|
|
@@ -182,6 +246,8 @@ export default class Network implements NetworkView {
|
|
|
182
246
|
private _initialConnectionCount?: number;
|
|
183
247
|
/** Whether to enforce acyclic connectivity. */
|
|
184
248
|
private _enforceAcyclic: boolean = false;
|
|
249
|
+
/** Public topology intent used to preserve semantic API choices. */
|
|
250
|
+
private _topologyIntent: NetworkTopologyIntent = 'unconstrained';
|
|
185
251
|
/** Cached topological order. */
|
|
186
252
|
private _topoOrder: Node[] | null = null;
|
|
187
253
|
/** Topology dirty marker. */
|
|
@@ -254,20 +320,20 @@ export default class Network implements NetworkView {
|
|
|
254
320
|
constructor(
|
|
255
321
|
input: number,
|
|
256
322
|
output: number,
|
|
257
|
-
options?:
|
|
258
|
-
minHidden?: number;
|
|
259
|
-
seed?: number;
|
|
260
|
-
enforceAcyclic?: boolean;
|
|
261
|
-
activationPrecision?: 'f32' | 'f64';
|
|
262
|
-
reuseActivationArrays?: boolean;
|
|
263
|
-
returnTypedActivations?: boolean;
|
|
264
|
-
},
|
|
323
|
+
options?: NetworkConstructorOptions,
|
|
265
324
|
) {
|
|
266
325
|
// Validate that input and output sizes are provided.
|
|
267
326
|
if (typeof input === 'undefined' || typeof output === 'undefined') {
|
|
268
327
|
throw new Error('No input or output size given');
|
|
269
328
|
}
|
|
270
329
|
|
|
330
|
+
// Step 1: Validate constructor topology semantics before mutating runtime state.
|
|
331
|
+
validateTopologyIntentConfiguration(options);
|
|
332
|
+
|
|
333
|
+
// Step 2: Resolve the public topology contract and the low-level acyclic flag.
|
|
334
|
+
const topologyIntent = resolveTopologyIntent(options);
|
|
335
|
+
const enforceAcyclic = resolveAcyclicEnforcement(options, topologyIntent);
|
|
336
|
+
|
|
271
337
|
// Initialize network properties
|
|
272
338
|
this.input = input;
|
|
273
339
|
this.output = output;
|
|
@@ -276,7 +342,8 @@ export default class Network implements NetworkView {
|
|
|
276
342
|
this.gates = [];
|
|
277
343
|
this.selfconns = [];
|
|
278
344
|
this.dropout = 0;
|
|
279
|
-
this.
|
|
345
|
+
this._topologyIntent = topologyIntent;
|
|
346
|
+
this._enforceAcyclic = enforceAcyclic;
|
|
280
347
|
if (options?.activationPrecision) {
|
|
281
348
|
this._activationPrecision = options.activationPrecision;
|
|
282
349
|
} else if (config.float32Mode) {
|
|
@@ -467,13 +534,46 @@ export default class Network implements NetworkView {
|
|
|
467
534
|
this._dropConnectProb = 0;
|
|
468
535
|
}
|
|
469
536
|
|
|
537
|
+
/**
|
|
538
|
+
* Returns the public topology intent for this network.
|
|
539
|
+
*
|
|
540
|
+
* @returns Current topology intent.
|
|
541
|
+
*/
|
|
542
|
+
getTopologyIntent(): NetworkTopologyIntent {
|
|
543
|
+
return this._topologyIntent;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
/**
|
|
547
|
+
* Sets the public topology intent and keeps acyclic enforcement aligned.
|
|
548
|
+
*
|
|
549
|
+
* @param topologyIntent Desired topology intent.
|
|
550
|
+
* @returns Nothing.
|
|
551
|
+
*/
|
|
552
|
+
setTopologyIntent(topologyIntent: NetworkTopologyIntent): void {
|
|
553
|
+
// Step 1: Persist the public topology contract.
|
|
554
|
+
this._topologyIntent = topologyIntent;
|
|
555
|
+
|
|
556
|
+
// Step 2: Keep the low-level acyclic guard aligned with the public contract.
|
|
557
|
+
this._enforceAcyclic = topologyIntent === 'feed-forward';
|
|
558
|
+
|
|
559
|
+
// Step 3: Mark topology caches dirty so later activation rebuilds coherent state.
|
|
560
|
+
this._topoDirty = true;
|
|
561
|
+
}
|
|
562
|
+
|
|
470
563
|
/**
|
|
471
564
|
* Enable or disable acyclic topology enforcement.
|
|
472
565
|
*
|
|
473
566
|
* @param flag Whether to enforce acyclic connectivity.
|
|
474
567
|
*/
|
|
475
|
-
setEnforceAcyclic(flag: boolean) {
|
|
568
|
+
setEnforceAcyclic(flag: boolean): void {
|
|
569
|
+
// Step 1: Preserve backward compatibility for callers using the legacy toggle.
|
|
476
570
|
this._enforceAcyclic = !!flag;
|
|
571
|
+
|
|
572
|
+
// Step 2: Keep the public topology intent synchronized with the active runtime contract.
|
|
573
|
+
this._topologyIntent = flag ? 'feed-forward' : 'unconstrained';
|
|
574
|
+
|
|
575
|
+
// Step 3: Mark topology caches dirty so acyclic mode changes rebuild ordering safely.
|
|
576
|
+
this._topoDirty = true;
|
|
477
577
|
}
|
|
478
578
|
|
|
479
579
|
/**
|
|
@@ -1618,6 +1718,10 @@ export default class Network implements NetworkView {
|
|
|
1618
1718
|
// Rebuild net.connections from all per-node connections
|
|
1619
1719
|
net.connections = net.nodes.flatMap((n) => n.connections.out);
|
|
1620
1720
|
net._topoDirty = true;
|
|
1721
|
+
|
|
1722
|
+
// Step 1: Preserve the public feed-forward contract for layered MLP builders.
|
|
1723
|
+
net.setTopologyIntent('feed-forward');
|
|
1724
|
+
|
|
1621
1725
|
return net;
|
|
1622
1726
|
}
|
|
1623
1727
|
|
package/src/methods/README.md
CHANGED
|
@@ -28,10 +28,6 @@ rounded network outputs (thresholded at 0.5) against the target labels.
|
|
|
28
28
|
It assumes target values are 0 or 1, and outputs are probabilities between 0 and 1.
|
|
29
29
|
Note: This is equivalent to `1 - accuracy` for binary classification.
|
|
30
30
|
|
|
31
|
-
Parameters:
|
|
32
|
-
- `` - - An array of target values, expected to be 0 or 1.
|
|
33
|
-
- `` - - An array of output values from the network, typically probabilities between 0 and 1.
|
|
34
|
-
|
|
35
31
|
Returns: The proportion of misclassified samples (error rate, between 0 and 1).
|
|
36
32
|
|
|
37
33
|
#### crossEntropy
|
|
@@ -47,10 +43,6 @@ predicted probability diverges from the actual label.
|
|
|
47
43
|
It uses a small epsilon (PROB_EPSILON = 1e-15) to prevent `log(0)` which would result in `NaN`.
|
|
48
44
|
Output values are clamped to the range `[epsilon, 1 - epsilon]` for numerical stability.
|
|
49
45
|
|
|
50
|
-
Parameters:
|
|
51
|
-
- `` - - An array of target values, typically 0 or 1 for binary classification, or probabilities for soft labels.
|
|
52
|
-
- `` - - An array of output values from the network, representing probabilities (expected to be between 0 and 1).
|
|
53
|
-
|
|
54
46
|
Returns: The mean cross-entropy error over all samples.
|
|
55
47
|
|
|
56
48
|
#### focalLoss
|
|
@@ -60,12 +52,6 @@ Returns: The mean cross-entropy error over all samples.
|
|
|
60
52
|
Calculates the Focal Loss, which is useful for addressing class imbalance in classification tasks.
|
|
61
53
|
Focal loss down-weights easy examples and focuses training on hard negatives.
|
|
62
54
|
|
|
63
|
-
Parameters:
|
|
64
|
-
- `` - - Array of target values (0 or 1 for binary, or probabilities for soft labels).
|
|
65
|
-
- `` - - Array of predicted probabilities (between 0 and 1).
|
|
66
|
-
- `` - - Focusing parameter (default 2).
|
|
67
|
-
- `` - - Balancing parameter (default 0.25).
|
|
68
|
-
|
|
69
55
|
Returns: The mean focal loss.
|
|
70
56
|
|
|
71
57
|
#### hinge
|
|
@@ -79,10 +65,6 @@ Hinge loss is used for training classifiers. It penalizes predictions that are
|
|
|
79
65
|
not only incorrect but also those that are correct but not confident (i.e., close to the decision boundary).
|
|
80
66
|
Assumes target values are encoded as -1 or 1.
|
|
81
67
|
|
|
82
|
-
Parameters:
|
|
83
|
-
- `` - - An array of target values, expected to be -1 or 1.
|
|
84
|
-
- `` - - An array of output values from the network (raw scores, not necessarily probabilities).
|
|
85
|
-
|
|
86
68
|
Returns: The mean hinge loss.
|
|
87
69
|
|
|
88
70
|
#### labelSmoothing
|
|
@@ -92,11 +74,6 @@ Returns: The mean hinge loss.
|
|
|
92
74
|
Calculates the Cross Entropy with Label Smoothing.
|
|
93
75
|
Label smoothing prevents the model from becoming overconfident by softening the targets.
|
|
94
76
|
|
|
95
|
-
Parameters:
|
|
96
|
-
- `` - - Array of target values (0 or 1 for binary, or probabilities for soft labels).
|
|
97
|
-
- `` - - Array of predicted probabilities (between 0 and 1).
|
|
98
|
-
- `` - - Smoothing factor (between 0 and 1, e.g., 0.1).
|
|
99
|
-
|
|
100
77
|
Returns: The mean cross-entropy loss with label smoothing.
|
|
101
78
|
|
|
102
79
|
#### mae
|
|
@@ -108,10 +85,6 @@ Calculates the Mean Absolute Error (MAE), another common loss function for regre
|
|
|
108
85
|
MAE measures the average of the absolute differences between predictions and actual values.
|
|
109
86
|
Compared to MSE, it is less sensitive to outliers because errors are not squared.
|
|
110
87
|
|
|
111
|
-
Parameters:
|
|
112
|
-
- `` - - An array of target numerical values.
|
|
113
|
-
- `` - - An array of output values from the network.
|
|
114
|
-
|
|
115
88
|
Returns: The mean absolute error.
|
|
116
89
|
|
|
117
90
|
#### mape
|
|
@@ -125,10 +98,6 @@ for understanding the error relative to the magnitude of the target values.
|
|
|
125
98
|
However, it has limitations: it's undefined when the target value is zero and
|
|
126
99
|
can be skewed by target values close to zero.
|
|
127
100
|
|
|
128
|
-
Parameters:
|
|
129
|
-
- `` - - An array of target numerical values. Should not contain zeros for standard MAPE.
|
|
130
|
-
- `` - - An array of output values from the network.
|
|
131
|
-
|
|
132
101
|
Returns: The mean absolute percentage error, expressed as a proportion (e.g., 0.1 for 10%).
|
|
133
102
|
|
|
134
103
|
#### mse
|
|
@@ -141,10 +110,6 @@ MSE measures the average of the squares of the errors—that is, the average
|
|
|
141
110
|
squared difference between the estimated values and the actual value.
|
|
142
111
|
It is sensitive to outliers due to the squaring of the error terms.
|
|
143
112
|
|
|
144
|
-
Parameters:
|
|
145
|
-
- `` - - An array of target numerical values.
|
|
146
|
-
- `` - - An array of output values from the network.
|
|
147
|
-
|
|
148
113
|
Returns: The mean squared error.
|
|
149
114
|
|
|
150
115
|
#### msle
|
|
@@ -159,10 +124,6 @@ It measures the squared difference between the logarithms of the predicted and a
|
|
|
159
124
|
Uses `log(1 + x)` instead of `log(x)` for numerical stability and to handle inputs of 0.
|
|
160
125
|
Assumes both targets and outputs are non-negative.
|
|
161
126
|
|
|
162
|
-
Parameters:
|
|
163
|
-
- `` - - An array of target numerical values (assumed >= 0).
|
|
164
|
-
- `` - - An array of output values from the network (assumed >= 0).
|
|
165
|
-
|
|
166
127
|
Returns: The mean squared logarithmic error.
|
|
167
128
|
|
|
168
129
|
#### softmaxCrossEntropy
|
|
@@ -382,10 +343,6 @@ rounded network outputs (thresholded at 0.5) against the target labels.
|
|
|
382
343
|
It assumes target values are 0 or 1, and outputs are probabilities between 0 and 1.
|
|
383
344
|
Note: This is equivalent to `1 - accuracy` for binary classification.
|
|
384
345
|
|
|
385
|
-
Parameters:
|
|
386
|
-
- `` - - An array of target values, expected to be 0 or 1.
|
|
387
|
-
- `` - - An array of output values from the network, typically probabilities between 0 and 1.
|
|
388
|
-
|
|
389
346
|
Returns: The proportion of misclassified samples (error rate, between 0 and 1).
|
|
390
347
|
|
|
391
348
|
#### cosineAnnealing
|
|
@@ -434,10 +391,6 @@ predicted probability diverges from the actual label.
|
|
|
434
391
|
It uses a small epsilon (PROB_EPSILON = 1e-15) to prevent `log(0)` which would result in `NaN`.
|
|
435
392
|
Output values are clamped to the range `[epsilon, 1 - epsilon]` for numerical stability.
|
|
436
393
|
|
|
437
|
-
Parameters:
|
|
438
|
-
- `` - - An array of target values, typically 0 or 1 for binary classification, or probabilities for soft labels.
|
|
439
|
-
- `` - - An array of output values from the network, representing probabilities (expected to be between 0 and 1).
|
|
440
|
-
|
|
441
394
|
Returns: The mean cross-entropy error over all samples.
|
|
442
395
|
|
|
443
396
|
#### exp
|
|
@@ -482,12 +435,6 @@ Returns: A function that takes the base learning rate and the current iteration
|
|
|
482
435
|
Calculates the Focal Loss, which is useful for addressing class imbalance in classification tasks.
|
|
483
436
|
Focal loss down-weights easy examples and focuses training on hard negatives.
|
|
484
437
|
|
|
485
|
-
Parameters:
|
|
486
|
-
- `` - - Array of target values (0 or 1 for binary, or probabilities for soft labels).
|
|
487
|
-
- `` - - Array of predicted probabilities (between 0 and 1).
|
|
488
|
-
- `` - - Focusing parameter (default 2).
|
|
489
|
-
- `` - - Balancing parameter (default 0.25).
|
|
490
|
-
|
|
491
438
|
Returns: The mean focal loss.
|
|
492
439
|
|
|
493
440
|
#### hinge
|
|
@@ -501,10 +448,6 @@ Hinge loss is used for training classifiers. It penalizes predictions that are
|
|
|
501
448
|
not only incorrect but also those that are correct but not confident (i.e., close to the decision boundary).
|
|
502
449
|
Assumes target values are encoded as -1 or 1.
|
|
503
450
|
|
|
504
|
-
Parameters:
|
|
505
|
-
- `` - - An array of target values, expected to be -1 or 1.
|
|
506
|
-
- `` - - An array of output values from the network (raw scores, not necessarily probabilities).
|
|
507
|
-
|
|
508
451
|
Returns: The mean hinge loss.
|
|
509
452
|
|
|
510
453
|
#### inv
|
|
@@ -534,11 +477,6 @@ Returns: A function that calculates the inversely decayed learning rate for a gi
|
|
|
534
477
|
Calculates the Cross Entropy with Label Smoothing.
|
|
535
478
|
Label smoothing prevents the model from becoming overconfident by softening the targets.
|
|
536
479
|
|
|
537
|
-
Parameters:
|
|
538
|
-
- `` - - Array of target values (0 or 1 for binary, or probabilities for soft labels).
|
|
539
|
-
- `` - - Array of predicted probabilities (between 0 and 1).
|
|
540
|
-
- `` - - Smoothing factor (between 0 and 1, e.g., 0.1).
|
|
541
|
-
|
|
542
480
|
Returns: The mean cross-entropy loss with label smoothing.
|
|
543
481
|
|
|
544
482
|
#### linearWarmupDecay
|
|
@@ -563,10 +501,6 @@ Calculates the Mean Absolute Error (MAE), another common loss function for regre
|
|
|
563
501
|
MAE measures the average of the absolute differences between predictions and actual values.
|
|
564
502
|
Compared to MSE, it is less sensitive to outliers because errors are not squared.
|
|
565
503
|
|
|
566
|
-
Parameters:
|
|
567
|
-
- `` - - An array of target numerical values.
|
|
568
|
-
- `` - - An array of output values from the network.
|
|
569
|
-
|
|
570
504
|
Returns: The mean absolute error.
|
|
571
505
|
|
|
572
506
|
#### mape
|
|
@@ -580,10 +514,6 @@ for understanding the error relative to the magnitude of the target values.
|
|
|
580
514
|
However, it has limitations: it's undefined when the target value is zero and
|
|
581
515
|
can be skewed by target values close to zero.
|
|
582
516
|
|
|
583
|
-
Parameters:
|
|
584
|
-
- `` - - An array of target numerical values. Should not contain zeros for standard MAPE.
|
|
585
|
-
- `` - - An array of output values from the network.
|
|
586
|
-
|
|
587
517
|
Returns: The mean absolute percentage error, expressed as a proportion (e.g., 0.1 for 10%).
|
|
588
518
|
|
|
589
519
|
#### mse
|
|
@@ -596,10 +526,6 @@ MSE measures the average of the squares of the errors—that is, the average
|
|
|
596
526
|
squared difference between the estimated values and the actual value.
|
|
597
527
|
It is sensitive to outliers due to the squaring of the error terms.
|
|
598
528
|
|
|
599
|
-
Parameters:
|
|
600
|
-
- `` - - An array of target numerical values.
|
|
601
|
-
- `` - - An array of output values from the network.
|
|
602
|
-
|
|
603
529
|
Returns: The mean squared error.
|
|
604
530
|
|
|
605
531
|
#### msle
|
|
@@ -614,10 +540,6 @@ It measures the squared difference between the logarithms of the predicted and a
|
|
|
614
540
|
Uses `log(1 + x)` instead of `log(x)` for numerical stability and to handle inputs of 0.
|
|
615
541
|
Assumes both targets and outputs are non-negative.
|
|
616
542
|
|
|
617
|
-
Parameters:
|
|
618
|
-
- `` - - An array of target numerical values (assumed >= 0).
|
|
619
|
-
- `` - - An array of output values from the network (assumed >= 0).
|
|
620
|
-
|
|
621
543
|
Returns: The mean squared logarithmic error.
|
|
622
544
|
|
|
623
545
|
#### reduceOnPlateau
|
|
@@ -703,7 +625,7 @@ but can slow down the search process.
|
|
|
703
625
|
|
|
704
626
|
### registerCustomActivation
|
|
705
627
|
|
|
706
|
-
`(activationName: string, activationFunction: import("
|
|
628
|
+
`(activationName: string, activationFunction: import("src/methods/activation.utils").ActivationFunction) => void`
|
|
707
629
|
|
|
708
630
|
## methods/connection.ts
|
|
709
631
|
|
|
@@ -935,7 +857,7 @@ Useful for any stateless schedule strategy.
|
|
|
935
857
|
|
|
936
858
|
### createCosineAnnealingRateSchedule
|
|
937
859
|
|
|
938
|
-
`(period: number, minimumRate: number) => import("
|
|
860
|
+
`(period: number, minimumRate: number) => import("src/methods/rate.utils").RateSchedule`
|
|
939
861
|
|
|
940
862
|
Returns a cosine annealing learning rate schedule.
|
|
941
863
|
|
|
@@ -947,7 +869,7 @@ Returns: A learning rate schedule implementing cosine annealing.
|
|
|
947
869
|
|
|
948
870
|
### createCosineAnnealingWarmRestartsSchedule
|
|
949
871
|
|
|
950
|
-
`(initialPeriod: number, minimumRate: number, periodGrowthMultiplier: number) => import("
|
|
872
|
+
`(initialPeriod: number, minimumRate: number, periodGrowthMultiplier: number) => import("src/methods/rate.utils").RateSchedule`
|
|
951
873
|
|
|
952
874
|
Returns a cosine annealing schedule with warm restarts and growing cycles.
|
|
953
875
|
|
|
@@ -960,7 +882,7 @@ Returns: A learning rate schedule implementing SGDR-style warm restarts.
|
|
|
960
882
|
|
|
961
883
|
### createExponentialRateSchedule
|
|
962
884
|
|
|
963
|
-
`(decayFactor: number) => import("
|
|
885
|
+
`(decayFactor: number) => import("src/methods/rate.utils").RateSchedule`
|
|
964
886
|
|
|
965
887
|
Returns an exponential decay learning rate schedule.
|
|
966
888
|
|
|
@@ -971,7 +893,7 @@ Returns: A learning rate schedule implementing exponential decay.
|
|
|
971
893
|
|
|
972
894
|
### createFixedRateSchedule
|
|
973
895
|
|
|
974
|
-
`() => import("
|
|
896
|
+
`() => import("src/methods/rate.utils").RateSchedule`
|
|
975
897
|
|
|
976
898
|
Returns a schedule that always yields the base learning rate.
|
|
977
899
|
|
|
@@ -979,7 +901,7 @@ Returns: A learning rate schedule that ignores iteration and returns baseRate.
|
|
|
979
901
|
|
|
980
902
|
### createInverseRateSchedule
|
|
981
903
|
|
|
982
|
-
`(decayFactor: number, decayPower: number) => import("
|
|
904
|
+
`(decayFactor: number, decayPower: number) => import("src/methods/rate.utils").RateSchedule`
|
|
983
905
|
|
|
984
906
|
Returns an inverse decay learning rate schedule.
|
|
985
907
|
|
|
@@ -991,7 +913,7 @@ Returns: A learning rate schedule implementing inverse decay.
|
|
|
991
913
|
|
|
992
914
|
### createLinearWarmupDecaySchedule
|
|
993
915
|
|
|
994
|
-
`(totalStepCount: number, warmupStepCount: number | undefined, endRate: number) => import("
|
|
916
|
+
`(totalStepCount: number, warmupStepCount: number | undefined, endRate: number) => import("src/methods/rate.utils").RateSchedule`
|
|
995
917
|
|
|
996
918
|
Returns a linear warmup followed by linear decay schedule.
|
|
997
919
|
|
|
@@ -1004,7 +926,7 @@ Returns: A learning rate schedule implementing warmup then decay.
|
|
|
1004
926
|
|
|
1005
927
|
### createReduceOnPlateauSchedule
|
|
1006
928
|
|
|
1007
|
-
`(options: { factor?: number | undefined; patience?: number | undefined; minDelta?: number | undefined; cooldown?: number | undefined; minRate?: number | undefined; verbose?: boolean | undefined; } | undefined) => import("
|
|
929
|
+
`(options: { factor?: number | undefined; patience?: number | undefined; minDelta?: number | undefined; cooldown?: number | undefined; minRate?: number | undefined; verbose?: boolean | undefined; } | undefined) => import("src/methods/rate.utils").ReduceOnPlateauSchedule`
|
|
1008
930
|
|
|
1009
931
|
Returns a ReduceLROnPlateau-style schedule that lowers the rate when no improvement is seen.
|
|
1010
932
|
|
|
@@ -1015,7 +937,7 @@ Returns: A stateful schedule that reacts to lack of improvement.
|
|
|
1015
937
|
|
|
1016
938
|
### createStepRateSchedule
|
|
1017
939
|
|
|
1018
|
-
`(decayFactor: number, decayStepSize: number) => import("
|
|
940
|
+
`(decayFactor: number, decayStepSize: number) => import("src/methods/rate.utils").RateSchedule`
|
|
1019
941
|
|
|
1020
942
|
Returns a step decay learning rate schedule.
|
|
1021
943
|
|