pub struct ActivationHistogram {
pub bins: Array2<f32>,
pub edges: Array1<f32>,
pub num_dims: usize,
/* private fields */
}Expand description
2D histogram of activation distributions across sequence steps.
Bins are computed along the value axis; each column represents one dimension of the activation vector.
Fields§
§bins: Array2<f32>Bin counts — shape (num_bins, num_dims)
edges: Array1<f32>Bin edges — shape (num_bins + 1,)
num_dims: usizeNumber of activation dimensions
Implementations§
Source§impl ActivationHistogram
impl ActivationHistogram
Sourcepub fn new(num_bins: usize, min_val: f32, max_val: f32, num_dims: usize) -> Self
pub fn new(num_bins: usize, min_val: f32, max_val: f32, num_dims: usize) -> Self
Create a new histogram with num_bins evenly spaced between min_val
and max_val for num_dims dimensions.
Sourcepub fn update(&mut self, x: &Array1<f32>) -> ModelResult<()>
pub fn update(&mut self, x: &Array1<f32>) -> ModelResult<()>
Accumulate one activation vector into the histogram.
Sourcepub fn density(&self) -> Array2<f32>
pub fn density(&self) -> Array2<f32>
Return normalized histogram (density) per dimension.
Each column sums to ≈ 1.0 (or 0.0 if no data was accumulated).
Sourcepub fn per_dim_entropy(&self) -> Array1<f32>
pub fn per_dim_entropy(&self) -> Array1<f32>
Per-dimension Shannon entropy of the distribution (in nats).
Sourcepub fn most_active_dims(&self, top_k: usize) -> Vec<usize>
pub fn most_active_dims(&self, top_k: usize) -> Vec<usize>
Return indices of the top_k dimensions with highest entropy.
Trait Implementations§
Source§impl Clone for ActivationHistogram
impl Clone for ActivationHistogram
Source§fn clone(&self) -> ActivationHistogram
fn clone(&self) -> ActivationHistogram
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ActivationHistogram
impl RefUnwindSafe for ActivationHistogram
impl Send for ActivationHistogram
impl Sync for ActivationHistogram
impl Unpin for ActivationHistogram
impl UnsafeUnpin for ActivationHistogram
impl UnwindSafe for ActivationHistogram
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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 more