FedLcAggregationStrategy<T>
Models & Types · AiDotNet.FederatedLearning.Aggregators
Implements FedLC (Logit Calibration) aggregation strategy.
Inheritance: FederatedLearningComponentBase<T> → AggregationStrategyBase<Dictionary<string, T[]>, T> → ParameterDictionaryAggregationStrategyBase<T> → FedLcAggregationStrategy<T>
For Beginners
When different clients have different class distributions (e.g., Hospital A sees mostly flu, Hospital B sees mostly cold), local models develop biased predictions. FedLC fixes this by adjusting each client’s logits based on its local class counts during local training.
How It Works
During local training, logits are calibrated:
where n_local[c] is the number of local samples of class c. This counteracts the bias introduced by the imbalanced local data distribution.
Reference: Zhang, J., et al. (2022). “Federated Learning with Label Distribution Skew via Logits Calibration.” ICML 2022.
Constructors
| Constructor | Summary |
|---|---|
FedLcAggregationStrategy(double calibrationTemperature) |
Initializes a new instance of the FedLcAggregationStrategy class. |
Properties
| Property | Summary |
|---|---|
double CalibrationTemperature { get; } |
Gets the logit calibration temperature (tau). |
int RegisteredClientCount { get; } |
Gets the number of clients with registered class counts. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T[]> Aggregate(Dictionary<int, Dictionary<string, T[]>> clientModels, Dictionary<int, double> clientWeights) |
|
Matrix<T> CalibrateBatch(Matrix<T> logitsBatch, int clientId) |
Calibrates a batch of logits for a client. |
Vector<T> CalibrateLogits(Vector<T> logits, int clientId) |
Calibrates raw logits using the client’s local class counts. |
Vector<T> ComputeClassCounts(int[] labels, int numClasses) |
Counts the local samples of each class (convenience helper). |
bool UnregisterClassCounts(int clientId) |
Removes a client’s registered class counts. |
string GetStrategyName() |
|
void ClearAllClassCounts() |
Removes all registered class counts. |
void RegisterClassCounts(int clientId, Vector<T> classCounts) |
Registers a client’s local per-class sample counts for use in logit calibration. |