FedCPPersonalization<T>
Models & Types · AiDotNet.FederatedLearning.Personalization
Implements FedCP (Conditional Policy) personalization with input-dependent routing.
Inheritance: FederatedLearningComponentBase<T> → FedCPPersonalization<T>
For Beginners
Different clients have different types of data. Rather than forcing all data through the same model path, FedCP learns a “routing policy” per client that decides which parts of the model to use for each input. The policy network is lightweight and personalized (kept local), while the main model modules are shared globally. This way, each client can effectively use a different “subset” of the global model tailored to their data.
How It Works
Architecture:
Reference: Zhang, J., et al. (2023). “Federated Learning with Conditional Computation.” KDD 2023.
Constructors
| Constructor | Summary |
|---|---|
FedCPPersonalization(int numExperts, double policyFraction) |
Creates a new FedCP personalization strategy. |
Properties
| Property | Summary |
|---|---|
double PolicyFraction { get; } |
Gets the policy network fraction. |
int NumExperts { get; } |
Gets the number of expert modules. |
Methods
| Method | Summary |
|---|---|
Dictionary<string, T[]> ExtractPolicyParameters(Dictionary<string, T[]> fullParameters) |
Extracts local policy network parameters (not aggregated). |
Dictionary<string, T[]> ExtractSharedParameters(Dictionary<string, T[]> fullParameters) |
Extracts shared expert module parameters for aggregation. |
T[] CombineExpertOutputs(T[][] expertOutputs, T[] routingWeights) |
Combines expert outputs using routing weights: output = sum(w_k * expert_k(input)). |
T[] ComputeRoutingWeights(T[] policyLogits) |
Computes routing weights from the policy network output using softmax. |
double ComputeLoadBalancingLoss(double[][] routingWeightsBatch) |
Computes the load-balancing loss to prevent expert collapse (all traffic to one expert). |