p2pfl.learning.aggregators.aggregator moduleΒΆ
Abstract aggregator.
- class p2pfl.learning.aggregators.aggregator.Aggregator(node_name='unknown')[source]ΒΆ
Bases:
object
Class to manage the aggregation of models.
- Parameters:
node_name (
str
) β String with the name of the node.
- 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