pub struct DiversityMonitor { /* private fields */ }Expand description
Monitors diversity of generated synthetic samples over time.
Tracks rolling statistics to detect trends like mode collapse or decreasing diversity during generation.
§Example
use aprender::synthetic::{DiversityMonitor, DiversityScore};
let mut monitor = DiversityMonitor::new(5);
monitor.record(DiversityScore::new(0.5, 0.3, 0.7));
monitor.record(DiversityScore::new(0.4, 0.2, 0.6));
assert_eq!(monitor.sample_count(), 2);
assert!(monitor.mean_diversity() > 0.0);Implementations§
Source§impl DiversityMonitor
impl DiversityMonitor
Sourcepub fn with_collapse_threshold(self, threshold: f32) -> Self
pub fn with_collapse_threshold(self, threshold: f32) -> Self
Set the collapse detection threshold.
Sourcepub fn record(&mut self, score: DiversityScore)
pub fn record(&mut self, score: DiversityScore)
Record a new diversity score.
Sourcepub fn sample_count(&self) -> usize
pub fn sample_count(&self) -> usize
Get the number of samples in the window.
Sourcepub fn total_samples(&self) -> usize
pub fn total_samples(&self) -> usize
Get total samples processed.
Sourcepub fn latest(&self) -> Option<DiversityScore>
pub fn latest(&self) -> Option<DiversityScore>
Get the most recent diversity score.
Sourcepub fn mean_diversity(&self) -> f32
pub fn mean_diversity(&self) -> f32
Get mean diversity over the window.
Sourcepub fn min_diversity(&self) -> f32
pub fn min_diversity(&self) -> f32
Get minimum diversity in the window.
Sourcepub fn max_diversity(&self) -> f32
pub fn max_diversity(&self) -> f32
Get maximum diversity in the window.
Sourcepub fn is_collapsing(&self) -> bool
pub fn is_collapsing(&self) -> bool
Check if current diversity indicates collapse.
Sourcepub fn is_trending_down(&self) -> bool
pub fn is_trending_down(&self) -> bool
Check if diversity is trending downward.
Compares first half of window to second half.
Sourcepub fn compute_from_distances(distances: &[f32]) -> DiversityScore
pub fn compute_from_distances(distances: &[f32]) -> DiversityScore
Trait Implementations§
Source§impl Clone for DiversityMonitor
impl Clone for DiversityMonitor
Source§fn clone(&self) -> DiversityMonitor
fn clone(&self) -> DiversityMonitor
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DiversityMonitor
impl Debug for DiversityMonitor
Auto Trait Implementations§
impl Freeze for DiversityMonitor
impl RefUnwindSafe for DiversityMonitor
impl Send for DiversityMonitor
impl Sync for DiversityMonitor
impl Unpin for DiversityMonitor
impl UnwindSafe for DiversityMonitor
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)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