p2pfl.learning.aggregators.aggregator moduleΒΆ
Abstract aggregator.
- class p2pfl.learning.aggregators.aggregator.Aggregator(disable_partial_aggregation=False)[source]ΒΆ
Bases:
NodeComponentClass to manage the aggregation of models.
- Parameters:
node_addr β Address of the node.
disable_partial_aggregation (
bool)
-
SUPPORTS_PARTIAL_AGGREGATION:
bool= FalseΒΆ
- add_model(model)[source]ΒΆ
Add a model. The first model to be added starts the run method (timeout).
- Parameters:
model (
P2PFLModel) β Model to add.- Return type:
list[str]- Returns:
List of contributors.
- aggregate(models)[source]ΒΆ
Aggregate the models.
- Parameters:
models (
list[P2PFLModel]) β Dictionary with the models to aggregate.- Return type:
- get_aggregated_models()[source]ΒΆ
Get the list of aggregated models.
- Return type:
list[str]- Returns:
Name of nodes that colaborated to get the model.
- get_missing_models()[source]ΒΆ
Obtain missing models for the aggregation.
- Return type:
set- Returns:
A set of missing models.
- get_model(except_nodes)[source]ΒΆ
Get corresponding aggregation depending if aggregator supports partial aggregations.
- Parameters:
except_nodes β List of nodes to exclude from the aggregation.
- Return type:
- get_required_callbacks()[source]ΒΆ
Get the required callbacks for the aggregation.
- Return type:
list[str]- Returns:
List of required callbacks.
- set_nodes_to_aggregate(nodes_to_aggregate)[source]ΒΆ
List with the name of nodes to aggregate. Be careful, by setting new nodes, the actual aggregation will be lost.
- Parameters:
nodes_to_aggregate (
list[str]) β List of nodes to aggregate. Empty for no aggregation.- Raises:
Exception β If the aggregation is running.
- Return type:
None