pub struct EwcPlusPlus { /* private fields */ }Expand description
EWC++ implementation
Implementations§
Source§impl EwcPlusPlus
impl EwcPlusPlus
Sourcepub fn update_fisher(&mut self, gradients: &[f32])
pub fn update_fisher(&mut self, gradients: &[f32])
Update Fisher information online using EMA
Sourcepub fn detect_task_boundary(&self, gradients: &[f32]) -> bool
pub fn detect_task_boundary(&self, gradients: &[f32]) -> bool
Detect task boundary using distribution shift
Sourcepub fn start_new_task(&mut self)
pub fn start_new_task(&mut self)
Start new task - saves current Fisher to memory
Sourcepub fn apply_constraints(&self, gradients: &[f32]) -> Vec<f32>
pub fn apply_constraints(&self, gradients: &[f32]) -> Vec<f32>
Apply EWC++ constraints to gradients
Sourcepub fn regularization_loss(&self, current_weights: &[f32]) -> f32
pub fn regularization_loss(&self, current_weights: &[f32]) -> f32
Compute EWC regularization loss
Sourcepub fn set_optimal_weights(&mut self, weights: &[f32])
pub fn set_optimal_weights(&mut self, weights: &[f32])
Update optimal weights reference
Sourcepub fn consolidate_all_tasks(&mut self)
pub fn consolidate_all_tasks(&mut self)
Consolidate all tasks (merge Fisher information)
Sourcepub fn set_lambda(&mut self, lambda: f32)
pub fn set_lambda(&mut self, lambda: f32)
Set lambda manually
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Get task count
Sourcepub fn current_task_id(&self) -> usize
pub fn current_task_id(&self) -> usize
Get current task ID
Sourcepub fn samples_seen(&self) -> u64
pub fn samples_seen(&self) -> u64
Get samples seen for current task
Sourcepub fn importance_scores(&self) -> Vec<f32>
pub fn importance_scores(&self) -> Vec<f32>
Get parameter importance scores
Trait Implementations§
Source§impl Clone for EwcPlusPlus
impl Clone for EwcPlusPlus
Source§fn clone(&self) -> EwcPlusPlus
fn clone(&self) -> EwcPlusPlus
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 moreSource§impl Debug for EwcPlusPlus
impl Debug for EwcPlusPlus
Source§impl<'de> Deserialize<'de> for EwcPlusPlus
impl<'de> Deserialize<'de> for EwcPlusPlus
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for EwcPlusPlus
impl RefUnwindSafe for EwcPlusPlus
impl Send for EwcPlusPlus
impl Sync for EwcPlusPlus
impl Unpin for EwcPlusPlus
impl UnwindSafe for EwcPlusPlus
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