code wiki / (root) / nx_vq_train.nx

nx_vq_train.nx

buildroot/runtime/nx_vq_train.nx

1953 B43 linesdepth 1pulls 1 transitivereach 2 importersview sourcekind librarytopic vq
docsdependenciesstructsconstsfunctions

about

nx_vq_train.nx -- Lloyd's algorithm (k-means) VQ codebook training: moonshot rung #2. Given a training set of LPC reflection vectors, it iteratively (1) assigns each vector to its nearest codebook entry and (2) moves each centroid to the mean of its assigned vectors -- provably non-increasing distortion. This is the optimal CLASSICAL codebook that neural RVQ generalises: it lowers the VQ distortion at the SAME bitrate (better coverage), the bridge from raw VQ to the learned codebook. Composes nx_vq. Caller owns all scratch (no hidden alloc). license_tier: ORIGINAL

dependencies 1 imports · 2 importers

nx_vq.nx nx_vq_train.nx nx_rvq_gate.nx nx_vq_train_gate.nx

imports: nx_vq.nx

imported by: nx_rvq_gate.nxnx_vq_train_gate.nx

structs

none

consts

none

functions

9func vqt_vec(train: *i64, t: i64, D: i64) -> *i64 { return (train as i64 + t*D*8) as *i64 }
12func vqt_iterate(train: *i64, T: i64, cb: *i64, K: i64, D: i64, assign: *i64, sum: *i64, cnt: *i64) -> i64
called by 2: mainmain calls 2: vq_encodevqt_vec
34func vqt_distortion(train: *i64, T: i64, cb: *i64, K: i64, D: i64) -> i64
called by 1: main calls 3: vqt_vecvq_dist2vq_encode