Schemas¶
Schemas used in the application.
- class substrafl.schemas.FedAvgAveragedState(*, avg_parameters_update: List[numpy.ndarray])¶
Bases:
substrafl.schemas._Model
Shared state sent by the aggregate_organization in the federated averaging strategy.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- Parameters
avg_parameters_update (List[numpy.ndarray]) –
- Return type
None
Bases:
substrafl.schemas._Model
Shared state returned by the train method of the algorithm for each client, received by the aggregate function in the federated averaging strategy.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- Parameters
n_samples (int) –
parameters_update (List[numpy.ndarray]) –
- Return type
None
- class substrafl.schemas.NewtonRaphsonAveragedStates(*, parameters_update: List[numpy.ndarray])¶
Bases:
substrafl.schemas._Model
Shared state sent by the aggregate_organization in the Newton Raphson strategy.
- Parameters
parameters_update (numpy.ndarray) – the new parameters_update sent to the clients
- Return type
None
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Bases:
substrafl.schemas._Model
Shared state returned by the train method of the algorithm for each client, received by the aggregate function in the Newton Raphson strategy.
- Parameters
n_samples (int) – number of samples of the client dataset.
gradients (numpy.ndarray) – gradients of the model parameters \(\theta\).
hessian (numpy.ndarray) – second derivative of the loss function regarding the model parameters \(\theta\).
- Return type
None
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class substrafl.schemas.ScaffoldAveragedStates(*, server_control_variate: List[numpy.ndarray], avg_parameters_update: List[numpy.ndarray])¶
Bases:
substrafl.schemas._Model
Shared state sent by the aggregate_organization (returned by the func strategies.scaffold.avg_shared_states)
- Parameters
server_control_variate (List[numpy.ndarray]) – the new server_control_variate sent to the clients
avg_parameters_update (List[numpy.ndarray]) – the weighted average of the parameters_update from each client
- Return type
None
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Bases:
substrafl.schemas._Model
Shared state returned by the train method of the algorithm for each client (e.g. algorithms.pytorch.scaffold.train)
- Parameters
parameters_update (List[numpy.ndarray]) – the weight update of the client (delta between fine-tuned weights and previous weights)
control_variate_update (List[numpy.ndarray]) – the control_variate update of the client
n_samples (int) – the number of samples of the client
server_control_variate (List[numpy.ndarray]) – the server control variate (
c
in the Scaffold paper’s Algo). It is sent by every client as the aggregation node doesn’t have a persistent state, and should be the same for each client as it should not be modified in the client Algo
- Return type
None
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- class substrafl.schemas.StrategyName(value)¶
-
An enumeration.
- class substrafl.schemas._Model¶
Bases:
pydantic.main.BaseModel
Base model configuration
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
- Return type
None