code wiki / _hdl_build / nx_nofloat_mlp4.nx

nx_nofloat_mlp4.nx

buildroot/runtime/_hdl_build/nx_nofloat_mlp4.nx

7504 B112 linesdepth 2pulls 2 transitivereach 0 importersview sourcekind tooltopic nofloat
docsdependenciesstructsconstsfunctions

about

nx_nofloat_mlp4.nx -- CLOSE THE GAP from nx_nofloat_mlp (the 2-2-1 hit the predict-~0.5 local min). A 2-4-1 ReLU integer-Q16 MLP with full backprop + a DIVERSE half-plane init (4 hidden units oriented to different input half- planes = a separating feature basis; NOT the output answer). Full backprop trains all 17 params and the net learns XOR END-TO-END -- the non-linear function a linear model provably cannot. Still 100% integer => bit-exact deterministic. T1 forward runs (4 hidden units). T2 loss drops substantially (final < initial/4). T3 (EXCEED) DETERMINISM bit-identical. T4 SOLVES XOR -- all four inputs classify correctly across the 0.5 threshold. expect_exit: 0 Sovereign: nx_syscalls.

dependencies 1 imports · 0 importers

nx_syscalls.nx nx_nofloat_mlp4.nx

imports: nx_syscalls.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main g_puts sys_write sys_mmap init_params forward fxmul relu g_pn sys_mmap ↻ sys_write ↻ ck g_puts ↻ train init_params ↻ epoch sys_mmap ↻ forward ↻ fxmul ↻ classified_xor sys_mmap ↻ forward ↻ sys_openat_append sys_write ↻ sys_close sys_exit

structs

none

consts

9const K_MAGIC_4000: i64 = 4000
15const Q: i64 = 16
16const ONE: i64 = 65536
17const H: i64 = 4

functions

11func g_puts(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 }
called by 2: ckmain calls 1: sys_write
12func g_pn(v: i64) -> i64 { let b: *u8=sys_mmap(28); var x: i64=v; if x<0{b[0]=45;sys_write(1,b,1);x=0-x} if x==0{b[0]=48;sys_write(1,b,1);return 0} var d: i64=0; var y: i64=x; while y>0{d=d+1;y=y/10} var i: i64=d-1; y=x; while i>=0{b[i]=(48+(y%10)) as u8;y=y/10;i=i-1} sys_write(1,b,d); return 0 }
called by 1: main calls 2: sys_mmapsys_write
13func ck(name: *u8, c: i64) -> i64 { if c==1 { g_puts(" PASS " as *u8) } else { g_puts(" FAIL " as *u8) } g_puts(name); g_puts("\n" as *u8); return c }
called by 1: main calls 1: g_puts
18func fxmul(a: i64, b: i64) -> i64 { return (a*b)>>Q }
called by 2: forwardepoch
19func relu(x: i64) -> i64 { if x>0 { return x } return 0 }
called by 1: forward
23func forward(P: *i64, x1: i64, x2: i64, s: *i64) -> i64
called by 3: epochclassified_xormain calls 2: fxmulrelu
28func epoch(P: *i64, lr: i64) -> i64
called by 1: train calls 3: sys_mmapforwardfxmul
49func init_params(P: *i64) -> i64
called by 2: trainmain
58func train(P: *i64, epochs: i64, lr: i64, lossout: *i64) -> i64
called by 1: main calls 2: init_paramsepoch
63func classified_xor(P: *i64) -> i64 { // 1 if all four inputs land on the correct side of the 0.5 threshold
called by 1: main calls 2: sys_mmapforward
70func main() -> i64