pub struct LotteryTicketState {
pub initial_weights: Vec<WeightTensor>,
pub masks: Vec<PruningMask>,
pub iteration: usize,
pub sparsity_history: Vec<f32>,
pub enabled: bool,
}Expand description
State for Lottery Ticket Hypothesis rewinding
The Lottery Ticket Hypothesis (Frankle & Carlin, 2019) suggests that randomly initialized networks contain sparse subnetworks (“winning tickets”) that can achieve comparable accuracy when trained in isolation.
Fields§
§initial_weights: Vec<WeightTensor>Initial weights before any training (for rewinding)
masks: Vec<PruningMask>Current pruning masks learned through training
iteration: usizeCurrent pruning iteration
sparsity_history: Vec<f32>Sparsity at each iteration
enabled: boolWhether rewinding is enabled
Implementations§
Source§impl LotteryTicketState
impl LotteryTicketState
Sourcepub fn new(initial_weights: Vec<WeightTensor>) -> Self
pub fn new(initial_weights: Vec<WeightTensor>) -> Self
Creates a new lottery ticket state
Sourcepub fn rewind(&self) -> Vec<WeightTensor>
pub fn rewind(&self) -> Vec<WeightTensor>
Rewinds weights to initial values while applying current masks
Returns the rewound weights with masks applied
Sourcepub fn update_masks(&mut self, new_masks: Vec<PruningMask>, sparsity: f32)
pub fn update_masks(&mut self, new_masks: Vec<PruningMask>, sparsity: f32)
Updates masks after a pruning iteration
Sourcepub fn current_sparsity(&self) -> f32
pub fn current_sparsity(&self) -> f32
Returns the current overall sparsity
Trait Implementations§
Source§impl Clone for LotteryTicketState
impl Clone for LotteryTicketState
Source§fn clone(&self) -> LotteryTicketState
fn clone(&self) -> LotteryTicketState
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 LotteryTicketState
impl RefUnwindSafe for LotteryTicketState
impl Send for LotteryTicketState
impl Sync for LotteryTicketState
impl Unpin for LotteryTicketState
impl UnsafeUnpin for LotteryTicketState
impl UnwindSafe for LotteryTicketState
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