fl4health.parameter_exchange.full_exchanger module

class FullParameterExchanger[source]

Bases: ParameterExchanger

pull_parameters(parameters, model, config=None)[source]

Takes in a set of parameters in the form of NDArrays (list of numpy arrays) and injects them into the provided model.

Assumes all model parameters are contained in parameters. The state_dict is reconstituted because parameters is simply a list of arrays

Parameters:
  • parameters (NDArrays) – Parameter to inject into the provided model

  • model (nn.Module) – Model to inject the parameters into

  • config (Config | None, optional) – Not used.. Defaults to None.

Return type:

None

push_parameters(model, initial_model=None, config=None)[source]

Sending all of parameters ordered by state_dict keys NOTE: Order matters, because it is relied upon by pull_parameters below

Parameters:
  • model (nn.Module) – Model containing the weights to be sent.

  • initial_model (nn.Module | None, optional) – Not Used. Defaults to None.

  • config (Config | None, optional) – Not Used. Defaults to None.

Returns:

All parameters contained in the state_dict of the model parameter. The state_dict maintains a specific order.

Return type:

NDArrays