:py:mod:`kosmos.simulator.fl_simulator` ======================================= .. py:module:: kosmos.simulator.fl_simulator Classes ------- .. py: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: :py:class:`kosmos.simulator.simulator.Simulator` Federated learning simulator. Initialize the simulator. :param network: The network topology. :type network: Network :param train_config: The federated learning training configuration. :type train_config: FLTrainConfig :param client_nodes: The node references of the clients. :type client_nodes: list[NodeReference] :param server_node: The node reference of the server. :type server_node: NodeReference :param seed: The seed for the random number generator. Defaults to 1. :type seed: int | .. rubric:: Methods .. py:method:: 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. :rtype: Iterator[SLTrainIterationResult] .. py:method:: test() -> kosmos.ml.sl_result.SLTestIterationResult Evaluate the global model on the test dataset. :returns: The result of the global model evaluation. :rtype: SLTrainIterationResult