pub struct Data2VecState {
pub teacher_params: Vec<f32>,
pub step: usize,
}Expand description
Mutable state that tracks the teacher EMA parameter vector and training step.
The teacher is initialised to a copy of the online (student) parameters and updated each training step via:
θ_teacher ← m · θ_teacher + (1−m) · θ_onlineFields§
§teacher_params: Vec<f32>EMA teacher parameter vector (flat, same length as the student).
step: usizeTraining-step counter (incremented by Self::update_teacher).
Implementations§
Source§impl Data2VecState
impl Data2VecState
Sourcepub fn new(online_params: &[f32]) -> Self
pub fn new(online_params: &[f32]) -> Self
Initialise state by cloning the current online (student) parameters.
The teacher starts as an exact copy of the student so that the very first EMA update moves from a well-defined position.
Sourcepub fn update_teacher(
&mut self,
online_params: &[f32],
momentum: f32,
) -> SslResult<()>
pub fn update_teacher( &mut self, online_params: &[f32], momentum: f32, ) -> SslResult<()>
Apply the EMA update θ_teacher ← m·θ_teacher + (1−m)·θ_online and
increment the step counter.
§Errors
SslError::InvalidMomentumwhenmomentumis outside[0, 1]or non-finite.SslError::DimensionMismatchwhenonline_paramshas a different length than the stored teacher vector.
Trait Implementations§
Source§impl Clone for Data2VecState
impl Clone for Data2VecState
Source§fn clone(&self) -> Data2VecState
fn clone(&self) -> Data2VecState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Data2VecState
impl RefUnwindSafe for Data2VecState
impl Send for Data2VecState
impl Sync for Data2VecState
impl Unpin for Data2VecState
impl UnsafeUnpin for Data2VecState
impl UnwindSafe for Data2VecState
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