R OBUST
F EDERATED
L EARNING
T HROUGH
R EPRESENTATION
M ATCHING
AND
A DAPTIVE
H YPERPARAMETERS
Anonymous authors
Paper under double-blind review
A BSTRACT
Federated learning is a distributed, privacy-aware learning scenario which trains a single model on data belonging to several clients.
Each client trains a local model on its data and the local models are then aggregated by a central party.
Current federated learning methods struggle in cases with heterogeneous client-side data distributions which can quickly lead to divergent local models and a collapse in performance.
Careful hyper-parameter tuning is particularly important in these cases but traditional automated hyper-parameter tuning methods would require several training trials which is often impractical in a federated learning setting.
We describe a two-pronged solution to the issues of robustness and hyper-parameter tuning in federated learning settings.
We propose a novel representation matching scheme that reduces the divergence of local models by ensuring the feature representations in the global (aggregate) model can be derived from the locally learned representations.
We also propose an online hyper-parameter tuning scheme which uses an online version of the REINFORCE algorithm to ﬁnd a hyper-parameter distribution that maximizes the expected improvements in training loss.
We show on several benchmarks that our two-part scheme of local representation matching and global adaptive hyper-parameters signiﬁcantly improves performance and training robustness.
I NTRODUCTION
The size of the data used to train machine learning models is steadily increasing, and the privacy concerns associated with storing and managing this data are becoming more pressing.
Ofﬂoading model training to the data owners is an attractive solution to address both scalability and privacy concerns.
This gives rise to the Federated Learning (FL) setting (McMahan et al., 2016) where several clients collaboratively train a model without disclosing their data.
In synchronous FL, training proceeds in rounds where at the beginning of each round, a central party sends the latest version of the model to the clients.
The clients (or a subset of them) train the received model on their local datasets and then communicate the resulting models to the central party at the end of the round.
The central party aggregates the client models (typically by averaging them) to obtain the new version of the model which it then communicates to the clients in the next round.
The FL setting poses a unique set of challenges compared to standard stochastic gradient descent (SGD) learning on a monolithic dataset.
In real-world settings, data from each client may be drawn from different distributions, and this heterogeneity can lead the local learning processes to diverge from each other, harming the convergence rate and ﬁnal performance of the aggregate model.
We address this challenge in two ways: (1) adaptive on-line tuning of hyper-parameters; and (2) adding a regularization term that punishes divergent representation learning across clients.
Traditional hyper-parameter tuning schemes, such as random search (Bergstra & Bengio, 2012) or Bayesian methods (Bergstra et al., 2011; Snoek et al., 2012), require several training runs to evaluate the ﬁtness of different hyper-parameters.
This is impractical in the FL setting, which strives to minimize unnecessary communication.
To address this issue, we formulate the hyper-parameter selection problem as an online reinforcement learning (RL) problem: in each round, the learners perform an action by selecting particular hyper-parameter values, and at the end of the round get a reward which is the relative reduction in training loss.
We then update the hyper-parameter selection policy online to maximize the rewards.
Unlike centralized SGD, where there is a single trajectory of parameter updates, the FL setting has many local parameter trajectories, one per each active client.
Even though they share the same initial point, these trajectories could signiﬁcantly diverge.
Averaging the endpoints of these divergent trajectories at the end of a training round would then result in a poor model (Zhao et al., 2018).
Clients with heterogeneous data distributions exacerbate this effect as each client could quickly learn representations speciﬁc to its local dataset.
We introduce a scheme that mitigates the problem of divergent representations: each client uses the representations it learns to reconstruct the representations in the initial model it receives.
A client is thus discouraged from learning representations that are too speciﬁc and that discard information about the globally learned representations.
We show that this representation matching scheme signiﬁcantly improves robustness and accuracy in the presence of heterogeneous client-side data distributions.
We evaluate the performance of our two-part scheme, representation matching and online hyperparameter adjustments, on image classiﬁcation tasks: MNIST, CIFAR10; and on a keyword spotting (KWS) task.
We show that for homogeneous client-side data distributions, our scheme consistently improves accuracy.
For heterogeneous clients, in addition to improving accuracy, our scheme improves training robustness and stops catastrophic training failures without having to manually tune hyper-parameters for each task.
R ELATED WORK
The simplest automated hyper-parameter tuning methods execute random searches in hyperparameter space to ﬁnd the best-performing hyper-parameters (Bergstra & Bengio, 2012).
Random search is outperformed by Bayesian methods (Bergstra et al., 2011; Snoek et al., 2012) that use the performance of previously selected hyper-parameters to inform the choice of new hyper-parameter to try.
In these methods, the ﬁtness of a hyper-parameter choice is the post-training validation accuracy.
Running the training process to completion in order to evaluate the hyper-parameter ﬁtness is computationally intensive.
This motivates running partial training runs instead (Klein et al., 2016;
Li et al., 2016).
However, in FL settings with tight communication budgets, running several (partial) training runs to select the right hyper-parameters could still be impractical.
Hyper-parameters can be optimized using gradient descent to minimize the ﬁnal validation loss.
To avoid storing the entire training trajectory in order to evaluate the hyper-gradients, Maclaurin et al.
(2015) uses reversible learning dynamics to allow the entire training trajectory to be reconstructed from the ﬁnal model.
Alternatively, the hyper-gradients can be calculated in a forward manner, albeit at an increased memory overhead (Franceschi et al., 2017).
Using the hyper-gradient to optimize hyper-parameters is an iterative process that requires several standard training runs (hyper-iterations), again making this approach impractical in a communication-constrained FL setting.
Hyper-parameters can be optimized using SGD in tandem with model parameters through the use of hyper-networks (Ha et al., 2016; Lorraine & Duvenaud, 2018) which map hyper-parameters to optimal model parameters.
It is unclear how hyper-networks can be learned in a FL setting as we are interested in choosing hyper-parameters that result in the best post-aggregation model and not the hyper-parameters chosen by any particular client to optimize its own model on its own dataset.
The hyper-parameter tuning approaches most related to ours are those based on RL methods.
Daniel et al.
; Jomaa et al.
learn policies and/or state-action values that are then used to select good hyper-parameters.
However, several training runs are needed to learn the policies and the action values.
Perhaps the closest approach to ours is the method in Xu et al.
(2017) which trains an actor-critic network in tandem with the main model and uses it to select actions (hyper-parameter choices) that maximize the expected reduction in training loss.
It is unclear how this approach can be applied in a FL setting as the training process on each client has no access to the loss of interest which is the loss of the post-aggregation model.
FL typically struggles when the client-side data distributions are signiﬁcantly different (McMahan et al., 2016; Zhao et al., 2018) as this causes the parameter trajectories to signiﬁcantly diverge
[Figure]
across different clients.
This severely degrades the performance of the averaged model (Zhao et al., 2018).
One straightforward solution is to reduce the SGD steps each client takes between the synchronization (model averaging) points.
More frequent model synchronization, however, increases communication volume.
Various compression methods (Sattler et al., 2019; Koneˇcn`y et al., 2016) are able to compress the model updates, which makes it possible to synchronize more frequently and mitigate the effect of heterogeneous data distributions.
Sattler et al.
(2019) takes the extreme case of synchronizing after every SGD step, which reduces the FL setting to standard SGD.
An alternative solution is to mix the datasets of the different clients to obtain more homogeneous client-side data distributions (Zhao et al., 2018).
This, however, compromises the privacy of the clients’ data.
METHODS
We build upon the federated averaging (FedAvg) algorithm (McMahan et al., 2016) and introduce two novel aspects to it: global adaptive hyper-parameters and local (per-client) representation matching.
We ﬁrst give an informal description of the complete algorithm.
We consider a synchronous
FedAvg setting with K clients, where D k is the dataset local to client k .
Training proceeds in rounds.
Figure 1 illustrates the steps involved in training round t .
The server maintains a distribution P ( H| ψ ) over the space of hyper-parameters H .
At the beginning of round t (Fig. 1a), the selected clients receive the most recent model parameters from the server, w t , together with training hyper-parameters h t sampled from P ( H| ψ t ) .
Client i uses two copies of w t to initialize two models: a ﬁxed model M F and a trainable model M it .
The parameters w it of M it are trained using
SGD (Fig. 1b).
Client i maintains a set of local parameters θ it that it uses to map the activations in
M it to the activations in M F .
θ it and w it are simultaneously trained to minimize a two-component loss: the ﬁrst component is the standard training loss of M it on D i (for example, the cross-entropy loss); the second component is the mean squared difference between the activations in M F and the activations reconstructed from M it using θ it .
We denote this second component as the representation matching loss.
In the ﬁnal step in the round (Fig. 1c), each participating client sends its ﬁnal model parameters, w it , to the central server.
The server aggregates the model parameters, and uses the loss of the resulting model to update the parameters ψ of the hyper-parameter distribution, P ( H| ψ ) .
3. R EPRESENTATION M ATCHING
We now describe the representation matching scheme.
For an example model, Fig. 2 illustrates how the local parameters θ i in client i are used to map the activations of the model being trained, M i ,to the activations of the ﬁxed model M F .
M i is parameterized by w i while M F is parameterized by w which was received from the server at the beginning of training.
To simplify notation, we dropped the index of the round, t .
Given a data point x ∼ D i , x is fed to M i and M F to obtain the layer activations [ a 1 ( x ; w i ) , . . .
a M ( x ; w i )] and [ a 1 ( x ; w ) , . . . , a M ( x ; w )] , respectively.
These are not all the model activations, but only the M activations we are interested in matching.
The
[Figure]
activations in the two models are matched by a set of matching layers parameterized by θ i ( θ i ≡ [ θ i 1 , θ i 2 , θ i 3 ] in Fig. 2).
Instead of deriving the activations of one layer in M F from the activations of the corresponding layer in M i , we found performance signiﬁcantly improves if the activations of one layer are instead derived from the activations of the next layer of interest above it.
As shown in the representative example in Fig.
2, the activations/layers of interest are the input layer, the point-wise non-linearity layers and the top layer.
We use convolutional matching layers if the input has spatial information (such as within a convolutional stack), and fully-connected matching layers otherwise.
To reverse a pooling operation, we follow the scheme in Zhao et al.
and
unpool pooled activations using the pooling positions used during the pooling operation as shown in Fig. 2.
Given a training point and label ( x , y ) ∼ D i , we deﬁne the matching loss at client i as:
[Equation]
where f j denotes the j th matching layer.
The per-point training loss at client i is:
[Equation]
where L C is the cross-entropy loss and a M ( x ; w i ) is the top layer activation in the trainable model.
Our representation matching architecture is similar in some respects to auto-encoding architectures, particularly ladder networks (Rasmus et al., 2015).
Unlike ladder networks, however, we do not reconstruct the activations of a non-noisy model from a noisy model but rather, reconstruct the activations of the most recent aggregate model from the activations of the model while it is being trained on a local dataset.
This has a regularizing inﬂuence as it stops the clients from learning representations that are too speciﬁc to their local datasets.
This should also ameliorate the effect of model divergence in the clients as all client models have to learn representations that are mappable to a common set of representations deﬁned by the common aggregate model.
Additional regularization comes about because a layer’s activations are used to reconstruct the activations of a layer below it.
A similar technique was used in what-where autoencoders (Zhao et al., 2015), and was shown to signiﬁcantly improve accuracy.
Our approach is fundamentally distinct, however, as we use the activations in one one model, M i , to reconstruct the activations in a different model, M F .
Our representation matching scheme is similar in spirit to the techniques used to learn invariant feature representations for domain adaptation where the goal is to minimize the discrepancy between the distributions of features extracted from different domains.
However, current techniques for learning domain-invariant features(Ganin et al., 2016; Shen et al., 2017) are incompatible with the FL setting as they require the learner to have access to data from different domains (clients in our case) in order to match the feature distributions across these domains.
3. A DAPTIVE HYPER - PARAMETERS
At each round, the server provides the clients with training hyper-parameters.
The hyper-parameters h t provided in round t are a sample from P ( H| ψ t ) .
Let L t be the loss of the aggregate model at the beginning of round t on a representative set of data points (we describe in the next subsection practical schemes for evaluating L t ).
We deﬁne the reward received for choosing hyper-parameter h t as r t =
( L t − L t +1 ) /L
t .
The use of relative loss reduction is motivated by the desire to have the scale of rewards unchanged throughout training.
At round t , the goal is to maximize:
[Equation]
Taking the derivative of J t and approximating it with a one-sample Monte Carlo estimate, we obtain [Equation] h
[Equation]
∼ P ( h
[Equation]
The score-function or REINFORCE gradient estimator (Williams, 1992) in Eq.
5 can be readily evaluated and can be used to update ψ t .
However, the variance of this gradient estimator can be quite high (Rezende et al., 2014), especially since we are using a single-sample estimate.
To reduce variance, we introduce a reward baseline (Greensmith et al., 2004) which is the weighted average reward in an interval [ t − Z, t + Z ] centered around t .
The update equation for ψ t is:
[Equation]
) ∇ ψ t log [Equation] P [Equation]
h t | ψ t ))
where
[Equation]
where η H is the hyper learning rate and γ Z a normalizing constant.
We weigh nearby rewards more heavily than distant rewards when calculating the baseline in round t .
A causal version of Eq. 6 that only depends on past rewards is:
[Equation]
where
[Equation]
which is the update equation for ψ that we use.
Even though we are using RL terminology, there are several fundamental differences between our problem and traditional RL problems.
First, the setting is non-stationary as the same action in different rounds could lead to a different reward distribution.
For example, large learning rates are appropriate towards the beginning of training but would increase the loss towards the end of training.
In our scheme, this is reﬂected in the design of the baseline which weighs nearby rewards more heavily as these provide a more accurate baseline of the rewards at the current state of the learning problem.
This non-stationary behavior can be modeled as a partially-observable Markov decision process (Jaakkola et al., 1995).
While several techniques can be used to learn policies in non-stationary settings (Padakandla et al., 2019; Abdallah & Kaisers, 2016), these methods are not online and require several trajectories (training runs in our case) to optimize the policy.
The second difference from traditional RL methods is that we do not seek to maximize the (discounted) sum of rewards, but rather, at each round t , we seek to maximize the rewards in a small interval [ t − Z, t ] which is what allows us to formulate an online algorithm.
3. F ULL A LGORITHM AND P RACTICAL C ONSIDERATIONS
Algorithm 1 describes the FedAvg algorithm with our two contributions: representation matching and adaptive hyper-parameters.
There are a couple of practical considerations that we address here:
Evaluating the loss of the aggregate model: After each round, the server needs to evaluate the loss of the aggregate model in order to obtain the reward signal (Line 15 in algorithm 1).
This could be done in two ways:1)
The server maintains a small validation set on which it evaluates the loss.
This validation set has to be representative of the clients’ data.
Unlike the scheme in Zhao et al.
(2015), this validation set is not shared with the clients and can be collected from them in a secure way to avoid revealing the origin of each data point.
At the start of a round, the clients themselves evaluate the loss of the aggregate model on a small part of their training data and then send the scalar loss to the server.
The server averages these losses to obtain an estimate of the loss.
This estimate is good if the fraction of participating clients in the round is high, which would make the evaluated loss more representative of the loss across all clients.
In our experiments, we use the ﬁrst approach.
do 4: h ψ
S
←
6: for i
S do
7: w
← iterations do
← sample w θ it ] ← [ w θ it ] − η h t
∇ [ w it θ it ]
L i
X
Y w w t θ
11: end
12: θ it
1 ← θ it 13: end for 14: w t +1 ← w t + (cid:80) i ∈
S t n k N ( w it − w t ) 15:
L t +1 ← Loss ( w t +1 ) 16: r t ← ( L t − L t +1 ) /L
t 17:
Z (cid:48) ← min ( Z, t − 1) 18: ψ t +1 ← ψ t − η H τ = t (cid:80) τ
= t − Z (cid:48)
( r τ − ˆ r t ) ∇ ψ τ log ( P ( h τ | ψ τ ))
where ˆ r t = 1 Z (cid:48)
+ τ = t (cid:80)
τ
= t − Z (cid:48)
r τ 19: end for
Choosing the form of P ( H| ψ ) : For D hyper-parameters, we use a discrete D-dimensional hyperparameter space. For the p th hyper-parameter, we have a ﬁnite set of allowable values H p . H is a D-dimensional grid containing all possible combinations of the allowed values of the D hyperparameter. |H| =
(cid:81)
Dp
=1 |H p | .
For P ( H| ψ ) we use a D-dimensional discrete Gaussian.
Let
N ( •| µ, A ) be a standard(continuous) D-dimensional Gaussian with mean µ and precision A .
Let h
j
=
( h 1 j , . . .
, h Dj ) be a point on the grid H .
P ( h j | ψ ) = 1 Z N ( h j | µ, A ) where ψ = { µ, A } and
Z = (cid:80) h ∈H N ( h | µ, A ) .
Since different hyper-parameters can have different scales, we shift and normalize the allowed values for each hyper-parameter so that they have zero mean and are in the range [ − 0 .
5] before constructing the grid.
The grid of hyper-parameters H thus has zero-mean and the same scale in all dimensions.
This increase the stability of the hyper-parameter tuning algorithm as the optimization space is uniform in all directions.
We choose a discrete hyper-parameter space H to force different hyper-parameter choices to be signiﬁcantly different, which would provide more distinct reward signals to the online REINFORCE algorithm.
The choice of a uni-modal distribution, such as the discrete Gaussian, encourages hyperparameter exploration to focus on areas around the mode.
This embodies the inductive bias that the optimal hyper-parameter in one round is close to the optimal hyper-parameter in the previous round.
E XPERIMENTAL RESULTS
We evaluate the performance of our two-part scheme on the MNIST and CIFAR10 image classiﬁcation datasets, and on a KWS task using the speech commands dataset (Warden, 2018).
We restrict the KWS task to only ten keywords.
In all experiments, we use ten clients and use one of two data distributions: iid where the dataset is split randomly across the ten clients, and non-iid where each client only has data points belonging to one of the ten classes.
We use our online hyper-parameter tuning scheme to tune the learning rate and the number of SGD iterations (see algorithm 1).
In all experiments, we use the same hyper-hyper-parameters controlling the hyper-parameter tuning process which are the hyper-learning rate η H , the hyper-parameter grid H , and the REINFORCE baseline interval Z .
One exception is the KWS task where we modify the grid H to reduce the number of allowed SGD iterations per round to reﬂect the smaller size of the dataset.
A batch size of 64 is used throughout.
In all experiments, we add an entropy regularization (ER) term (Pereyra et al., 2017) to the client losses during training.
For client i in round t with input x , the ER loss term has the form:
[Equation]
where H ( • ) is the entropy operator and a M the top layer activity.
L ER penalizes highly conﬁdent (low entropy) output distributions when their entropy falls below H min .
This loss term signiﬁcantly improves the performance of the FedAvg algorithm in the presence of non-iid client data.
As a comparison baseline, we run experiments with a ﬁxed decay schedule for both the learning rate and the number of SGD iterations per round.
As a baseline for our representation matching scheme, we run experiments where each client’s training loss is augmented with a term that penalizes weight divergence between the client model parameters and the initial parameters received from the server.
For client i in round t , this weight divergence (WD) loss term has the form || w t − w it
||
This penalty function was introduced into the FL setting by the FedProx algorithm (Li et al., 2018) to mitigate the effect of model divergence.
We report results for the standard FedAvg algorithm (FA), FedAvg with a weight divergence loss term in the clients (FA+WD), and FedAvg augmented with adaptive hyper-parameters(AH) and/or representation matching (RM).
We consider two values for C (the fraction of clients participating in each round): C = 0 .
5 and C = 1 . 0 .
For the baselines, FA and FA+WD, we manually tuned the hyper-parameters decay schedule to obtain best accuracy.
This tuning was done separately for the iid and non-iid cases .
All experiments were repeated 3 times.
MNIST :
We use a fully-connected network with two hidden layers with 100 neurons each.
As shown in table 1, the best performing algorithm is FA+AH.
The use of representation matching causes a slight degradation in performance (FA+RM+AH and FA+RM).
It is interesting to look at the trajectory of the mean µ of the discrete Gaussian hyper-parameter distribution P ( H| µ, A ) .
This is shown in the ﬁrst column of Fig.
3 for the iid and non-iid cases.
In the non-iid case, the online
REINFORCE algorithm pushes the mean learning rate down as it detects that a smaller learning rate yields greater loss reductions, while in the iid case, the mean learning rate is pushed up instead.
This aligns with what a practitioner would do to ensure convergence in the more challenging non-iid case.
The REINFORCE algorithm chooses to keep the mean number of SGD iterations per round relatively high for most of the training run.
As shown in table 1, these choices yield slightly better accuracy (FA+AH) than the ﬁxed training schedule used in the standard FA algorithm.
[Table]
CIFAR10 :
We use a network with two convolutional layers (with 32 and 64 feature maps and 5x kernels) followed by two fully connected layers (with 1024 and 10 neurons).
2x2 max pooling was used after each convolutional layer.
As shown in table 2, the use of representation matching yields a signiﬁcant improvement in accuracy for the non-iid case while slightly improving performance in the iid case.
The beneﬁt of adaptive hyper-parameters over a ﬁxed hyper-parameter schedule are more equivocal.
The evolution of adaptive hyper-parameters is shown in the second column of
Fig.
Unlike the MNIST case, the REINFORCE algorithm chooses to push down the learning rate for the iid case as well which actually leads to better performance in the iid case compared to the ﬁxed schedule (FA vs. FA+AH and FA+RM+AH vs. FA+RM in table 2).
In the non-iid case, the ﬁxed schedule performs better, though.
Keyword spotting task : We calculate the mel spectrogram for each speech command to obtain a 32x32 input to our network.
The network we use has four convolutional layers with 3x3 kernels and 64 feature maps each (with 2x2 max pooling after each pair), followed by two fully connected layers of 1024 and 10 neurons.
In this deeper network, representation matching is essential in
[Table]
[Figure]
[Table]
[Figure]
During forced to the non-iid case as shown in table 3 since training consistently fails in its absence. It might be possible that with ﬁne tuning of hyper-parameters, training would be possible in the non-iid case. However, representation matching obviates the need for such ﬁne tuning. FA+RM+AH consistently outperforms all other methods indicating the hyper-parameters schedule found by the REINFORCE algorithm (third column in Fig. 3) is better than the ﬁxed schedule.
[Table]
Communication and computational overhead : Our representation matching scheme does not introduce any communication overhead between the clients and the central server. The adaptive hyper-parameters scheme introduces a negligible communication overhead for sending two scalar hyper-parameters to the clients each round. As for computational overhead, we quantify the wallclock run-time 1 for training a client for 30 SGD iterations or mini-batches (mini-batch size of 64). Where adaptive hyper-parameters are used, we also include the time needed to execute the adaptive hyper-parameter tuning procedure.
The results are shown in table 4. We note that the overhead of our hyper-parameter tuning procedure is negligible (FA vs. FA+AH) and is typically less than 2% . This negligible computational overhead is primarily the cost of a single inference pass to evaluate the loss L t on a very small subset of the training set.
The Representation matching scheme is signiﬁcantly more demanding as as it requires optimizing a more complicated loss during each SGD iteration at the client.
[Table]
D ISCUSSION
We described two additions to the FedAvg algorithm: representation matching and adaptive hyperparameters.
We compared representation matching (FA+RM) against a scheme based on penalizing weight divergence (FA+WD) and FA+RM came out on top by a signiﬁcant margin in the more difﬁcult tasks we tried: CIFAR10 and KWS.
We compared our adaptive hyper-parameter scheme against a ﬁxed hyper-parameter schedule chosen based on experience.
In most cases, adaptive hyper-parameters outperform the ﬁxed-schedule scheme.
The combination of our two new additions (FA+RM+AH) slightly improves performance compared to standard FA in the small MNIST network and signiﬁcantly improves performance on the deeper networks used in CIFAR10 and KWS.
The hyper-parameter schedule chosen by our REINFORCE algorithm exhibits some easily interpretable behavior such as reducing the learning rate in the more difﬁcult non-iid cases.
However, we see some behavior that does not have an immediately obvious interpretation.
For example, in order to maximize rewards in the non-iid case, reducing the learning rate is more important than reducing the number of SGD iterations per round as can be seen in Fig.
It is important to note that at each round, our online REINFORCE algorithm only seeks to maximize the loss improvement in the last few rounds.
Moreover, our algorithm continuously samples hyper-parameters around the mean to determine the direction of highest reward.
These noisy hyper-parameter choices could prove problematic in settings that depend on highly tuned schedules and which have no room for online exploration of hyper-parameters.
We thus expect our scheme would be outperformed by traditional automated hyper-parameter tuning methods that tune hyper-parameters to maximize the ﬁnal validation loss.
However, our scheme is signiﬁcantly more efﬁcient as it does not require repeated training and introduces only a small computational overhead in each round.