FedAlignAggregationStrategy<T>
Models & Types · AiDotNet.FederatedLearning.Aggregators
Implements FedAlign (Feature Alignment) aggregation strategy.
Inheritance: FederatedLearningComponentBase<T> → AggregationStrategyBase<Dictionary<string, T[]>, T> → ParameterDictionaryAggregationStrategyBase<T> → FedAlignAggregationStrategy<T>
For Beginners
Different clients with different data can learn different “languages” for representing the same concepts. FedAlign adds a regularizer during local training that forces each client’s feature space to align with shared anchor representations, so all clients speak the same “language” when their models are combined.
How It Works
Local training objective:
where anchors are shared reference inputs and D measures representation distance using either L2 distance or CKA (Centered Kernel Alignment).
Protocol:
Reference: Mendieta, M., et al. (2022). “Local Learning Matters: Rethinking Data Heterogeneity in Federated Learning.” CVPR 2022.
Constructors
| Constructor | Summary |
|---|---|
FedAlignAggregationStrategy(double alignmentWeight, AlignmentDistanceMetric distanceMetric) |
Initializes a new instance of the FedAlignAggregationStrategy class. |
Properties
| Property | Summary |
|---|---|
AlignmentDistanceMetric DistanceMetric { get; } |
Gets the distance metric used for alignment. |
Matrix<T> Anchors { get; } |
Gets the registered anchor inputs, or null if none have been set. |
double AlignmentWeight { get; } |
Gets the feature alignment weight (alpha). |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T[]> Aggregate(Dictionary<int, Dictionary<string, T[]>> clientModels, Dictionary<int, double> clientWeights) |
Aggregates client models using standard weighted averaging. |
T ComputeAlignmentLoss(Matrix<T> localFeatures, Matrix<T> globalFeatures) |
Computes the feature alignment loss between local and global model representations on anchors. |
T ComputeTotalLoss(T taskLoss, Matrix<T> localFeatures, Matrix<T> globalFeatures) |
Computes the complete local training loss including task loss and alignment loss. |
string GetStrategyName() |
|
void SetAnchors(Matrix<T> anchors) |
Registers anchor inputs that all clients use for alignment. |