ELM: pluggable hidden activation (tanh / relu / step)

ActivationKind (atanTanh default, atanRelu, atanStep) on ElmConfig, plus
applyActivation, activationName and parseActivation. The hidden units stay
pure additive nodes: every activation sees the same pre-activation s = a.x + b
and differs only in the scalar nonlinearity g.

tanh is unchanged and bit-identical to the previous version, so existing
callers cannot regress. Two init details are activation-aware, because relu and
step are dead for s <= 0: they get bias U[0,1] instead of U[-1,1], and hidden
weight scale 8/sqrt(inputDim) instead of 1/sqrt(inputDim) (at the tanh scale
the pre-activations barely straddle 0, the Gram matrix loses rank and Thm 2.2
interpolation fails outright).

No RBF option: g(b*||x - a||) reads the distance to a centre in input space,
which is a different node architecture (extra centre + width parameters, its
own init and its own Thm 2.2 validation), not a different g.

Adds tests/test_elm.nim (9 suites) and a `nimble test` task. All pass.
This commit is contained in:
2026-10-05 22:42:12 +02:00
parent fe8b1eddff
commit 7598f7db4a
6 changed files with 791 additions and 5 deletions
+31 -1
View File
@@ -97,5 +97,35 @@ tr_bots/_salvage/legacy_bots/*
!legacy_bots/**/*.jar
legacy_bots/**/*.jar.*
# DrussGT raw recorded corpora (large, regenerable via tools/raw_recorder)
# Raw recorded battle corpora (regenerable via tools/raw_recorder):
# data/drussgt_raw/ 26 MB, one 20 MB capture
# data/generalization_raw/ 34 MB, 8 opponent captures
# These are the INPUT to tools/elm_bench; committing the DERIVED samples
# (tools/elm_bench/gen/*.ndjson) is enough to rerun every experiment.
data/drussgt_raw/
data/generalization_raw/
# Research PDFs (60 MB). Regenerable: common_libs/guns/docs/fetch_papers.sh
# (same call as the BitBrain zip rule above).
docs/papers/*.pdf
# Root-level build output (garage builds go to *_garage/out/, this was not)
/out/
# Extensionless build artifacts
DevControlBot_garage/DevControlBot/DevControlBot
DevControlBot_garage/DevControlBot/modules/ELM/elm_tests
common_libs/guns/waveelm
common_libs/tests/measure_melee_strong_field
common_libs/tests/measure_tfil_arrival
common_libs/tests/measure_tfil_pick_defects
common_libs/tests/measure_tfil_picker_loss
tools/elm_bench/bench
tools/elm_bench/bench_realistic
tools/elm_bench/bench_ring
tools/elm_bench/cross_opponent
# Generated sample tables. The authoritative copies live in tools/elm_bench/gen/
# (committed); the top-level ones are the DrussGT extract, byte-identical.
tools/elm_bench/samples*.ndjson
tools/elm_bench/ring_*.ndjson