pub struct FederatedServer {
pub global_parameters: HashMap<String, Tensor>,
pub clients: Vec<FederatedClient>,
pub aggregation: AggregationStrategy,
pub round: usize,
}Expand description
Federated server
Fields§
§global_parameters: HashMap<String, Tensor>Global model parameters
clients: Vec<FederatedClient>Connected clients
aggregation: AggregationStrategyAggregation strategy
round: usizeCurrent round
Implementations§
Source§impl FederatedServer
impl FederatedServer
Sourcepub fn new(
global_parameters: HashMap<String, Tensor>,
aggregation: AggregationStrategy,
) -> Self
pub fn new( global_parameters: HashMap<String, Tensor>, aggregation: AggregationStrategy, ) -> Self
Create a new federated server
Sourcepub fn register_client(&mut self, client: FederatedClient)
pub fn register_client(&mut self, client: FederatedClient)
Register a client
Sourcepub fn select_clients(&self, fraction: f32) -> Vec<usize>
pub fn select_clients(&self, fraction: f32) -> Vec<usize>
Select clients for training (random sampling)
Sourcepub fn distribute_model(&mut self, client_ids: &[usize])
pub fn distribute_model(&mut self, client_ids: &[usize])
Distribute global model to clients
Sourcepub fn train_round(
&mut self,
client_fraction: f32,
local_epochs: usize,
batch_size: usize,
)
pub fn train_round( &mut self, client_fraction: f32, local_epochs: usize, batch_size: usize, )
Run one round of federated learning
Sourcepub fn current_round(&self) -> usize
pub fn current_round(&self) -> usize
Get current round number
Auto Trait Implementations§
impl Freeze for FederatedServer
impl !RefUnwindSafe for FederatedServer
impl Send for FederatedServer
impl Sync for FederatedServer
impl Unpin for FederatedServer
impl !UnwindSafe for FederatedServer
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> 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