fl4health.clients.fedbn_client module

class FedBnClient(data_path, metrics, device, loss_meter_type=LossMeterType.AVERAGE, checkpoint_and_state_module=None, reporters=None, progress_bar=False, client_name=None)[source]

Bases: BasicClient

This class serves as a sparse interface for clients aiming to leverage the FedBN method (https://arxiv.org/abs/2102.07623) or any other approach that excludes specific types of model layers during parameter exchange. This class simply ensures that the user has overridden the get_parameter_exchanger properly.

For example, in FedBN, batch normalization layers are excluded from exchange with the server but all other layers flow through and are aggregated via whatever strategy the server is implementing. An example of this where one wants to exclude 2D batch normalization layers during exchange is LayerExchangerWithExclusions(self.model, {nn.BatchNorm2d}), where the model is provided so that the exchanger can identify the appropriate layers to leave out.

setup_client(config)[source]

Set dataloaders, optimizers, parameter exchangers and other attributes derived from these. Then set initialized attribute to True.

Parameters:

config (Config) – The config from the server.

Return type:

None