pub struct LayerAnalyzer { /* private fields */ }Expand description
Layer analyzer for monitoring and analyzing individual layer behavior.
Implementations§
Source§impl LayerAnalyzer
impl LayerAnalyzer
Sourcepub fn with_config(config: LayerAnalysisConfig) -> Self
pub fn with_config(config: LayerAnalysisConfig) -> Self
Create a new layer analyzer with custom configuration.
Sourcepub fn record_layer_weights(&mut self, layer_name: &str, weights: Vec<f64>)
pub fn record_layer_weights(&mut self, layer_name: &str, weights: Vec<f64>)
Record a real weight tensor (flattened) for a layer. Required before
Self::analyze_layer_weight_distribution can report anything.
Sourcepub fn record_activation_grid(&mut self, layer_name: &str, grid: Vec<Vec<f64>>)
pub fn record_activation_grid(&mut self, layer_name: &str, grid: Vec<Vec<f64>>)
Record a real captured activation grid (e.g. [batch][feature], or a
spatial [height][width] slice) for a layer. Required before
Self::create_activation_heatmap can report anything.
Record one real hidden-state sample (a batch of hidden-state vectors
captured at one point in time/training) for a layer. Accumulates into
that layer’s history; required before
Self::analyze_layer_hidden_states can report anything.
Sourcepub fn record_attention_weights(
&mut self,
layer_name: &str,
weights: Vec<Vec<f64>>,
input_tokens: Option<Vec<String>>,
output_tokens: Option<Vec<String>>,
)
pub fn record_attention_weights( &mut self, layer_name: &str, weights: Vec<Vec<f64>>, input_tokens: Option<Vec<String>>, output_tokens: Option<Vec<String>>, )
Record a real attention-weight matrix for a layer. input_tokens /
output_tokens default to positional labels (pos_0, pos_1, …)
when not supplied – a real (if generic) label derived from the
matrix’s own shape, never fabricated content. Required before
Self::create_attention_visualization can report anything.
Sourcepub fn record_layer_activations(
&mut self,
layer_name: &str,
stats: LayerActivationStats,
)
pub fn record_layer_activations( &mut self, layer_name: &str, stats: LayerActivationStats, )
Record layer activation statistics.
Sourcepub fn record_layer_stats(&mut self, stats: LayerActivationStats)
pub fn record_layer_stats(&mut self, stats: LayerActivationStats)
Record layer statistics (extracts layer name and calls record_layer_activations).
Sourcepub fn get_layer_activations(
&self,
layer_name: &str,
) -> Option<&[LayerActivationStats]>
pub fn get_layer_activations( &self, layer_name: &str, ) -> Option<&[LayerActivationStats]>
Get layer activation statistics for a specific layer.
Sourcepub fn perform_layer_by_layer_analysis(&self) -> Vec<LayerAnalysis>
pub fn perform_layer_by_layer_analysis(&self) -> Vec<LayerAnalysis>
Perform comprehensive layer-by-layer analysis.
Sourcepub fn analyze_single_layer(
&self,
layer_name: &str,
current_stats: &LayerActivationStats,
stats_history: &[LayerActivationStats],
) -> LayerAnalysis
pub fn analyze_single_layer( &self, layer_name: &str, current_stats: &LayerActivationStats, stats_history: &[LayerActivationStats], ) -> LayerAnalysis
Analyze a single layer comprehensively.
Sourcepub fn calculate_layer_health_score(&self, stats: &LayerActivationStats) -> f64
pub fn calculate_layer_health_score(&self, stats: &LayerActivationStats) -> f64
Calculate layer health score.
Sourcepub fn identify_layer_issues(
&self,
current_stats: &LayerActivationStats,
stats_history: &[LayerActivationStats],
) -> Vec<String>
pub fn identify_layer_issues( &self, current_stats: &LayerActivationStats, stats_history: &[LayerActivationStats], ) -> Vec<String>
Identify issues in a layer.
Sourcepub fn generate_layer_recommendations(
&self,
issues: &[String],
layer_type: &str,
) -> Vec<String>
pub fn generate_layer_recommendations( &self, issues: &[String], layer_type: &str, ) -> Vec<String>
Generate recommendations for layer improvement.
Sourcepub fn analyze_weight_distributions(
&self,
) -> HashMap<String, WeightDistribution>
pub fn analyze_weight_distributions( &self, ) -> HashMap<String, WeightDistribution>
Analyze weight distributions for every layer with a real weight
tensor on record (see Self::record_layer_weights). Layers without
one are simply absent from the result – never filled with a
fabricated distribution.
Sourcepub fn generate_activation_heatmaps(&self) -> HashMap<String, ActivationHeatmap>
pub fn generate_activation_heatmaps(&self) -> HashMap<String, ActivationHeatmap>
Generate activation heatmaps for every layer with a real recorded
activation grid (see Self::record_activation_grid).
Sourcepub fn generate_attention_visualizations(
&self,
) -> HashMap<String, AttentionVisualization>
pub fn generate_attention_visualizations( &self, ) -> HashMap<String, AttentionVisualization>
Generate attention visualizations for every layer with real recorded
attention weights (see Self::record_attention_weights).
Analyze hidden states for every layer with real recorded hidden-state
samples (see Self::record_hidden_state_sample). A layer is
omitted (never fabricated) when its sample count is too small for a
statistically meaningful analysis – see
Self::analyze_layer_hidden_states.
Trait Implementations§
Source§impl Debug for LayerAnalyzer
impl Debug for LayerAnalyzer
Auto Trait Implementations§
impl Freeze for LayerAnalyzer
impl RefUnwindSafe for LayerAnalyzer
impl Send for LayerAnalyzer
impl Sync for LayerAnalyzer
impl Unpin for LayerAnalyzer
impl UnsafeUnpin for LayerAnalyzer
impl UnwindSafe for LayerAnalyzer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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.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.