fl_server_ai.aggregation ¶
Modules:
| Name | Description |
|---|---|
base | |
fed_dc | |
fed_prox | |
mean | |
method | |
Classes:
| Name | Description |
|---|---|
Aggregation | Abstract base class for aggregation strategies. |
MeanAggregation | Implements the aggregate method for aggregating models by calculating their mean. |
Functions:
| Name | Description |
|---|---|
get_aggregation_class | Get the aggregation class based on the provided model, training or aggregation method. |
Attributes¶
Classes¶
Aggregation ¶
Bases: ABC
flowchart TD
fl_server_ai.aggregation.Aggregation[Aggregation]
click fl_server_ai.aggregation.Aggregation href "" "fl_server_ai.aggregation.Aggregation"
Abstract base class for aggregation strategies.
- API Reference
fl_server_aiaggregation
- API Reference
fl_server_aiaggregation
Methods:
| Name | Description |
|---|---|
aggregate | Abstract method for aggregating models. |
Source code in fl_server_ai/aggregation/base.py
Functions¶
aggregate abstractmethod ¶
aggregate(models: Sequence[Module], model_sample_sizes: Sequence[int], *, deepcopy: bool = True) -> Module
Abstract method for aggregating models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| Sequence[Module] | The models to be aggregated. | required |
| Sequence[int] | The sample sizes for each model. | required |
| bool | Whether to create a deep copy of the models. Defaults to True. | True |
Returns:
| Type | Description |
|---|---|
Module | torch.nn.Module: The aggregated model. |
Source code in fl_server_ai/aggregation/base.py
MeanAggregation ¶
Bases: Aggregation
flowchart TD
fl_server_ai.aggregation.MeanAggregation[MeanAggregation]
fl_server_ai.aggregation.base.Aggregation[Aggregation]
fl_server_ai.aggregation.base.Aggregation --> fl_server_ai.aggregation.MeanAggregation
click fl_server_ai.aggregation.MeanAggregation href "" "fl_server_ai.aggregation.MeanAggregation"
click fl_server_ai.aggregation.base.Aggregation href "" "fl_server_ai.aggregation.base.Aggregation"
Implements the aggregate method for aggregating models by calculating their mean.
Methods:
| Name | Description |
|---|---|
aggregate | Aggregate models by calculating the mean. |
Source code in fl_server_ai/aggregation/mean.py
Functions¶
aggregate ¶
aggregate(models: Sequence[Module], model_sample_sizes: Sequence[int], *, deepcopy: bool = True) -> Module
Aggregate models by calculating the mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| Sequence[Module] | The models to be aggregated. | required |
| Sequence[int] | The sample sizes for each model. | required |
| bool | Whether to create a deep copy of the models. Defaults to True. | True |
Returns:
| Type | Description |
|---|---|
Module | torch.nn.Module: The aggregated model. |
Raises:
| Type | Description |
|---|---|
AggregationException | If the models do not have the same architecture. |
Source code in fl_server_ai/aggregation/mean.py
Functions¶
get_aggregation_class ¶
get_aggregation_class(value: Model) -> Type[Aggregation]
get_aggregation_class(value: Training) -> Type[Aggregation]
get_aggregation_class(value: AggregationMethod) -> Type[Aggregation]
get_aggregation_class(value: AggregationMethod | Model | Training) -> Type[Aggregation]
Get the aggregation class based on the provided model, training or aggregation method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| AggregationMethod | Model | Training | The value based on which the aggregation class is determined. | required |
Returns:
| Type | Description |
|---|---|
Type[Aggregation] | Type[Aggregation]: The type of the aggregation class. |
Raises:
| Type | Description |
|---|---|
ValueError | If the type of value or the aggregation method is unknown. |