code wiki / _hdl_build / nx_skintex_train_gate.nx
nx_skintex_train_gate.nx
buildroot/runtime/_hdl_build/nx_skintex_train_gate.nx
about
nx_skintex_train_gate.nx -- ★★P4 NEURAL RUNG 1: a TRAINED sovereign neural SKIN-TEXTURE model. A coordinate
MLP (Fourier features -> 40 ReLU -> rgb; the SIREN/FFN/Instant-NGP family, per the banked ntex_* frontier)
is trained by HAND-ROLLED INTEGER (Q12) backprop on a REAL 48x48 skin patch cropped from the Elara exemplar,
persisted as quantized integer weights, and re-rendered by integer-only inference -- the ENTIRE P4 pipeline
(data -> train -> persist -> integer inference -> render) proven end-to-end at a scale we win today.
Honest boundary: this is EXEMPLAR-FIT (a compressed, resolution-free representation of one patch), not yet a
GENERATIVE skin model -- that is R2 (latent-conditioned family / NCA stationary synthesis).
T1 training CONVERGES: final reconstruction error < 1/4 of the untrained error
T2 close reconstruction: final mean |err| per channel < 26/255
T3 PERSISTENCE: integer weights file -> reload -> re-render is BIT-IDENTICAL (the deploy path)
T4 RESOLUTION-FREE: renders at 4x coordinate density (192x192, smooth continuous zoom -- the coordinate-net
win over a stored bitmap) + PNG knowledge/nx_skintex.png (exemplar | reconstruction | 4x zoom)
license_tier: ORIGINAL expect_exit: 0
dependencies 4 imports · 0 importers
imports: nx_syscalls.nxnx_itrig.nxnx_jpeg_ascii.nxnx_png.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
| 22 | const PS: i64 = 48 // exemplar patch size |
| 23 | const CX: i64 = 148 // crop origin in elara_face_hi.jpg: the LEFT EYE region -- real structure |
| 24 | const CY: i64 = 244 // (iris/lashes/lid/skin) so the net learns actual image content, not noise |
| 25 | const NFR: i64 = 6 // frequencies {1,2,4,8,16,24}: the eye has REAL high-freq structure (iris, |
| 26 | const NF: i64 = 24 // lashes), so the high bands fit real edges (on a FLAT patch they lay plaid) |
| 27 | const NH: i64 = 64 // hidden units |
| 28 | const NO: i64 = 3 // rgb |
| 29 | const NPX: i64 = 2304 // PS*PS |
| 30 | const EPOCHS: i64 = 1000 |
functions
| 19 | func hw(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 20 | func pn(v: i64) -> i64 { let b: *u8=sys_mmap(32) as *u8; var x: i64=v; var ng: i64=0; if x<0{ng=1;x=0-x} var i: i64=31; if x==0{b[i]=48 as u8;i=i-1} while x>0{b[i]=(48+x%10) as u8;x=x/10;i=i-1} if ng==1{b[i]=45 as u8;i=i-1} sys_write(1,(b as i64+i+1) as *u8,31-i); return 0 } |
| 32 | func lcg(st: *i64) -> i64 { var h: i64=st[0]; h=h*6364136223846793005+1442695040888963407; st[0]=h; return (h>>33)&2147483647 } called by 1: main |
| 35 | func features(px: i64, py: i64, scale: i64, f: *i64) -> i64 |
| 52 | func infer(W1: *i64, b1: *i64, W2: *i64, b2: *i64, f: *i64, h: *i64) -> i64 called by 1: main |
| 81 | func main() -> i64 |