pub struct AttentionVisualizer<F: Float + Debug + ScalarOperand> { /* private fields */ }
Expand description
Attention mechanism visualizer
Implementations§
Source§impl<F: Float + Debug + 'static + FromPrimitive + ScalarOperand + Send + Sync + Serialize> AttentionVisualizer<F>
impl<F: Float + Debug + 'static + FromPrimitive + ScalarOperand + Send + Sync + Serialize> AttentionVisualizer<F>
Sourcepub fn new(model: Sequential<F>, config: VisualizationConfig) -> Self
pub fn new(model: Sequential<F>, config: VisualizationConfig) -> Self
Create a new attention visualizer
Sourcepub fn visualize_attention(
&mut self,
input: &ArrayD<F>,
options: &AttentionVisualizationOptions,
) -> Result<Vec<PathBuf>>
pub fn visualize_attention( &mut self, input: &ArrayD<F>, options: &AttentionVisualizationOptions, ) -> Result<Vec<PathBuf>>
Visualize attention patterns
Sourcepub fn get_cached_attention(
&self,
layer_name: &str,
) -> Option<&AttentionData<F>>
pub fn get_cached_attention( &self, layer_name: &str, ) -> Option<&AttentionData<F>>
Get cached attention data for a layer
Sourcepub fn clear_cache(&mut self)
pub fn clear_cache(&mut self)
Clear the attention cache
Sourcepub fn get_attention_statistics(&self) -> Result<Vec<AttentionStatistics<F>>>
pub fn get_attention_statistics(&self) -> Result<Vec<AttentionStatistics<F>>>
Get attention statistics for all cached layers
Sourcepub fn update_config(&mut self, config: VisualizationConfig)
pub fn update_config(&mut self, config: VisualizationConfig)
Update the visualization configuration
Sourcepub fn export_attention_data(
&self,
layer_name: &str,
export_options: &ExportOptions,
) -> Result<PathBuf>
pub fn export_attention_data( &self, layer_name: &str, export_options: &ExportOptions, ) -> Result<PathBuf>
Export attention data in various formats
Auto Trait Implementations§
impl<F> Freeze for AttentionVisualizer<F>
impl<F> !RefUnwindSafe for AttentionVisualizer<F>
impl<F> Send for AttentionVisualizer<F>where
F: Send,
impl<F> Sync for AttentionVisualizer<F>where
F: Sync,
impl<F> Unpin for AttentionVisualizer<F>
impl<F> !UnwindSafe for AttentionVisualizer<F>
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> 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