pub struct ModelSyncProtocol { /* private fields */ }Expand description
Model synchronization protocol for federated learning
Implementations§
Source§impl ModelSyncProtocol
impl ModelSyncProtocol
Sourcepub fn new(
max_rounds: usize,
min_clients_per_round: usize,
convergence_window: usize,
convergence_threshold: f64,
) -> Self
pub fn new( max_rounds: usize, min_clients_per_round: usize, convergence_window: usize, convergence_threshold: f64, ) -> Self
Create a new model synchronization protocol
Sourcepub fn start_round(
&mut self,
global_model: Cid,
client_count: usize,
) -> Result<usize, GradientError>
pub fn start_round( &mut self, global_model: Cid, client_count: usize, ) -> Result<usize, GradientError>
Start a new round
Sourcepub fn complete_round(
&mut self,
round_num: usize,
aggregated_gradient: Vec<f32>,
loss: f64,
) -> Result<(), GradientError>
pub fn complete_round( &mut self, round_num: usize, aggregated_gradient: Vec<f32>, loss: f64, ) -> Result<(), GradientError>
Complete the current round
Sourcepub fn should_continue(&self) -> bool
pub fn should_continue(&self) -> bool
Check if training should continue
Sourcepub fn has_converged(&self) -> bool
pub fn has_converged(&self) -> bool
Check if training has converged
Sourcepub fn current_round(&self) -> usize
pub fn current_round(&self) -> usize
Get the current round number
Sourcepub fn total_rounds(&self) -> usize
pub fn total_rounds(&self) -> usize
Get the total number of rounds
Sourcepub fn get_round(&self, round_num: usize) -> Option<&FederatedRound>
pub fn get_round(&self, round_num: usize) -> Option<&FederatedRound>
Get round information
Sourcepub fn latest_loss(&self) -> Option<f64>
pub fn latest_loss(&self) -> Option<f64>
Get the latest loss
Sourcepub fn max_rounds(&self) -> usize
pub fn max_rounds(&self) -> usize
Get max rounds
Auto Trait Implementations§
impl Freeze for ModelSyncProtocol
impl RefUnwindSafe for ModelSyncProtocol
impl Send for ModelSyncProtocol
impl Sync for ModelSyncProtocol
impl Unpin for ModelSyncProtocol
impl UnwindSafe for ModelSyncProtocol
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> 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