:py:mod:`kosmos.ml.fl.fl_client` ================================ .. py:module:: kosmos.ml.fl.fl_client Classes ------- .. py:class:: FLClient(trainer: kosmos.ml.sl_trainer.SLTrainer, node: kosmos.topology.node.Node) Federated learning client. Initialize a federated learning client. :param trainer: The trainer used for local training. :type trainer: SLTrainer :param node: The node representing this client in the topology. :type node: Node | .. rubric:: Methods .. py:method:: get_model_state() -> dict Get the current model state of the client. :returns: A state_dict containing the model parameters. :rtype: dict .. py:method:: set_model_state(state_dict: dict) -> None Set the client's model state. :param state_dict: The state_dict to set the client's model state to. :type state_dict: dict .. py:method:: train(num_epochs: int, dataloader: torch.utils.data.DataLoader, fl_round: int) -> collections.abc.Iterator[kosmos.ml.sl_result.SLTrainIterationResult] Train the client's model on the given data. :param num_epochs: Number of epochs to run. :type num_epochs: int :param dataloader: Dataloader providing the local training data. :type dataloader: DataLoader :param fl_round: The federated learning round index for this training run. :type fl_round: int :returns: An iterator yielding one training result per epoch. :rtype: Iterator[SLTrainIterationResult]