Skip to main content

quantize

Function quantize 

Source
pub fn quantize(weights: &[f32], threshold: f32) -> Vec<Trit>
Expand description

Quantize a slice of f32 weights to balanced ternary using threshold tau.

Rule: w > tau → +1 (truth) w < -tau → -1 (conflict) else → 0 (hold)

A tau of 0.5 * mean(|weights|) matches the BitNet b1.58 scheme.