kosmos.simulator.fl_simulator¶
Classes¶
- class FLSimulator(network: kosmos.topology.net.Network, train_config: kosmos.ml.config.sl_train.FLTrainConfig, client_nodes: list[kosmos.topology.typing.NodeReference], server_node: kosmos.topology.typing.NodeReference, seed: int = 1)¶
Bases:
kosmos.simulator.simulator.SimulatorFederated learning simulator.
Initialize the simulator.
- Parameters:
network (Network) – The network topology.
train_config (FLTrainConfig) – The federated learning training configuration.
client_nodes (list[NodeReference]) – The node references of the clients.
server_node (NodeReference) – The node reference of the server.
seed (int) – The seed for the random number generator. Defaults to 1.
Methods
- train() collections.abc.Iterator[kosmos.ml.sl_result.SLTrainIterationResult]¶
Run federated training across all configured rounds.
- Returns:
- An iterator yielding one training result per epoch
for all rounds.
- Return type:
Iterator[SLTrainIterationResult]
- test() kosmos.ml.sl_result.SLTestIterationResult¶
Evaluate the global model on the test dataset.
- Returns:
The result of the global model evaluation.
- Return type: