Abstract
Federated learning is widely used to perform decentralized training of a global model on multiple devices while preserving the data privacy of each device. However, it suffers from heterogeneous local data on each training device which increases the difficulty to reach the same level of accuracy as the centralized training. Supervised Contrastive Learning which outperform cross-entropy tries to minimizes the difference between feature space of points belongs to the same class and pushes away points from different classes. We propose Supervised Contrastive Federated Learning in which devices can share the learned class-wise feature spaces with each other and add the supervised-contrastive learning loss as a regularization term to foster the feature space learning. The loss tries to minimize the cosine similarity distance between the feature map and the averaged feature map from another device in the same class and maximizes the distance between the feature map and that in a different class. This new regularization term when added on top of the moon regularization term is found to outperform the other state-of-the-art regularization terms in solving the heterogeneous data distribution problem.
Introduction
Federated Learning (FL) has emerged as a critical paradigm for training machine learning models across decentralized devices while maintaining data privacy. By keeping data local and only sharing model updates, FL mitigates many privacy risks. However, the performance of FL is often hampered by data heterogeneity, or "non-IID" (non-Independent and Identically Distributed) data. In real-world scenarios, the distribution of classes across devices is often highly skewed, leading to "client drift" where local models diverge, slowing convergence and reducing the accuracy of the aggregated global model.
Methodology: Shared Supervised-Contrastive Learning
To address the challenges of non-IID data, we propose FedSSC (Shared Supervised-Contrastive Federated Learning). FedSSC enhances the local training process by incorporating shared class-wise feature embeddings, or "prototypes," from other devices.
The FedSSC Loss Function
The training objective for each device is defined by a three-part loss function:
- Classification Loss ($l_{class}$): Standard cross-entropy loss to ensure accurate label prediction.
- MOON Regularization ($l_{moon}$): Based on Model-Contrastive Federated Learning, this term ensures the local model's feature representations remain consistent with the global model's representations for the same input.
- Global Class-wise Contrastive Loss ($l_{glob}$): This novel term fosters feature space learning by comparing local features to shared global prototypes.
Prototype Sharing Mechanism
Instead of sharing raw data, devices compute the average feature map for each class they possess. These anonymized "fingerprints" are sent to the server. To preserve privacy and ensure quality, the server only aggregates averages from devices with a sufficient sample size (e.g., $\ge 10$ samples). In each communication round, the server randomly selects one device's average for a given class to serve as the "global prototype," which is then broadcast back to all participating devices.
Experimental Evaluation
We evaluated FedSSC using the CIFAR-10 dataset. To simulate a realistic non-IID environment, we employed a Dirichlet distribution with a concentration parameter $\beta$. A lower $\beta$ indicates higher data heterogeneity.
Accuracy and Convergence
FedSSC demonstrates significant improvements over baseline methods like FedAvg and MOON. As shown in the comparison below, FedSSC achieves higher final accuracy and faster convergence than the state-of-the-art MOON method.
- Higher Accuracy: FedSSC achieved a top-1 accuracy of 69.3%, surpassing MOON (68.6%) and FedAvg (65.8%).
- Accelerated Convergence: FedSSC reached a target accuracy of 68% in just 41 communication rounds, whereas MOON required 61 rounds. FedAvg was unable to reach this threshold within 100 rounds.
Robustness to Heterogeneity
The advantages of FedSSC are most evident in highly non-IID settings. Performance remains stable even as the data distribution becomes more skewed (lower $\beta$ values).
Conclusion
FedSSC effectively addresses the non-IID problem in Federated Learning by leveraging shared class-wise feature spaces. By combining local model-contrastive learning with global class-wise contrastive learning, the framework achieves faster convergence and higher accuracy than existing state-of-the-art methods. Future work will focus on evaluating FedSSC on more complex architectures and diverse datasets, as well as investigating its resilience to communication failures in edge computing environments.
Summary updated