pub struct FederatedLearning {
pub config: FederatedConfig,
pub clients: Vec<FederatedClient>,
pub global_model: Arc<RwLock<ModelParameters>>,
pub privacy_mechanism: PrivacyMechanism,
}Expand description
Federated Learning framework with privacy-preserving techniques
Implements federated averaging (FedAvg) and secure aggregation for privacy-preserving distributed machine learning.
Fields§
§config: FederatedConfigFederated learning configuration
clients: Vec<FederatedClient>Client models
global_model: Arc<RwLock<ModelParameters>>Global model parameters
privacy_mechanism: PrivacyMechanismPrivacy mechanism
Implementations§
Source§impl FederatedLearning
impl FederatedLearning
Sourcepub fn new(config: FederatedConfig, num_features: usize) -> Self
pub fn new(config: FederatedConfig, num_features: usize) -> Self
Create a new federated learning system
Sourcepub fn add_client(&mut self, client_id: String, dataset_size: usize)
pub fn add_client(&mut self, client_id: String, dataset_size: usize)
Add a client to the federated system
Sourcepub fn select_clients(&self) -> Vec<usize>
pub fn select_clients(&self) -> Vec<usize>
Select clients for a training round
Sourcepub fn federated_average(
&self,
client_updates: &[(usize, Vec<f64>)],
) -> Vec<f64>
pub fn federated_average( &self, client_updates: &[(usize, Vec<f64>)], ) -> Vec<f64>
Perform federated averaging of client updates
Sourcepub fn get_global_model(&self) -> ModelParameters
pub fn get_global_model(&self) -> ModelParameters
Get global model parameters
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FederatedLearning
impl RefUnwindSafe for FederatedLearning
impl Send for FederatedLearning
impl Sync for FederatedLearning
impl Unpin for FederatedLearning
impl UnwindSafe for FederatedLearning
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