code wiki / _hdl_build / nx_skintex_train_gate.nx

nx_skintex_train_gate.nx

buildroot/runtime/_hdl_build/nx_skintex_train_gate.nx

14461 B339 linesdepth 9pulls 24 transitivereach 0 importersview sourcekind gate/proof
docsdependenciesstructsconstsfunctions

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

nx_syscalls.nx nx_itrig.nx nx_jpeg_ascii.nx nx_png.nx nx_skintex_train_gate.nx

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

main hw sys_write sys_mmap sys_read_file sys_openat_rd sys_lseek sys_mmap ↻ sys_read sys_close nx_jpeg_decode_rgb sys_mmap ↻ nx_jpeg_dec_ctx_init sys_mmap ↻ _jpeg_ascii_probe_sof sys_mmap ↻ nx_jpeg_seg_init nx_jpeg_seg_next nx_jpeg_classify_marker nx_jpeg_marker_is_lengthle nx_jpeg_sof_parse nx_jpeg_is_progressive prog_be16 nx_jpeg_prog_decode sys_mmap ↻ prog_be16 ↻ nx_jpeg_dqt_parse nx_jpeg_dht_parse nx_jpeg_dht_build_decode_t nx_jpeg_sos_parse prog_next_marker prog_scan sys_mmap ↻ nx_jpeg_huff_decode_symbol nx_jpeg_ent_extend nx_jpeg_ent_receive prog_refine_nz nx_jpeg_mcu_scratch_init sys_mmap ↻ nx_jpeg_idct_init_cos_tabl

structs

none

consts

22const PS: i64 = 48 // exemplar patch size
23const CX: i64 = 148 // crop origin in elara_face_hi.jpg: the LEFT EYE region -- real structure
24const CY: i64 = 244 // (iris/lashes/lid/skin) so the net learns actual image content, not noise
25const NFR: i64 = 6 // frequencies {1,2,4,8,16,24}: the eye has REAL high-freq structure (iris,
26const NF: i64 = 24 // lashes), so the high bands fit real edges (on a FLAT patch they lay plaid)
27const NH: i64 = 64 // hidden units
28const NO: i64 = 3 // rgb
29const NPX: i64 = 2304 // PS*PS
30const EPOCHS: i64 = 1000

functions

19func hw(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 1: main calls 1: sys_write
20func 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 }
called by 1: main calls 2: sys_mmapsys_write
32func lcg(st: *i64) -> i64 { var h: i64=st[0]; h=h*6364136223846793005+1442695040888963407; st[0]=h; return (h>>33)&2147483647 }
called by 1: main
35func features(px: i64, py: i64, scale: i64, f: *i64) -> i64
called by 1: main calls 3: sys_mmapit_sin4096it_cos4096
52func infer(W1: *i64, b1: *i64, W2: *i64, b2: *i64, f: *i64, h: *i64) -> i64
called by 1: main
81func main() -> i64