F EDERATED LEARNING WITH MATCHED AVERAGING
mikhail yurochkin
Research yasaman.khazaeni@us.ibm.com
A BSTRACT
Federated learning allows edge devices to collaboratively learn a shared model while keeping the training data on device, decoupling the ability to do model training from the need to store the data in the cloud.
We propose the Federated matched averaging (FedMA) algorithm designed for federated learning of modern neural network architectures e g. convolutional neural networks (CNNs) and LSTMs.
FedMA constructs the shared global model in a layer-wise manner by matching and averaging hidden elements ( i e. channels for convolution layers; hidden states for LSTM; neurons for fully connected layers) with similar feature extraction signatures.
Our experiments indicate that FedMA not only outperforms popular state- of-the-art federated learning algorithms on deep CNN and LSTM architectures trained on real world datasets, but also reduces the overall communication burden 1 .
I NTRODUCTION
Edge devices such as mobile phones, sensors in a sensor network, or vehicles have access to a wealth of data.
However, due to data privacy concerns, network bandwidth limitation, and device availability, it’s impractical to gather all the data from the edge devices at the data center and conduct centralized training.
To address these concerns, federated learning is emerging (McMahan et al., 2017; Li et al., 2019; Smith et al., 2017; Caldas et al., 2018; Bonawitz et al., 2019; Kairouz et al., 2019) as a paradigm that allows local clients to collaboratively train a shared global model.
The typical federated learning paradigm involves two stages: (i) clients train models with their local datasets independently, and (ii) the data center gathers the locally trained models and aggregates them to obtain a shared global model.
One of the standard aggregation methods is FedAvg (McMahan et al., 2017) where parameters of local models are averaged element-wise with weights proportional to sizes of client datasets.
FedProx (Sahu et al., 2018) adds a proximal term for client local cost functions, which limits the impact of local updates by restricting them to be close to the global model.
Agnostic Federated Learning (AFL) (Mohri et al., 2019), as another variant of
FedAvg, optimizes a centralized distribution that is formed by a mixture of the client distributions.
One shortcoming of the FedAvg algorithm is that coordinate-wise averaging of weights may have drastic detrimental effect on the performance and hence hinders the communication efﬁciency.
This issue arises due to the permutation invariant nature of the neural network (NN) parameters, i.e. for [Figure] [Figure] cc
[Figure]
[Figure]
[Figure] [Figure] any given NN there are many variations of it that only differ in the ordering of parameters and constitute local optima which are practically equivalent. Probabilistic Federated Neural Matching (PFNM) (Yurochkin et al., 2019b) addresses this problem by ﬁnding permutation of the parameters of the NNs before averaging them.
PFNM further utilizes Bayesian nonparametric machinery to adapt global model size to heterogeneity of the data.
As a result, PFNM has better performance and communication efﬁciency, however it was only developed for fully connected NNs and tested on simple architectures.
Our contribution In this work (i) we demonstrate how PFNM can be applied to CNNs and
LSTMs, however we ﬁnd that it gives very minor improvement over weight averaging when applied to modern deep neural network architectures; (ii) we propose Federated Matched Averaging (FedMA), a new layers-wise federated learning algorithm for modern CNNs and LSTMs utilizing matching and model size adaptation underpinnings of PFNM; (iii) We empirically study FedMA with real datasets under the federated learning constraints.
F EDERATED M ATCHED A VERAGING OF NEURAL NETWORKS
In this section we will discuss permutation invariance classes of prominent neural network architectures and establish the appropriate notion of averaging in the parameter space of NNs.
We will begin with the simplest case of a single hidden layer fully connected network, moving on to deep architectures and, ﬁnally, convolutional and recurrent architectures.
Permutation invariance of fully connected architectures A basic fully connected (FC) NN can be formulated as ˆ y = σ ( xW 1 ) W 2 (without loss of generality, biases are omitted to simplify notation), where σ is the non-linearity (applied entry-wise).
Expanding the preceding expression ˆ y = (cid:80) L i =1 W 2 ,i · σ ( (cid:104) x, W 1 , · i (cid:105) ) , where i · and · i denote i th row and column correspondingly and
L is the number of hidden units.
Summation is a permutation invariant operation, hence for any { W 1 , W 2 } there are L !
practically equivalent parametrizations if this basic NN.
It is then more appropriate to write
[Equation]
Recall that permutation matrix is an orthogonal matrix that acts on rows when applied on the left and on columns when applied on the right.
Suppose { W 1 , W 2 } are optimal weights, then weights obtained from training on two homogeneous datasets X j , X j (cid:48) are { W 1 Π j , Π Tj W 2 } and { W 1 Π j (cid:48) , Π Tj (cid:48) W 2 } .
It is now easy to see why naive averaging in the parameter space is not appropriate: with high probability Π j (cid:54) =
Π j (cid:48) and ( W 1 Π j + W 1 Π j (cid:48) ) / 2 (cid:54) =
W 1 Π for any Π .
To meaningfully average neural networks in the weight space we should ﬁrst undo the permutation ( W 1 Π j Π T j + W 1 Π j (cid:48)
Π T j (cid:48) ) /
2 = W 1 .
2. M ATCHED AVERAGING FORMULATION
In this section we formulate practical notion of parameter averaging under the permutation invariance.
Let w jl be l th neuron learned on dataset j (i.e. l th column of W (1)
Π j in the previous example), θ i denote the i th neuron in the global model, and c ( · , · ) be an appropriate similarity function between a pair of neurons.
Solution to the following optimization problem are the required permutations:
[Equation]
Then Π Tjli = π jli and given weights { W j, 1 , W j, 2 } Jj =1 provided by J clients, we compute the federated neural network weights W 1 = 1 J (cid:80) j W j, 1 Π Tj and W 2 = 1 J (cid:80) j Π j W j, 2 .
We refer to this approach as matched averaging due to relation of equation 2 to the maximum bipartite matching problem.
We note that if c ( · , · ) is squared Euclidean distance, we recover objective function similar to k-means clustering, however it has additional constraints on the “cluster assignments” π jli necessary to ensure that they form permutation matrices.
In a special case where all local neural networks and the global model are assumed to have same number of hidden neurons, solving equation 2 is equivalent to ﬁnding a Wasserstein barycenter (Agueh & Carlier, 2011) of the empirical distributions over the weights of local neural networks.
Concurrent work of Singh & Jaggi (2019) explores the
Wasserstein barycenter variant of equation 2. Solving matched averaging Objective function in equation 2 can be optimized using an iterative procedure: applying the Hungarian matching algorithm (Kuhn, 1955) to ﬁnd permutation { π j (cid:48) li } l,i corresponding to dataset j (cid:48) , holding other permutations { π jli } l,i,j (cid:54) =
j (cid:48) ﬁxed and iterating over the datasets.
Important aspect of Federated Learning that we should consider here is the data heterogeneity.
Every client will learn a collection of feature extractors, i.e. neural network weights, representing their individual data modality.
As a consequence, feature extractors learned across clients may overlap only partially .
To account for this we allow the size of the global model L to be an unknown variable satisfying max j L j ≤ L ≤ (cid:80) j L j where L j is the number of neurons learned from dataset j .
That is, global model is at least as big as the largest of the local models and at most as big as the concatenation of all the local models.
Next we show that matched averaging with adaptive global model size remains amendable to iterative Hungarian algorithm with a special cost.
At each iteration, given current estimates of { π jli } l,i,j (cid:54) =
j (cid:48) , we ﬁnd a corresponding global model { θ i =
arg min θ i (cid:80) j (cid:54) =
j (cid:48) ,l π jli c ( w jl , θ i ) } Li =
(this is typically a closed-form expression or a simple optimization sub-problem, e.g. a mean if c ( · , · ) is Euclidean) and then we will use Hungarian algorithm to match this global model to neurons { w j (cid:48) l } L j (cid:48)
l =1 of the dataset j (cid:48) to obtain a new global model with L ≤ L (cid:48)
≤ L + L j (cid:48) neurons.
Due to data heterogeneity, local model j (cid:48) may have neurons not present in the global model built from other local models, therefore we want to avoid “poor” matches by saying that if the optimal match has cost larger than some threshold value (cid:15) , instead of matching we create a new global neuron from the corresponding local one.
We also want a modest size global model and therefore penalize its size with some increasing function f
( L (cid:48) ) .
This intuition is formalized in the following extended maximum bipartite matching formulation:
[Equation]
i [Equation] [Equation] l π jli ∈ { 0 , 1 } ∀ i , where
[Equation]
The size of the new global model is then L (cid:48)
=
max { i : π j (cid:48) li
= 1 , l = 1 , . .
, L j (cid:48) } .
We note some technical details: after the optimization is done, each corresponding Π Tj is of size L j × L and is not a permutation matrix in a classical sense when L j (cid:54) =
L .
Its functionality is however similar: taking matrix product with a weight matrix W (1) j Π Tj implies permuting the weights to align with weights learned on the other datasets and padding with “dummy” neurons having zero weights (alternatively we can pad weights W (1) j ﬁrst and complete Π Tj with missing rows to recover a proper permutation matrix).
This “dummy” neurons should also be discounted when taking average.
Without loss of generality, in the subsequent presentation we will ignore these technicalities to simplify the notation.
To complete the matched averaging optimization procedure it remains to specify similarity c ( · , · ) , threshold (cid:15) and model size penalty f ( · ) .
Yurochkin et al. (2019a;b;c) studied fusion, i.e. aggregation, of model parameters in a range of applications. The most relevant to our setting is Probabilistic Federated Neural Matching (PFNM) (Yurochkin et al., 2019b).
They arrived at a special case of equation 3 to compute maximum a posteriori estimate (MAP) of their Bayesian nonparametric model based on the Beta-Bernoulli process (BBP) (Thibaux & Jordan, 2007), where similarity c ( w jl , θ i ) is the corresponding posterior probability of j th client neuron l generated from a Gaussian with mean θ i , and (cid:15) and f ( · ) are guided by the Indian Buffet Process prior (Ghahramani & Grifﬁths, 2005). Instead of making heuristic choices, this formulation provides a model-based speciﬁcation of equation 3.
We refer to a procedure for solving equation 2 with the setup from Yurochkin et al. (2019b)
as BBP-MAP.
We note that their PFNM is only applicable to fully connected architectures limiting its practicality.
Our matched averaging perspective allows to formulate averaging of widely used architectures such as CNNs and LSTMs as instances of equation 2 and utilize the BBP-MAP as a solver.
2. P ERMUTATION INVARIANCE OF KEY ARCHITECTURES
Before moving onto the convolutional and recurrent architectures, we discuss permutation invariance in deep fully connected networks and corresponding matched averaging approach.
We will utilize this as a building block for handling LSTMs and CNN architectures such as VGG (Simonyan &
Zisserman, 2014) widely used in practice.
Permutation invariance of deep FCs We extend equation 1 to recursively deﬁne deep FC network:
[Equation]
where n = 1 , . . , N is the layer index, Π 0 is identity indicating non-ambiguity in the ordering of input features x = x 0 and Π N is identity for the same in output classes.
Conventionally σ ( · ) is any non-linearity except for ˆ y =
x N where it is the identity function (or softmax if we want probabilities instead of logits).
When N = 2 , we recover a single hidden layer variant from equation 1.
To perform matched averaging of deep FCs obtained from J clients we need to ﬁnd permutations for every layer of every client.
Unfortunately, permutations within any consecutive pair of intermediate layers are coupled leading to a NP-hard combinatorial optimization problem.
Instead we consider recursive (in layers) matched averaging formulation.
Suppose we have { Π j,n − 1 } , then plugging { Π Tj,n − 1 W j,n } into equation
we ﬁnd { Π j,n } and move onto next layer.
The recursion base for this procedure is { Π j, 0 } , which we know is an identity permutation for any j .
Permutation invariance of CNNs The key observation in understanding permutation invariance of CNNs is that instead of neurons, channels deﬁne the invariance.
To be more concrete, let
Conv ( x, W ) deﬁne convolutional operation on input x with weights W ∈ R C in × w × h × C out , where
C in , C out are the numbers of input/output channels and w, h are the width and height of the ﬁlters.
Applying any permutation to the output dimension of the weights and then same permutation to the input channel dimension of the subsequent layer will not change the corresponding CNN’s forward pass.
Analogous to equation 4 we can write:
[Equation]
Note that this formulation permits pooling operations as those act within channels.
To apply matched averaging for the n th CNN layer we form inputs to equation 2 as { w jl ∈ R D } C outn l =1 , j = 1 , . .
, J , where D is the ﬂattened C inn × w × h dimension of Π Tj,n − 1 W j,n .
This result can be alternatively derived taking the IM 2 COL perspective.
Similar to FCs, we can recursively perform matched averaging on deep CNNs.
The immediate consequence of our result is the extension of PFNM (Yurochkin et al., 2019b) to CNNs.
Empirically, see Figure 1, we found that this extension performs well on
MNIST with a simpler CNN architecture such as LeNet (LeCun et al., 1998) (4 layers) and significantly outperforms coordinate-wise weight averaging (1 round FedAvg).
However, it breaks down for more complex architecture, e.g. VGG-9 (Simonyan & Zisserman, 2014) (9 layers), needed to obtain good quality prediction on a more challenging CIFAR-10.
Permutation invariance of LSTMs Permutation invariance in the recurrent architectures is associated with the ordering of the hidden states.
At a ﬁrst glance it appears similar to fully connected architecture, however the important difference is associated with the permutation invariance of the hidden-to-hidden weights
H ∈ R L × L , where L is the number of hidden states.
In particular, permutation of the hidden states affects both rows and columns of H .
Consider a basic RNN h t = σ ( h t − 1 H + x t W ) , where W are the input-to-hidden weights.
To account for the permutation invariance of the hidden states, we notice that dimensions of h t should be permuted in the same way for any t , hence
[Equation]
To match RNNs, the basic sub-problem is to align hidden-to-hidden weights of two clients with
Euclidean similarity, which requires minimizing (cid:107) Π T H j Π − H j (cid:48) (cid:107) 22 over permutations Π .
This is a quadratic assignment problem known to be NP-hard (Loiola et al., 2007).
Fortunately, the same permutation appears in an already familiar context of input-to-hidden matching of W Π .
Our matched averaging RNN solution is to utilize equation 2 plugging-in input-to-hidden weights { W j } to ﬁnd { Π j } .
Then federated hidden-to-hidden weights are computed as H = 1 J (cid:80)
j Π j H h Π Tj and input-to-hidden weights are computed as before.
We note that Gromov-Wasserstein distance (Gromov, 2007) from the optimal transport literature corresponds to a similar quadratic assignment problem.
It may be possible to incorporate hidden-to-hidden weights H into the matching algorithm by exploring connections to approximate algorithms for computing Gromov-Wasserstein barycenter (Peyr ´ e et al., 2016).
We leave this possibility for future work.
To ﬁnalize matched averaging of LSTMs, we discuss several speciﬁcs of the architecture.
LSTMs have multiple cell states, each having its individual hidden-to-hidden and input-to-hidden weights.
In out matched averaging we stack input-to-hidden weights into SD ×
L weight matrix ( S is the number of cell states; D is input dimension and L is the number of hidden states) when computing the permutation matrices and then average all weights as described previously.
LSTMs also often have an embedding layer, which we handle like a fully connected layer.
Finally, we process deep LSTMs in the recursive manner similar to deep FCs.
2. F EDERATED M ATCHED A VERAGING (F ED MA) ALGORITHM
Deﬁning the permutation invariance classes of CNNs and LSTMs allows us to extend PFNM (Yurochkin et al., 2019b) to these architectures, however our empirical study in Figure 1 demonstrates that such extension fails on deep architectures necessary to solve more complex tasks.
Our results suggest that recursive handling of layers with matched averaging may entail poor overall solution.
To alleviate this problem and utilize the strength of matched averaging on “shallow” architectures, we propose the following layer-wise matching scheme.
First, data center gathers only the weights of the ﬁrst layers from the clients and performs one-layer matching described previously to obtain the ﬁrst layer weights of the federated model.
Data center then broadcasts these weights to the clients, which proceed to train all consecutive layers on their datasets, keeping the matched federated layers frozen .
This procedure is then repeated up to the last layer for which we conduct a weighted averaging based on the class proportions of data points per client.
We summarize our Federated Matched Averaging (FedMA) in Algorithm 1.
The FedMA approach requires communication rounds equal to the number of layers in a network.
In Figure 1 we show that with layer-wise matching FedMA performs well on the deeper VGG-9 CNN as well as LSTMs.
In the more challenging heterogeneous setting, FedMA outperforms FedAvg, FedProx trained with same number of communication rounds (4 for LeNet and LSTM and 9 for VGG-9) and other baselines, i.e. client individual CNNs and their ensemble. FedMA with communication We’ve shown that in the heterogeneous data scenario FedMA outperforms other federated learning approaches, however it still lags in performance behind the entire data training. Of course the entire data training is not possible under the federated learning constraints, but it serves as performance upper bound we should strive to achieve. To further improve the performance of our method, we propose FedMA with communication , where local clients receive the matched global model at the beginning of a new round and reconstruct their local models with the size equal to the original local models ( e.g. size of a VGG-9) based on the matching results of the previous round.
This procedure allows to keep the size of the global model small in contrast to a naive strategy of utilizing full matched global model as a starting point across clients on every round.
while n ≤ N do if n < N then { Π j } Jj =1 = BBP-MAP (cid:0) { W j,n } Jj =1 (cid:1) ; // call BBP-MAP to solve Eq.
W n = 1 J (cid:80) j W j,n Π Tj ; else
W n = (cid:80)
Kk =1 (cid:80) j p jk W jl,n where p k is fraction of data points with label k on worker j ; endfor j ∈ { 1 , . .
, J } do
W j,n +1 ← Π j W j,n +1 ; // permutate the next-layer weights
Train
; end n = n + 1 ; end
E XPERIMENTS
We present an empirical study of FedMA with communication and compare it with state-of-the-art methods i.e. FedAvg (McMahan et al., 2017) and FedProx (Sahu et al., 2018); analyze the performance under the growing number of clients and visualize the matching behavior of FedMA to study its interpretability.
Our experimental studies are conducted over three real world datasets.
Summary information about the datasets and associated models can be found in supplement Table 3.
Experimental Setup We implemented FedMA and the considered baseline methods in PyTorch (Paszke et al., 2017).
We deploy our empirical study under a simulated federated learning environment where we treat one centralized node in the distributed cluster as the data center and the other nodes as local clients.
All nodes in our experiments are deployed on p3.2xlarge instances on Amazon EC2.
We assume the data center samples all the clients to join the training process for every communication round for simplicity.
For the CIFAR-10 dataset, we use data augmentation (random crops, and ﬂips) and normalize each individual image (details provided in the Supplement).
We note that we ignore all batch normalization (Ioffe & Szegedy, 2015) layers in the VGG architecture and leave it for future work.
For CIFAR-10, we considered two data partition strategies to simulate federated learning scenario: (i) homogeneous partition where each local client has approximately equal proportion of each of the classes; (ii) heterogeneous partition for which number of data points and class proportions are unbalanced.
We simulated a heterogeneous partition into J clients by sampling p k ∼ Dir J (0 . 5) and allocating a p k,j proportion of the training instances of class k to local client j .
We use the original test set in CIFAR-10 as our global test set for comparing performance of all methods.
For the Shakespeare dataset, we treat each speaking role as a client (Caldas et al., 2018) resulting in a natural heterogeneous partition.
We preprocess the Shakespeare dataset by ﬁltering out the clients with less than 10 k datapoints and sampling a random subset of J = 66 clients.
We allocate 80% of the data for training [-set. We then randomly sample J = 
 out of 132 clients in conducting our experiments. We-]and amalgamate the remaining data into a global test set.
Communication Efﬁciency and Convergence Rate
In this experiment we study performance of
FedMA with communication.
Our goal is to compare our method to FedAvg and FedProx in terms of the total message size exchanged between data center and clients (in Gigabytes) and the number of communication rounds (recall that completing one FedMA pass requires number of rounds equal to the number of layers in the local models) needed for the global model to achieve good performance on the test data.
We also compare to the performance of an ensemble method.
We evaluate all methods under the heterogeneous federated learning scenario on CIFAR-10 with J = 16 clients with VGG-9 local models and on Shakespeare dataset with J = 66 clients with 1-layer LSTM net- [Figure]
work. We ﬁx the total rounds of communication allowed for FedMA, FedAvg, and FedProx i [Figure] e.rounds for FedMA and 99/33 rounds for FedAvg and FedProx for the VGG-9/LSTM experiments respectively.
We notice that number of local training epochs is a common parameter shared by the three considered methods, we thus tune this parameter (denoted E ; comprehensive analysis will be presented in the next experiment) and report the convergence rate under E that yields the best ﬁnal model accuracy over the global test set.
We also notice that there is another hyper-parameter in FedProx i.e. the coefﬁcient µ associated with the proxy term, we also tune the parameter using grid search and report the best µ we found (0.001) for both VGG-9 and LSTM experiments.
FedMA outperforms FedAvg and FedProx in all scenarios (Figure 2) with its advantage especially pronounced when we evaluate convergence as a function of the message size in Figures 2(a) and 2(c).
Final performance of all trained models is summarized in Tables 1 and 2.
[Figure]
Effect of local training epochs As studied in previous work (McMahan et al., 2017; Caldas et al., 2018; Sahu et al., 2018), the number of local training epochs E can affect the performance of FedAvg and sometimes lead to divergence.
We conduct an experimental study on the effect of
E over FedAvg, FedProx, and FedMA on VGG-9 trained on
CIFAR-10 under heterogeneous setup.
The candidate local epochs we consider are E ∈ { 10 , 20 , 50 , 70 , 100 , 150 } .
For each of the candidate E , we run FedMA for 6 rounds while FedAvg and FedProx for 54 rounds and report the ﬁnal accuracy that each methods achieves.
The result is shown in Figure 3.
We observe that training longer beneﬁts FedMA, supporting our assumption that FedMA performs best on local models with higher quality.
For FedAvg, longer local training leads to deterioration of the ﬁnal accuracy, which matches the observations made in the previous literature (McMahan et al., 2017;
Caldas et al., 2018; Sahu et al., 2018).
FedProx only partially alleviates this problem.
The result of this experiment suggests that FedMA is the only method that local clients can use to train their model as long as they want.
[Table]
[Table]
Handling data bias Real world data often exhibit multimodality within each class, e
[Table]
g. geodiversity.
It has been shown that an observable amerocentric and eurocentric bias is present in the widely used ImageNet dataset (Shankar et al., 2017; Russakovsky et al., 2015).
Classiﬁers trained on such data “learn” these biases and perform poorly on the under-represented domains (modalities) since correlation between the corresponding dominating domain and class can prevent the classiﬁer from learning meaningful relations between features and classes.
For example, classiﬁer trained on amerocentric and eurocentric data may learn to associate white color dress with a “bride” class, therefore underperforming on the wedding images taken in countries where wedding traditions are different (Doshi, 2018) [Table]
[Figure]
-10 dataset. The data bias scenario is an important aspect of federated learning, however it received little to no attention in the prior federated learning works.
In this study we argue that FedMA can handle this type of problem.
If we view each domain, e.g. geographic region, as one client, local models will not be affected by the aggregate data biases and learn meaningful relations between features and classes.
FedMA can then be used to learn a good global model without biases.
We have already demonstrated strong performance of FedMA on federated learning problems with heterogeneous data across clients and this scenario is very similar.
To verify this conjecture we conduct the following experiment.
We simulate the skewed domain problem with CIFAR-10 dataset by randomly selecting 5 classes and making 95% training images in those classes to be grayscale.
For the remaining 5 we turn only 5% of the corresponding images into grayscale.
By doing so, we create 5 grayscale images dominated classes and 5 colored images dominated classes.
In the test set, there is half grayscale and half colored images for each class.
We anticipate entire data training to pick up the uninformative correlations between greyscale and certain classes, leading to poor test performance without these correlations.
In Figure 4 we see that entire data training performs poorly in comparison to the regular (i.e. No Bias) training and testing on CIFAR-10 dataset without any grayscaling.
This experiment was motivated by Olga Russakovsky’s talk at ICML 2019.
Next we compare the federated learning based approaches.
We split the images from color dominated classes and grayscale dominated classes into 2 clients.
We then conduct FedMA with communication, FedAvg, and FedProx with these 2 clients. FedMA noticeably outperforms the entire
0 5 10 15 20 25       (a) Raw input 0 5 10 15 20 25       (b) FedMA ﬁlter0 5 10 15 20 25       (c) Client1, ﬁlter0 5 10 15 20 25       (d) Client2, ﬁlter0 5 10 15 20 25       (e) FedAvg ﬁlter0 5 10 15 20 25       (f) Raw input 0 5 10 15 20 25       (g)
FedMA ﬁlter0 5 10 15 20 25       (h) Client 1, ﬁlter 0 5 10 15 20 25       (i) Client 2, ﬁlter 0 5 10 15 20 25       (j) FedAvg ﬁlter data training and other federated learning approach as shown in Figure 4.
This result suggests that
FedMA may be of interest beyond learning under the federated learning constraints, where entire data training is the performance upper bound , but also to eliminate data biases and outperform entire data training.
We consider two additional approaches to eliminate data bias without the federated learning constraints.
One way to alleviate data bias is to selectively collect more data to debias the dataset.
In the context of our experiment, this means getting more colored images for grayscale dominated classes and more grayscale images for color dominated classes.
We simulate this scenario by simply doing a full data training where each class in both train and test images has equal amount of grayscale and color images.
This procedure, Color Balanced, performs well, but selective collection of new data in practice may be expensive or even not possible.
Instead of collecting new data, one may consider oversampling from the available data to debias.
In Oversampling, we sample the underrepresented domain (via sampling with replacement) to make the proportion of color and grayscale images to be equal for each class (oversampled images are also passed through the data augmentation pipeline, e.g. random ﬂipping and cropping, to further enforce the data diversity).
Such procedure may be prone to overﬁtting the oversampled images and we see that this approach only provides marginal improvement of the model accuracy compared to centralized training over the skewed dataset and performs noticeably worse than FedMA. [Figure]
Data efﬁciency It is known that deep learning models perform better when more training data is available.
However, under the federated learning constraints, data efﬁciency has not been studied to the best of our knowledge.
The challenge here is that when new clients join the federated system, they each bring their own version of the data distribution, which, if not handled properly, may deteriorate the performance despite the growing data size across the clients.
To simulate this scenario we ﬁrst partition the entire training CIFARdataset into 5 homogeneous pieces.
We then partition each homogeneous data piece further into 5 sub-pieces heterogeneously.
Using this strategy, we partition the CIFARtraining set into 25 heterogeneous small sub-datasets containing approximately 2k points each.
We conduct a 5-step experimental study: starting from a randomly selected homogeneous piece consisting of 5 associated heterogeneous sub-pieces, we simulate a 5-client federated learning heterogeneous problem.
For each consecutive step, we add one of the remaining homogeneous data pieces consisting of 5 new clients with heterogeneous subdatasets.
Results are presented in Figure 6.
Performance of FedMA (with a single pass) improves when new clients are added to the federated learning system, while FedAvg with 9 communication rounds deteriorates.
Interpretability One of the strengths of FedMA is that it utilizes communication rounds more efﬁciently than FedAvg.
Instead of directly averaging weights element-wise, FedMA identiﬁes matching groups of convolutional ﬁlters and then averages them into the global convolutional ﬁlters.
It’s natural to ask “How does the matched ﬁlters look like?” .
In Figure 5 we visualize the representations generated by a pair of matched local ﬁlters, aggregated global ﬁlter, and the ﬁlter returned by the FedAvg method over the same input image.
Matched ﬁlters and the global ﬁlter found with
FedMA are extracting the same feature of the input image, i.e. ﬁlter 0 of client 1 and ﬁlter 23 of client 2 are extracting the position of the legs of the horse, and the corresponding matched global ﬁlter 0 does the same.
For the FedAvg, global ﬁlter 0 is the average of ﬁlter 0 of client 1 and ﬁlterof client 2, which clearly tampers the leg extraction functionality of ﬁlter 0 of client 1.
C ONCLUSION
In this paper, we presented FedMA, a new layer-wise federated learning algorithm designed for modern CNNs and LSTMs architectures utilizing probabilistic matching and model size adaptation.
We demonstrate the convergence rate and communication efﬁciency of FedMA empirically.
In the future, we would like to extend FedMA towards ﬁnding the optimal averaging strategy.
Making
FedMA support more building blocks e.g. residual structures in CNNs and batch normalization layers is also of interest.
A S UMMARY OF THE DATASETS USED IN THE EXPERIMENTS
The details of the datasets and hyper-parameters used in our experiments are summarized in Table 3. In conducting the “freezing and retraining” process of FedMA, we notice when retraining the last FC layer while keeping all previous layers frozen (only for the VGG-9 architecture), the initial learning rate we use for SGD doesn’t lead to a good convergence. To ﬁx this issue, we divide the initial learning rate by 10 i.e. using 10 − 4 for the last FC layer retraining and allow retraining for 3 times more epochs. We also switch off the (cid:96) 2 weight decay during the “freezing and retraining” process of FedMA except for the last FC layer where we use a (cid:96) 2 weight decay of 10 − 4 .
For language task, we observe SGD with a constant learning rate works well for all considered methods. In our experiments, we use FedAvg and FedProx variants without the shared initialization since those would likely be more realistic when trying to aggregate locally pre-trained models. And FedMA still performs well in practical scenarios where local clients won’t be able to share the random initialization.
[Table]
The details of the model architectures we used in the experiments are summarized in this section. Speciﬁcally, details of the VGG-9 model architecture we used can be found in Table 4 and details of the 1-layer LSTM model used in our experimental study can be found in Table 5.
C D ATA AUGMENTATION AND NORMALIZATION DETAILS
In preprocessing the images in CIFAR-10 dataset, we follow the standard data augmentation and normalization process.
For data augmentation, random cropping and horizontal random ﬂipping are used.
Each color channels are normalized with mean and standard deviation by µ r = 0 .
491372549 , µ g = 0 .
482352941 , µ b = 0 .
446666667 , σ r = 0 .
247058824 , σ g = 0 .
243529412 , σ b = 0 . 261568627 .
Each channel pixel is normalized by subtracting the mean value in this color channel and then divided by the standard deviation of this color channel.
D E XTRA E XPERIMENTAL D ETAILS D. S HAPES OF F INAL G LOBAL M ODEL
Here we report the shapes of ﬁnal global VGG and LSTM models returned by FedMA with communication. [Table] [Table] [Table]
[Table]
D. H YPER - PARAMETERS FOR BBP-MAP
We follow FPNM (Yurochkin et al., 2019b) to choose the hyper-parameters of BBP-MAP
[Table]
which controls the choices of θ i , (cid:15)
[Table]
and the f ( · ) as discussed in Section 2.
More speciﬁcally, there are three parameters to choose i.e. 1) σ 20 , the prior variance of weights of the global neural network.
γ 0 , which controls discovery of new hidden states.
Increasing γ 0 leads to a larger ﬁnal global model.
3) σ 2 is the variance of the local neural network weights around corresponding global network weights.
{+We empirically analyze the different choices of the three hyper-parameters and ﬁnd the choice of γ 0 = 7 , σ 20 = 1 , σ 2 = 1 for VGG-9 on CIFAR-10 dataset and γ 
+}
= 10 − 3 , σ 20 = 1 , σ 2 = 1 for
LSTM on Shakespeare dataset lead to good performance in our experimental studies.
E P RACTICAL C ONSIDERATIONS
Following from the discussion in PFNM, here we brieﬂy discuss the time complexity of FedMA.
For simplicity, we focus on a single-layer matching and assume all participating clients train the same model architecture.
The complexity for matching the entire model follows trivially from this discussion.
The worst case complexity is achieved when no hidden states are matched and is equal to
O ( D ( JL ) 2 ) for building the cost matrix and O (( JL ) 3 ) for running the Hungarian algorithm where the deﬁnitions of D, J , and L follow the discussion in Section 2.
The best complexity per layer is (achieved when all hidden states are matched)
O ( DL 2 + L 3 ) .
Practically, when the number of participating clients i.e. J is large and each client trains a big model, the speed of our algorithm can be relatively slow.
To seed up the Hungarian algorithm.
Although there isn’t any algorithm that achieves lower complexity, better implementation improves the constant signiﬁcantly.
In our experiments, we used an implementation based on shortest path augmentation i.e. lapsolver 2 .
Empirically, we observed that this implementation of the Hungarian algorithm leads to orders of magnitude speed ups over the vanilla implementation.
F H YPER - PARAMETERS FOR THE H ANDLING D ATA B IAS E XPERIMENTS
In conducting the “handling data bias” experiments.
We re-tune the local epoch E for both FedAvg and FedProx.
The considered candidates of E are { 5 , 10 , 20 , 30 } .
We observe that a relatively large choice of E can easily lead to poor convergence of FedAvg.
While FedProx tolerates larger choices of E better, a smaller E can always lead to good convergence.
We use E = 5 for both FedAvg and
FedProx in our experiments.
{+For FedMA, we choose E = 
+}
and it leads to a good convergence.
And we observe larger values E make FedMA converge even better.
For the experimental results reported in this paper.
We conduct 6 rounds of communication for FedMA and 54 rounds of communication for both FedMA and FedProx.
For the “oversampling” baseline, we found that using
SGD to train VGG-9 over oversampled dataset doesn’t lead to a good convergence.
Moreover, when using constant learning rate, SGD can lead to divergence.
Thus we use A MS G RAD (Reddi et al., 2018) method for the “oversampling” baseline and train for 800 epochs.
To make the comparison fair, we use A MS G RAD for all other centralized baselines to get the reported results in our experiments.
Most of them converges when training for 200 epochs.
We also test the performance of the “Entire Data Training”, “Color Balanced”, and “No Bias” baselines over SGD.
We use learning rate 0 .
01 and (cid:96) 2 weight decay at 10 − 4 and train for 200 epochs for those three baselines.
It seems the “Entire Data Training” and ”No Bias” baselines converges to a slightly better accuracy 78 .
71% and 91 .
23% respectively.
But the “Color Balanced” doesn’t seem to converge better accuracy (we get 87 .
79% accuracy for SGD and 88 .
81% for A MS G RAD ).