kosmos.ml.fl.fl_server

Classes

class FLServer(trainer: kosmos.ml.sl_trainer.SLTrainer, node: kosmos.topology.node.Node)

Federated learning server.

Initialize a federated learning server.

Parameters:
  • trainer (SLTrainer) – The trainer used by this server.

  • node (Node) – The node representing this server in the topology.


Methods

get_model_state() dict

Get the current model state of the server.

Returns:

A state_dict containing the model parameters.

Return type:

dict

aggregate(client_states: list[dict]) None

Aggregate model states from clients using simple averaging.

Parameters:

client_states (list[dict]) – A list of model state_dicts from clients.

test(dataloader: torch.utils.data.DataLoader) kosmos.ml.sl_result.SLTestIterationResult

Evaluate the global model on test data.

Parameters:

dataloader (DataLoader) – Dataloader providing the test data.

Returns:

The result of the test iteration.

Return type:

SLTestIterationResult