pub struct AtomLinearImage {
pub atom_idx: usize,
pub t_bar: f64,
pub b0: Array1<f64>,
pub b1: Array1<f64>,
pub row_codes: Option<Array1<f64>>,
pub v: Option<Array1<f64>>,
}Expand description
The fitted straight sub-model γ̃(t) = b₀ + (t − t̄)·b₁ of one d = 1 atom:
the exact assignment-mass-weighted least-squares line fit to the atom’s
leave-this-atom-out RESPONSE residual y_resp over its assigned rows (the
curved family’s nested Θ = 0 sub-model on common data, #1202). Carried on a
verdict that selects LINEAR so the collapsed reconstruction can replace the
curved decoded row with this straight image at any coordinate WITHOUT
re-entering the (broken, #1051) outer fit — the coefficients are already
realized inside the adjudication.
Fields§
§atom_idx: usizeThe atom’s slot index in the dictionary (so the collapsed assembly knows which atom’s decoded row to substitute).
t_bar: f64The mass-weighted coordinate mean t̄ the line is centered on.
b0: Array1<f64>Per-output-channel centered intercept b₀ = γ̄ at t̄ (length p).
b1: Array1<f64>Per-output-channel slope b₁ (length p).
row_codes: Option<Array1<f64>>#1026 collapse-rescue per-row coordinates. None for the ordinary path:
the line is evaluated at the atom’s OWN realized coordinate t. Some(u)
only when the atom’s circle codes had collapsed to a single point
(s_tt ≈ 0) so its own coordinate carries no spread — then the line is fit
against, and reconstruct evaluates it at, these FRESH per-row codes uᵢ
(the projection of the leave-this-atom-out residual onto its top
mass-weighted output direction). This is what lets a circle atom that the
joint fit drove into the degenerate “chord-through-the-arc” fixed point
still reconstruct its residual’s best linear direction — recovering the
linear-tail reach the hybrid-split was designed to deliver — instead of a
constant (its collapsed curve), which is the real-OLMo rank-1 co-collapse
(held-out EV ≈ 0.13 vs the linear ceiling ≈ 0.74). Length n (one per
reconstructed row); unassigned rows are gated to zero by a_k anyway.
TRAIN-ONLY CAVEAT (#1777): these are the TRAIN rows’ codes. They are only
meaningful for the exact rows the split was fit on; a held-out row has no
entry here and used to fall back to the atom’s own (collapsed) coordinate
own_t — a DIFFERENT, degraded model out of sample. Prefer Self::v:
projecting a held-out row’s leave-this-atom-out residual onto v recovers
that row’s coordinate by the SAME math the train codes were built with, so
train and OOS use one model. row_codes is retained for back-compat and as
the exact cached train projection.
v: Option<Array1<f64>>#1777 collapse-rescue projection DIRECTION v (length p, unit norm), the
top mass-weighted output direction of the atom’s leave-this-atom-out
residual. Some exactly when this is a collapse-rescued image (paired with
row_codes); None for the ordinary straight-image path (which decodes at
the atom’s own coordinate). This is the SERIALIZABLE quantity the FFI must
persist so an OOS term can recompute any row’s coordinate as
uᵢ = ⟨y_i − Σ_{j≠k} f_j(x_i), v⟩ — identical to the train code
row_codes[i] on a train row, and the correct held-out coordinate on an OOS
row (see Self::coordinate_from_residual). Length must equal b0/b1.
Implementations§
Source§impl AtomLinearImage
impl AtomLinearImage
Sourcepub fn fill_row(&self, t: f64, out: &mut [f64])
pub fn fill_row(&self, t: f64, out: &mut [f64])
Evaluate the straight sub-model b₀ + (t − t̄)·b₁ into out (length p).
Sourcepub fn coordinate_for_row(&self, row: usize, own_t: f64) -> f64
pub fn coordinate_for_row(&self, row: usize, own_t: f64) -> f64
The coordinate at which row row should evaluate this image: the
collapse-rescue fresh code uᵢ when present (#1026), else the atom’s own
realized coordinate own_t passed by the caller.
TRAIN-ONLY: row_codes is indexed by TRAIN row, so this is correct only
for the rows the split was fit on. Out of sample use
Self::coordinate_from_residual (target-aware, model-identical to train).
Sourcepub fn coordinate_from_residual(&self, resid: &[f64]) -> Option<f64>
pub fn coordinate_from_residual(&self, resid: &[f64]) -> Option<f64>
#1777 — the collapse-rescue coordinate of a row from ITS OWN
leave-this-atom-out residual resid = y_i − Σ_{j≠k} f_j(x_i) (length p),
namely uᵢ = ⟨resid, v⟩. Some(uᵢ) exactly when this is a collapse-rescued
image (v is set); None for the ordinary straight-image path (which has
no projection direction and decodes at the atom’s own coordinate).
This is the SAME math [build_collapse_rescue_linear_image] used to build
the train row_codes (row_codes[i] = ⟨target_resid[i], v⟩), so on a TRAIN
row it reproduces row_codes[i] exactly, and on a HELD-OUT row it yields
that row’s correct coordinate — train and OOS share one model. Returns
None if resid’s length disagrees with v.
Sourcepub fn is_collapse_rescued(&self) -> bool
pub fn is_collapse_rescued(&self) -> bool
Whether this image is a #1777 collapse-rescued image (carries a projection
direction v and per-row train codes) rather than an ordinary straight
image evaluated at the atom’s own coordinate.
Trait Implementations§
Source§impl Clone for AtomLinearImage
impl Clone for AtomLinearImage
Source§fn clone(&self) -> AtomLinearImage
fn clone(&self) -> AtomLinearImage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for AtomLinearImage
impl RefUnwindSafe for AtomLinearImage
impl Send for AtomLinearImage
impl Sync for AtomLinearImage
impl Unpin for AtomLinearImage
impl UnsafeUnpin for AtomLinearImage
impl UnwindSafe for AtomLinearImage
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.