Table of Contents

Class RfaFullModelAggregationStrategy<T, TInput, TOutput>

Namespace
AiDotNet.FederatedLearning.Aggregators
Assembly
AiDotNet.dll

Robust Federated Aggregation (RFA) via geometric median (Weiszfeld iterations).

public sealed class RfaFullModelAggregationStrategy<T, TInput, TOutput> : RobustFullModelAggregationStrategyBase<T, TInput, TOutput>, IAggregationStrategy<IFullModel<T, TInput, TOutput>>

Type Parameters

T
TInput
TOutput
Inheritance
AggregationStrategyBase<IFullModel<T, TInput, TOutput>, T>
RfaFullModelAggregationStrategy<T, TInput, TOutput>
Implements
IAggregationStrategy<IFullModel<T, TInput, TOutput>>
Inherited Members

Remarks

For Beginners: Instead of averaging client updates, the geometric median finds a point that minimizes the sum of distances to all client updates. This is more robust when some clients are outliers or adversarial.

Constructors

RfaFullModelAggregationStrategy(int, double, double, bool)

public RfaFullModelAggregationStrategy(int maxIterations = 10, double tolerance = 1E-06, double epsilon = 1E-12, bool useClientWeights = false)

Parameters

maxIterations int
tolerance double
epsilon double
useClientWeights bool

Methods

Aggregate(Dictionary<int, IFullModel<T, TInput, TOutput>>, Dictionary<int, double>)

Aggregates model updates from multiple clients into a single global model update.

public override IFullModel<T, TInput, TOutput> Aggregate(Dictionary<int, IFullModel<T, TInput, TOutput>> clientModels, Dictionary<int, double> clientWeights)

Parameters

clientModels Dictionary<int, IFullModel<T, TInput, TOutput>>

Dictionary mapping client IDs to their trained models.

clientWeights Dictionary<int, double>

Dictionary mapping client IDs to their aggregation weights (typically based on data size).

Returns

IFullModel<T, TInput, TOutput>

The aggregated global model.

Remarks

This method combines model updates from clients using the strategy's specific algorithm.

For Beginners: Aggregation is like combining multiple rough drafts of a document into one polished version that incorporates the best parts of each.

The aggregation process typically:

  1. Takes model updates (weight changes) from each client
  2. Considers the weight or importance of each client (based on data size, accuracy, etc.)
  3. Combines these updates using the strategy's algorithm
  4. Returns a single aggregated model that represents the collective improvement

For example with weighted averaging (FedAvg):

  • Client 1 (1000 samples): model update A
  • Client 2 (500 samples): model update B
  • Client 3 (1500 samples): model update C
  • Aggregated update = (1000A + 500B + 1500*C) / 3000

FromOptions(RobustAggregationOptions)

public static RfaFullModelAggregationStrategy<T, TInput, TOutput> FromOptions(RobustAggregationOptions options)

Parameters

options RobustAggregationOptions

Returns

RfaFullModelAggregationStrategy<T, TInput, TOutput>

GetStrategyName()

Gets the name of the aggregation strategy.

public override string GetStrategyName()

Returns

string

A string describing the aggregation strategy (e.g., "FedAvg", "FedProx", "Krum").

Remarks

For Beginners: This helps identify which aggregation method is being used, useful for logging, debugging, and comparing different strategies.