Efficient Image Representation Learning with Federated Sampled Softmax

Sagar M. Waghmare, Hang Qi, Huizhong Chen, Mikhail Sirotenko, Tomer MeronICLR 2022

Abstract: Learning image representations on decentralized data can bring many benefits in cases where data cannot be aggregated across data silos. Softmax cross entropy loss is highly effective and commonly used for learning image representations. Using a large number of classes has proven to be particularly beneficial for the descriptive power of such representations in centralized learning. However, doing so on decentralized data with Federated Learning is not straightforward as the demand on FL clients' computation and communication increases proportionally to the number of classes. In this work we introduce federated sampled softmax (FedSS), a resource-efficient approach for learning image representation with Federated Learning. Specifically, the FL clients sample a set of classes and optimize only the corresponding model parameters with respect to a sampled softmax objective that approximates the global full softmax objective. We examine the loss formulation and empirically show that our method significantly reduces the number of parameters transferred to and optimized by the client devices, while performing on par with the standard full softmax method. This work creates a possibility for efficiently learning image representations on decentralized data with a large number of classes under the federated setting.

Introduction

In centralized machine learning, training image representations on massive label spaces—such as the 21,000 classes of ImageNet-21k—is a proven strategy for creating robust, universal features. However, in Federated Learning (FL), where models are trained across thousands of edge devices without sharing raw data, this strategy faces significant scalability hurdles. As the number of classes grows, the communication and computation costs for individual clients become prohibitive. This paper introduces Federated Sampled Softmax (FedSS) to enable large-scale representation learning in these decentralized environments.

The Classification Layer Bottleneck

The primary bottleneck in large-scale FL is the classification layer. In a standard Convolutional Neural Network (ConvNet), the final layer is a weight matrix that grows linearly with the number of classes. When training for 100,000 classes, this matrix can dwarf the rest of the model combined. For a smartphone client, downloading this entire matrix and calculating gradients for every class is bandwidth-heavy, compute-intensive, and often redundant, as a single user typically only possesses data for a tiny fraction of the total classes.

Proposed Method: FedSS

FedSS addresses these bottlenecks by allowing clients to download and optimize only a small fraction of the classification layer. The process involves four key steps:

  1. Sub-network Request: A client identifies its local "positive" classes ($P_k$) and samples a set of "negative" classes ($N_k$). It then requests only the parameters for this subset ($S_k = P_k \cup N_k$) from the server.
  2. Obfuscation for Privacy: To protect user privacy, clients can send a combined set of labels, preventing the server from knowing exactly which classes a user has locally.
  3. The FedSS Loss: Unlike standard sampled softmax, FedSS includes all local positive classes in the denominator of the softmax. This forces the model to distinguish between different local classes, not just between local and global classes.
  4. Aggregation: The server receives updates for the requested sub-matrix and aggregates them into the global model using standard methods like FedAvg.
Overview of the FedSS framework, illustrating the sub-network request and local optimization process.

The Role of Local Positives

A critical insight of this work is the "pushing force" of local positives. The researchers found that including all local positive classes in the loss function is mandatory to prevent representation collapse. Without this inclusion (a method termed NegOnly), the model tends to group all of a user's images into a single feature cluster rather than learning distinct features for different classes. By including the full set $P_k$, FedSS ensures the model maintains high descriptive power.

Comparison of different sampling strategies. FedSS (d) includes both local positives and sampled negatives in the loss denominator to prevent feature collapse.

Experimental Evaluation

The researchers evaluated FedSS on three benchmarks: Landmarks-User-160k, Stanford Online Products (SOP), and ImageNet-21k.

  • Performance Parity: On Landmarks-User-160k, FedSS achieved 56.0% accuracy compared to 56.8% for the full softmax, despite using less than 10% of the classification layer parameters.
  • Efficiency Gains: FedSS reduced communication costs per client by up to 79% for the SOP dataset and 38% for Landmarks when using larger embedding sizes.
  • Scalability: On ImageNet-21k, FedSS performed comparably to full softmax baselines while requiring clients to handle only ~2% of the total classes.

Interestingly, on the SOP dataset, FedSS occasionally outperformed full softmax. This suggests that updating only a subset of weights can act as a form of regularization, preventing overfitting on the limited data available to individual clients.

Conclusion

FedSS provides a resource-efficient path for scaling Federated Learning to thousands of classes. While sampled softmax introduces some gradient bias, the empirical results demonstrate that the trade-off is highly favorable for decentralized representation learning. Future work may involve integrating formal Differential Privacy and exploring efficiency gains for the feature extractor layers of the network.

Summary updated

BibTeX
@inproceedings{waghmare2022efficient,
  author = {Sagar M. Waghmare and Hang Qi and Huizhong Chen and Mikhail Sirotenko and Tomer Meron},
  title = {{Efficient Image Representation Learning with Federated Sampled Softmax}},
  booktitle = {International Conference on Learning Representations},
  year = {2022},
  url = {https://openreview.net/forum?id=gcjYTSzn99-},
}
Figure