code wiki / _hdl_build / nx_nofloat_mlp4.nx
nx_nofloat_mlp4.nx
buildroot/runtime/_hdl_build/nx_nofloat_mlp4.nx
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
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
structs
| none |
consts
| 9 | const K_MAGIC_4000: i64 = 4000 |
| 15 | const Q: i64 = 16 |
| 16 | const ONE: i64 = 65536 |
| 17 | const H: i64 = 4 |
functions
| 11 | func 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 } |
| 12 | func 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 } |
| 13 | func 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 } |
| 18 | func fxmul(a: i64, b: i64) -> i64 { return (a*b)>>Q } |
| 19 | func relu(x: i64) -> i64 { if x>0 { return x } return 0 } called by 1: forward |
| 23 | func forward(P: *i64, x1: i64, x2: i64, s: *i64) -> i64 |
| 28 | func epoch(P: *i64, lr: i64) -> i64 |
| 49 | func init_params(P: *i64) -> i64 |
| 58 | func train(P: *i64, epochs: i64, lr: i64, lossout: *i64) -> i64 |
| 63 | func classified_xor(P: *i64) -> i64 { // 1 if all four inputs land on the correct side of the 0.5 threshold |
| 70 | func main() -> i64 |