# Genetic CFL: Hyperparameter Optimization in Clustered Federated Learning

Authors: Shaashwat Agrawal; Sagnik Sarkar; Mamoun Alazab; Praveen Kumar Reddy Maddikunta; Thippa Reddy Gadekallu; Quoc-Viet Pham
Journal: Computational Intelligence and Neuroscience
 (2021)

---

## Abstract

Federated learning (FL) is a distributed model for deep learning that integrates client-server architecture, edge computing, and real-time intelligence. FL has the capability of revolutionizing machine learning (ML) but lacks in the practicality of implementation due to technological limitations, communication overhead, non-IID (independent and identically distributed) data, and privacy concerns. Training a ML model over heterogeneous non-IID data highly degrades the convergence rate and performance. The existing traditional and clustered FL algorithms exhibit two main limitations, including inefficient client training and static hyperparameter utilization. To overcome these limitations, we propose a novel hybrid algorithm, namely, genetic clustered FL (Genetic CFL), that clusters edge devices based on the training hyperparameters and genetically modifies the parameters clusterwise. Then, we introduce an algorithm that drastically increases the individual cluster accuracy by integrating the density-based clustering and genetic hyperparameter optimization. The results are bench-marked using MNIST handwritten digit dataset and the CIFAR-10 dataset. The proposed genetic CFL shows significant improvements and works well with realistic cases of non-IID and ambiguous data. An accuracy of 99.79% is observed in the MNIST dataset and 76.88% in CIFAR-10 dataset with only 10 training rounds.


---

## Body

## 1. Introduction

Federated learning (FL) [1, 2] has risen as a groundbreaking subdomain of machine learning (ML) that enables Internet of Things (IoT) devices to contribute their real-time data and processing to train ML models. FL represents a distributed architecture of a central server and heterogeneous clients, aiming to reduce the empirical loss of model prediction over nonindependent and identically distributed (non-IID) data. In contrast to traditional ML algorithms that require large amounts of homogeneous data in a central location, FL utilizes on-device intelligence over distributed data [3, 4]. The limited feasibility of ML in industrial and IoT applications is overturned by the introduction of FL. Some potential applications of FL include Google keyboard [5], image-based geolocation [6], healthcare informatics [7], and wireless communications [8].Each round of a FL paradigm constitutes of client-server communication, local training, and model aggregation [9]. The communication overhead is usually due to model broadcast from the server to all clients and vice versa. In every communication round, there is a feasibility risk in terms of limited network bandwidth, packet transmission loss, and privacy breach. In the growing applications of Industrial Internet of Things (IIoT), where the communication is Machine to Machine (M2M) these parameters may be static, making efficiency in data transfer important. Modified communication algorithms [10] use compression and encryption to reduce the model size and protect privacy. Communication load is also determined by the number of edge devices. Sparsification of communication [11] implemented over clients is modeled to increase convergence rate and reduce network traffic on the server. Many models also utilize hierarchical clustering [12] to generalize similar client models and reduce the aggregation complexity.Apart from communication, training ML models in a heterogeneous setup presents a huge challenge [13]. Once the server model is broadcast, the clients train on it considering some hyperparameters such as client ratio (i.e., from a strength of 100, number of clients chosen), learning rate, batch size, and epochs per round. With each edge device, computational power and properties of data (ambiguity, size, and complexity) vary drastically, and diversely trained client models are hard to aggregate. In a realistic scenario of thousands of edge devices, the updated global model may not converge at all. Existing aggregating algorithms such as FedAvg and FedMA [14] focus more on integration of weights of the local models. Convergence rate and learning saturation are common concerns when it comes to training and aggregation. Several novel approaches work around model aggregation either by using feature fusion of global and local models [15] or by a grouping of similar client models [16] to increase generalization. Some literatures also utilize multiple global models to better converge data [17].Research on making FL models adaptive to non-IID data has focused primarily on model aggregation. Local training of the model itself is an undermined step, given its role in the final accuracy. In this paper, we propose three novel contributions to lessen the empirical risk in FL, as shown in Figure1:(i)
Clustering of clients solely based on model hyperparameters to increase the learning efficiency per unit training of the model(ii)
Implementation of density-based clustering, i.e., DBSCAN, on the hyperparameters for proper analysis of devices properties(iii)
Introduction of genetic evolution of hyperparameters per cluster for finer tuning of individual device models and better aggregationFigure 1
Genetic CFL complete architecture.In particular, we introduce a new algorithm, namely, Genetic CFL, that clusters hyperparameters of a model to drastically increase the adaptability of FL in realistic environments. Hyperparameters such as batch size and learning rate are core features of any MFL model. In truth, every model is tuned manually depending on its behavior to the data. Therefore, in a realistic heterogeneous setup, the proper selection of these parameters could result in significantly better results. DBSCAN algorithm is used since it is not deterministic, static in terms of cluster size and uses neighbourhood of model hyperparameters for clustering. We also introduce genetic optimization of those parameters for each cluster. Genetic algorithm is algorithm since it is highly application flexible and scalable to higher dimensions. As defined, each cluster of clients has its own unique set of properties (i.e., hyperparameters) that are suitable for the training of the respective models. In each round, we determine the best parameters for each cluster and evolve them to better suit the cluster.The rest of this paper is organized as follows. Section2 discusses the recent work done in the fields of FL, clustering, and evolutionary optimization algorithms. The proposed algorithm is defined in Section 3, followed by the results in Section 4. Finally, the paper is concluded in Section 5.


## 2. Related Work

In this section, we survey the current literature on the topics of FL, density-based clustering, and evolutionary algorithms, respectively, and try to understand their limitations.


### 2.1. Federated Learning

Recently, FL as a distributed and edge ML architecture is being studied extensively [1, 18]. This decentralized nature of FL directly contradicts traditional ML algorithms which are genuinely difficult to train in a heterogeneous environment consisting of non-IID data. Novel approaches have tried to overcome this difficulty through various model aggregation algorithms, namely, FedMA [14], feature fusion of global and local models [15], and agnostic FL and grouping of similar client models [16] for better personalization and accuracy. Clustering takes advantage of data similarity in various clients and models [19] and efficient communication, and lastly improves global generalization [20]. In general, much work is yet to be done in terms of efficient model training on non-IID data.


### 2.2. Density-Based Clustering

Clustering in FL is primarily used for efficient communication and better generalization. In a realistic scenario with thousands of nodes, aggregating everything into a single model may damp the convergence greatly. Several partitioning, hierarchical, and density-based clustering algorithms have been applied to work on some of the problems existing in FL. Partitioning clustering algorithms such as k-means clustering [21] demand a predetermined number of clusters, but in actuality that is not feasible. Some examples of nondefinitive clusters include agglomorative hierarchical clustering [22] and generative adversarial network-based clustering. In this paper, we propose to use DBSCAN (density-based spatial clustering of applications with noise) [23], a density-based clustering algorithm that only groups points if they satisfy a density condition.


### 2.3. Evolutionary Algorithms

Hyperparameters of a model determine their ability to learn from a certain set of data. Optimization of ML models and their hyperparameters using evolutionary algorithms [24] such as whale optimization [25] and genetic algorithms [26] are explored by many researchers. In addition, these algorithms have been extensively used over DL frameworks that have become a trend for optimization tasks [27]. The same has yet not been adopted for FL extensively. Also, algorithms such as reinforcement learning (RL) with focus on Q-Learning are not suitable for highly complex scenarios [28]. The need for hyperparameter tuning increases even more in FL due to the ambiguity in data, and the abovementioned optimization algorithms assist in tuning those parameters beyond manual capacity. Since optimization of each client model parameters is not feasible, we propose to do so for each cluster.Through the survey, we observe that FL is greatly limited by efficiency of individual client training that includes apt choice of hyperparameters, increasing adaptive nature of the models and optimization of such process.


## 2.1. Federated Learning

Recently, FL as a distributed and edge ML architecture is being studied extensively [1, 18]. This decentralized nature of FL directly contradicts traditional ML algorithms which are genuinely difficult to train in a heterogeneous environment consisting of non-IID data. Novel approaches have tried to overcome this difficulty through various model aggregation algorithms, namely, FedMA [14], feature fusion of global and local models [15], and agnostic FL and grouping of similar client models [16] for better personalization and accuracy. Clustering takes advantage of data similarity in various clients and models [19] and efficient communication, and lastly improves global generalization [20]. In general, much work is yet to be done in terms of efficient model training on non-IID data.


## 2.2. Density-Based Clustering

Clustering in FL is primarily used for efficient communication and better generalization. In a realistic scenario with thousands of nodes, aggregating everything into a single model may damp the convergence greatly. Several partitioning, hierarchical, and density-based clustering algorithms have been applied to work on some of the problems existing in FL. Partitioning clustering algorithms such as k-means clustering [21] demand a predetermined number of clusters, but in actuality that is not feasible. Some examples of nondefinitive clusters include agglomorative hierarchical clustering [22] and generative adversarial network-based clustering. In this paper, we propose to use DBSCAN (density-based spatial clustering of applications with noise) [23], a density-based clustering algorithm that only groups points if they satisfy a density condition.


## 2.3. Evolutionary Algorithms

Hyperparameters of a model determine their ability to learn from a certain set of data. Optimization of ML models and their hyperparameters using evolutionary algorithms [24] such as whale optimization [25] and genetic algorithms [26] are explored by many researchers. In addition, these algorithms have been extensively used over DL frameworks that have become a trend for optimization tasks [27]. The same has yet not been adopted for FL extensively. Also, algorithms such as reinforcement learning (RL) with focus on Q-Learning are not suitable for highly complex scenarios [28]. The need for hyperparameter tuning increases even more in FL due to the ambiguity in data, and the abovementioned optimization algorithms assist in tuning those parameters beyond manual capacity. Since optimization of each client model parameters is not feasible, we propose to do so for each cluster.Through the survey, we observe that FL is greatly limited by efficiency of individual client training that includes apt choice of hyperparameters, increasing adaptive nature of the models and optimization of such process.


## 3. Genetic CFL Architecture

In this section, we give a detailed mathematical model of our algorithm, genetic CFL. The complete pipeline is divided into two parts, the initial broadcast round represented by Algorithm1 to determine the clusters and the federated training using genetic optimization represented by Algorithm 2. The variational behavior of the algorithm with different hyperparameters, including client ratio (n), number of rounds, ϵ, minimum samples, learning rate (η), and batch size is explained in this section. Table 1 elucidates all the symbols utilized in the algorithm.Table 1
Symbol representations.
SymbolMeaningnNumber of clientsηLearning rateBBatch sizeCiith clientw0Model weightswn0Model weight ofnth clientAlgorithm 1: Initial broadcast round and clustering.
n = Number of Clientsη: learning rateηm: learning rate list(1)
procedure Server(2)
w0: Server Model Initialization(3)
Initializeηm with learning rates 1e−1,1e−6(4)
Broadcast (w0, random (ηm,3))(5)
procedure Client(6)
i←0(7)
whilei≠ndo(8)
j←0(9)
whilej≠3do(10)
Trainwj0 on ηj(11)
losses←losswj0(12)
j = j + 1(13)
i = i + 1(14)
returnwmin0,ηmin,lossesmin(15)
procedure Server(16)
w0←∑wn0/n(17)
Initialize DBSCAN Clustering Algorithm(18)
ϵ←1e−6(19)
pointsmin←2(20)
model←DBSCANϵ,pointsmin(21)
clusters = model.fit_predict (ηn)Algorithm 2: Genetic optimization based FL on clustered data.
rounds: Number of loops for training the federated model(1)
function Mutate (η)(2)
factor← random (−1,0,1)(3)
η←η+η×factor/10(4)
returnη(5)
function Crossover (ηn)(6)
Initialize temporary arrayηtemp to store η(7)
ηtemp0,1←ηn0,1(8)
fork←2 to sizeηn do(9)
parentA,parentB←random0,sizeηn(10)
ηtempk←MutateηnparentA+ηnparentB/2(11)
returnηtemp(12)
function Evolve (lossesn,ηn)(13)
lossesn, order←sortlossesn(14)
ηn←sortηn,order(15)
return Crossover (ηn)(16)
procedure Train(17)
len←sizecluster(18)
ind←0 to len(19)
Initializeηglobal with shape (len, size (clusters ind)(20)
clustersunique=uniquecluster(21)
fori←0 to rounds do(22)
fork←0 to sizeclusterdo(23)
ind = [clusters.index (cluster[i])](24)
ηglobalk←EVOLVE lossesind,ηnind(25)
Empty arrays losses,ηn(26)
fork←0 to ndo(27)
wk0k, losses[k], ηnk=trainw0,ηglobalclusterskclustersk⋅nextIndex(28)
w0←∑wm0/nThe purpose of Algorithm1 is to discreetly determine the data characteristics of an edge device without intruding on their privacy. A server model (w0) is initialized and broadcast to n clients, C⊆C0,C1,…,Ctot. With each distributed model, three different η are broadcast. The sample size is chosen to introduce variance in training, while more number of samples can also be used for experiments. These learning rates are chosen from an array (ηm) ranging from 1e−1,1e−5. Each edge device receives w0 that is cloned for all values of η and trained individually for a single epoch. Data properties unique to an edge device such as size, complexity, ambiguity, and variance drastically affect the training, and thus, hyperparameters of a model, η, batch size, are chosen accordingly. Naturally, from the three trained models in an edge device, the one with the least loss, denoted as wmin0, is chosen. Each edge device then returns wmin0, ηmin, and lossesmin. The significance of these values is their data representative capacity of the respective edge devices.At server, the modelsw00,w10,…,wn0, the learning rates η0,η1,…,ηn, and their respective losses are attained. The model aggregation technique is used to obtain the server model by combining edge device models. The weights of the models (wn0) are summed iteratively as follows:(1)∑i=0nwi0=w00+w10+w20+⋯+wn0.After summation, the output of the equation is divided by the number of clients to obtain model aggregation as(2)w0←∑wn0n.After server model aggregation, the DBSCAN clustering algorithm is applied. In a realistic scenario, the number of edge devices and their variance cannot always be determined. In deterministic partitioning clustering methods such as K-means clustering, the number of clusters has to be predetermined and is not dynamic. DBSCAN, on the contrary, uses density-based reasoning for the grouping of similar objects. It takes two mandatory inputs,ϵ and min samples. Any point x forms a cluster if a minimum number of samples lie in its ϵ−neighbourhood. This value can be calculated by(3)Aϵ≡x∈HPspace,distx,y<ϵ,(4)HPspaceη∈1e−3,1e−7,(5)HPspacebatch−size∈16,128.Here,HPspace represents the domain in which the point x must be presented. In our case, it is the range of hyperparameters, specifically learning rate η. Each ϵ-neighbourhood must contain a certain number of points (MinPts) to be called a cluster as follows:(6)Aϵ>MinPts,MinPts∈ℕ.In the object space of only learning rate,η2−η1 gives the Euclidean distance used for ϵ neighbourhood. When the number of dimensions is increased with the addition of batch size (B) the Euclidean distance formula for the 2-coordinate system is used and logarithmic values of hyperparameters are taken to scale the exponential values to liner ones. The calculation can be observed as(7)ϵ=log10η2η12+log2B2B12.After each edge device is allotted a cluster-ID, we implement phase-2, shown by Algorithm2. This section of the algorithm works under the main control loop which runs for i rounds. In every ith iteration,(1)
Hyperparameters are optimized per cluster using genetic algorithm involving evolution followed by crossover and finally mutation(2)
The server model with optimized hyperparameters is broadcast to each client clusterwise(3)
Each client is trained based on said parameters(4)
Client models are aggregated to form the latest server modelEvery cluster has a different set of characteristic hyperparameters suitable to the edge devices belonging to them. These clustered parameters are evolved genetically followed by training for everyith round. Using genetic optimization for tuning converges the set of hyperparameters to an optimal set each round. ηglobalk is initialized that stores learning rates for each cluster, and its contents are modified every round. It is of shape C,sizeCi, where C is the number of clusters, Ci represents the ith cluster, and sizeCi represents the number of edge devices in each ith cluster. The hyperparameters of a cluster having shape m0 are sorted through their losses:(8)lossesn,order←sortlossesn,ηn←sortηn,order.Once sorted, we obtain new individuals through crossover and mutation, respectively. The best individuals (hyperparameters in a cluster) retain their genes and are promoted to the next generation (round), while the others are formed by mating of individuals from the last generation as(9)ηnew=η0,η1,…,ηsizeCm.The new learning ratesηnew are chosen either directly or by mating. The number of η taken from old generation can vary. From (9), we derive the modified parameters:(10)ηnew=ηold0,ηold1,…,ηoldPA+ηoldPB21+f10,where PA,PB∈0,9 and f∈−1,1.After genetic evolution, the server model is again broadcast to all devices with their respective cluster hyperparameters. Each edge device trains for 1 epoch, and the complete process of genetic optimization, training, and model aggregation is repeated fori−1 rounds.


## 4. Experiments and Results

This section deals with the experiments that have been conducted to validate and test the proposed genetic CFL architecture. Section4.1 deals with the clustering of the client edge devices and the clustering behavior under various parameters. Sections 4.2 and 4.3 after DBSCAN are concerned with the performance of the genetic CFL architecture on MNIST and CIFAR-10 datasets, respectively, and their comparison with the generic FL architecture. The overall performance analysis for the genetic CFL architecture is discussed in Section 4.4.


### 4.1. DBSCAN Clustering of the Client Models

The DBSCAN algorithm, as discussed in the previous section, focuses on the Euclidean distance between the observations to calculate the density and cluster the observations based on this density. The models in each edge device are assigned a particular learning rate and batch size for training. These two hyperparameters serve as the primary two dimensions for each observation for the process of clustering. The DBSCAN algorithm takes two main parameters for clustering a set of observations:ϵ and Min Samples. We note that ϵ is the maximum Euclidean distance for an observation from the closest point in the cluster in question. The Min Samples parameter is the least number of observations possible in the clustering algorithm. Thus, the tuning and selection of these parameters become essential to obtain proper and efficient results.Table2 summarizes the conditions tested for the quality and effectiveness of clustering with the said parameters. For each value of ϵ, two values of Min Samples are tested to validate the clustering effectiveness and detecting outliers in the data. For the ϵ values 0.2 and 0.175, the number of clusters for both 1 and 2 Min Samples stay constant at 7. This constant value for the generated number of clusters for both the Min Samples indicates that there are no outliers in the data, and each observation in the cluster holds a strong relationship with each other. Since the number of clusters for both the epsilon values are the same, it is evident that the clusters are locally isolated. For the ϵ values 0.150 and 0.100, the number of clusters changes drastically indicating weak clustering among the observations. The change in number of clusters for different Min Samples is proof that there are outliers in the data which can cause issues while performing the genetic optimization due to the lack of population. The parameters can therefore be safely assigned either of the four combinations to obtain 7 distinct clusters, as shown in Figure 2. The number of observations in each cluster is plotted in Figure 3.Table 2
DBSCAN clustering parameters and outcomes.
ϵMin samplesNumber of clusters0.20017270.17517270.15018270.100115218Figure 2
Clustering of client devices based on the learning rate and batch size by using DBSCAN algorithm.Figure 3
Number of observations in each cluster.


### 4.2. Performance of the Genetic CFL Architecture on MNIST Dataset

In this section, we discuss the performance and analyse the training curves of the models. The server model is initially trained on a subset of the MNIST handwritten digits’ dataset [29]. This model is then distributed among the clients based on the client ratio. The total number of clients chosen for this experiment is 100 and the client ratios tested for are 0.1, 0.15, and 0.3. In essence, we evaluate the performance of the models on 10, 15, and 30 clients, respectively. Each client device is provided with a random subset of the dataset with a random number of observations. This is to make sure that the data is non-IID, and the characteristics of the real-time scenario is emulated. For the initial round, the hyperparameters (learning rate and batch size) of the client devices are randomized within intervals (4) and (5), respectively. The client devices are trained for two epochs and the hyperparameters are subjected to genetic evolution as discussed in Section 3. These rounds are tabulated in Table 3, and the best performance is plotted against each round in Figure 4.Table 3
Performance of FL against genetic CFL on MNIST dataset for various hyperparameters.
Client ratioRoundsFLGenetic CFLAccuracyLossAccuracyLoss0.130.91330.31360.96790.120360.92650.24930.97300.1343100.93670.21150.97770.19230.1530.91760.28780.96650.104960.97400.08760.97400.0876100.94430.18280.97630.09100.330.91780.29890.96980.096460.93260.23590.97800.0804100.94500.19460.97990.0849Figure 4
Roundwise performance of the FL architecture compared with genetic CFL architecture on MNIST handwritten digit dataset.Since the model training hyperparameters are no longer predetermined, the performance of the models and their respective training are optimized locally in the cluster, thus providing a more personalized training for each cluster. The performance of the server model obtains a smooth learning curve and converges faster than the normal training of the model using FL. Table3 represents this performance of the models for both the architectures. The superiority of performance of genetic CFL over generic FL is evident for each round. The accuracy of the genetic CFL architecture is consistently higher and the loss is consistently lower as compared to the generic FL architecture. The increase in accuracy and the decrease in loss signify that the models are indeed training and useful information is aggregated at the server.


### 4.3. Performance of the Genetic CFL Architecture on CIFAR-10 Dataset

This section deals with the performance and the training of the models on CIFAR-10 dataset [30] using genetic CFL architecture and its comparison with the performance of the generic FL architecture. The training process of this dataset is similar to the training of the MNIST handwritten digits’ dataset. The server initializes the model and distributes the weights of the server model to every client device; the models are trained on the random subset of the dataset assigned for two epochs; the current hyperparameters are subjected to genetic evolution; the trained weights are sent back to the server to get aggregated. This process is repeated for several rounds. The performance of the server model after each round, at the end of the aggregation phase, is plotted in Figure 5 and tabulated in Table 4.Figure 5
Roundwise performance of the FL architecture compared with genetic CFL architecture on CIFAR-10 dataset.Table 4
Performance of FL against genetic CFL on CIFAR-10 dataset for various hyperparameters.
Client ratioRoundsFLGenetic CFLAccuracyLossAccuracyLoss0.1030.68180.95400.65141.009760.68911.37460.66391.3447100.68621.66170.65991.64490.1530.69730.96120.70980.881460.69881.36750.71991.693100.69521.62250.71291.38060.3030.75780.87080.76880.781860.76341.08910.76460.981100.76131.29640.76231.2961The performance of the models trained on the hyperparameters that are optimized using genetic algorithm for the respective clusters is higher than those that are not. This performance is consistent with any number of client devices. The performance also improves as the client ratio increases. The lowest loss is encountered at the second round for client ratio 0.3. The accuracy however peaks at the fourth epoch with a decent amount of loss for prediction. Any further training of the models does not provide better performance causing overfitting. The training of the models is stopped at round two. The aggregated model therefore provides a significant performance boost for very few rounds. This provides speed and high throughput while deployment in a real-time system.


### 4.4. Performance Analysis of Genetic CFL

The genetic CFL algorithm performs better with a higher sample size. Higher number of observations per cluster should therefore improve the optimization of the hyperparameters. However, taking into consideration the diversity of datasets both in the data characteristics and the number of data points, proper clustering of similar scenarios should provide higher throughput for the models individually. This calls for a balance between the number of clusters and the size of the cluster. A proper balance can ensure that the performance of the models in the federated architecture provides the best output in the given scenario. In a real-time application, the amount of edge devices expected is higher as compared to a synthetic environment. Following the progression of the performance, the higher number of total clients increases the performance significantly. The optimization of the hyperparameters using genetic CFL provides higher throughput for comparatively less number of rounds.Our architecture, genetic CFL, outperforms both algorithms [31, 32] in accuracy and rounds. This holds up the fact that genetic CFL architecture performs better while taking less number of rounds. In case of iterative clustering [16], our architecture outperforms in the case of MNIST dataset but does not in the case of the CIFAR-10 data. This behavior is attributed to the rotation and augmentation of data. This gives an upper hand in better feature extraction and representation. Genetic optimization provides an elastic and adaptive framework for optimization of the hyperparameters. This flexibility gives the architecture an edge over other methods by adapting to the dataset and the required environment. Most of the other types of architectures need to perform hyperparameter tuning beforehand and thus requiring manual intervention. This causes the system to be reset and a different set of parameters for a different type of data and application. This rigidity can cost both time and resources. Moreover, importance to every single client is given, thus affecting not only the server model performance but also the performance of every single client device. A better delivery of service for each and every client device is ensured while increasing the performance of the server model as a whole. Table 5 shows the comparison between the performance of our architecture, genetic CFL, with other architectures that incorporate clustering in federated learning. The table consists of the best accuracy of the models on the MNIST handwritten digits’ dataset and the CIFAR-10 dataset for a given number of rounds. It is evident that the number of rounds taken is significantly less keeping the accuracy higher.Table 5
Performance comparison.
AlgorithmRoundsMNISTCIFAR-10Genetic CFL1097.9976.88Byzantine robustness of CFL [31]20097.475.3FedZip [32]2098.03—Iterative federated clustering [16]—95.2581.51


## 4.1. DBSCAN Clustering of the Client Models

The DBSCAN algorithm, as discussed in the previous section, focuses on the Euclidean distance between the observations to calculate the density and cluster the observations based on this density. The models in each edge device are assigned a particular learning rate and batch size for training. These two hyperparameters serve as the primary two dimensions for each observation for the process of clustering. The DBSCAN algorithm takes two main parameters for clustering a set of observations:ϵ and Min Samples. We note that ϵ is the maximum Euclidean distance for an observation from the closest point in the cluster in question. The Min Samples parameter is the least number of observations possible in the clustering algorithm. Thus, the tuning and selection of these parameters become essential to obtain proper and efficient results.Table2 summarizes the conditions tested for the quality and effectiveness of clustering with the said parameters. For each value of ϵ, two values of Min Samples are tested to validate the clustering effectiveness and detecting outliers in the data. For the ϵ values 0.2 and 0.175, the number of clusters for both 1 and 2 Min Samples stay constant at 7. This constant value for the generated number of clusters for both the Min Samples indicates that there are no outliers in the data, and each observation in the cluster holds a strong relationship with each other. Since the number of clusters for both the epsilon values are the same, it is evident that the clusters are locally isolated. For the ϵ values 0.150 and 0.100, the number of clusters changes drastically indicating weak clustering among the observations. The change in number of clusters for different Min Samples is proof that there are outliers in the data which can cause issues while performing the genetic optimization due to the lack of population. The parameters can therefore be safely assigned either of the four combinations to obtain 7 distinct clusters, as shown in Figure 2. The number of observations in each cluster is plotted in Figure 3.Table 2
DBSCAN clustering parameters and outcomes.
ϵMin samplesNumber of clusters0.20017270.17517270.15018270.100115218Figure 2
Clustering of client devices based on the learning rate and batch size by using DBSCAN algorithm.Figure 3
Number of observations in each cluster.


## 4.2. Performance of the Genetic CFL Architecture on MNIST Dataset

In this section, we discuss the performance and analyse the training curves of the models. The server model is initially trained on a subset of the MNIST handwritten digits’ dataset [29]. This model is then distributed among the clients based on the client ratio. The total number of clients chosen for this experiment is 100 and the client ratios tested for are 0.1, 0.15, and 0.3. In essence, we evaluate the performance of the models on 10, 15, and 30 clients, respectively. Each client device is provided with a random subset of the dataset with a random number of observations. This is to make sure that the data is non-IID, and the characteristics of the real-time scenario is emulated. For the initial round, the hyperparameters (learning rate and batch size) of the client devices are randomized within intervals (4) and (5), respectively. The client devices are trained for two epochs and the hyperparameters are subjected to genetic evolution as discussed in Section 3. These rounds are tabulated in Table 3, and the best performance is plotted against each round in Figure 4.Table 3
Performance of FL against genetic CFL on MNIST dataset for various hyperparameters.
Client ratioRoundsFLGenetic CFLAccuracyLossAccuracyLoss0.130.91330.31360.96790.120360.92650.24930.97300.1343100.93670.21150.97770.19230.1530.91760.28780.96650.104960.97400.08760.97400.0876100.94430.18280.97630.09100.330.91780.29890.96980.096460.93260.23590.97800.0804100.94500.19460.97990.0849Figure 4
Roundwise performance of the FL architecture compared with genetic CFL architecture on MNIST handwritten digit dataset.Since the model training hyperparameters are no longer predetermined, the performance of the models and their respective training are optimized locally in the cluster, thus providing a more personalized training for each cluster. The performance of the server model obtains a smooth learning curve and converges faster than the normal training of the model using FL. Table3 represents this performance of the models for both the architectures. The superiority of performance of genetic CFL over generic FL is evident for each round. The accuracy of the genetic CFL architecture is consistently higher and the loss is consistently lower as compared to the generic FL architecture. The increase in accuracy and the decrease in loss signify that the models are indeed training and useful information is aggregated at the server.


## 4.3. Performance of the Genetic CFL Architecture on CIFAR-10 Dataset

This section deals with the performance and the training of the models on CIFAR-10 dataset [30] using genetic CFL architecture and its comparison with the performance of the generic FL architecture. The training process of this dataset is similar to the training of the MNIST handwritten digits’ dataset. The server initializes the model and distributes the weights of the server model to every client device; the models are trained on the random subset of the dataset assigned for two epochs; the current hyperparameters are subjected to genetic evolution; the trained weights are sent back to the server to get aggregated. This process is repeated for several rounds. The performance of the server model after each round, at the end of the aggregation phase, is plotted in Figure 5 and tabulated in Table 4.Figure 5
Roundwise performance of the FL architecture compared with genetic CFL architecture on CIFAR-10 dataset.Table 4
Performance of FL against genetic CFL on CIFAR-10 dataset for various hyperparameters.
Client ratioRoundsFLGenetic CFLAccuracyLossAccuracyLoss0.1030.68180.95400.65141.009760.68911.37460.66391.3447100.68621.66170.65991.64490.1530.69730.96120.70980.881460.69881.36750.71991.693100.69521.62250.71291.38060.3030.75780.87080.76880.781860.76341.08910.76460.981100.76131.29640.76231.2961The performance of the models trained on the hyperparameters that are optimized using genetic algorithm for the respective clusters is higher than those that are not. This performance is consistent with any number of client devices. The performance also improves as the client ratio increases. The lowest loss is encountered at the second round for client ratio 0.3. The accuracy however peaks at the fourth epoch with a decent amount of loss for prediction. Any further training of the models does not provide better performance causing overfitting. The training of the models is stopped at round two. The aggregated model therefore provides a significant performance boost for very few rounds. This provides speed and high throughput while deployment in a real-time system.


## 4.4. Performance Analysis of Genetic CFL

The genetic CFL algorithm performs better with a higher sample size. Higher number of observations per cluster should therefore improve the optimization of the hyperparameters. However, taking into consideration the diversity of datasets both in the data characteristics and the number of data points, proper clustering of similar scenarios should provide higher throughput for the models individually. This calls for a balance between the number of clusters and the size of the cluster. A proper balance can ensure that the performance of the models in the federated architecture provides the best output in the given scenario. In a real-time application, the amount of edge devices expected is higher as compared to a synthetic environment. Following the progression of the performance, the higher number of total clients increases the performance significantly. The optimization of the hyperparameters using genetic CFL provides higher throughput for comparatively less number of rounds.Our architecture, genetic CFL, outperforms both algorithms [31, 32] in accuracy and rounds. This holds up the fact that genetic CFL architecture performs better while taking less number of rounds. In case of iterative clustering [16], our architecture outperforms in the case of MNIST dataset but does not in the case of the CIFAR-10 data. This behavior is attributed to the rotation and augmentation of data. This gives an upper hand in better feature extraction and representation. Genetic optimization provides an elastic and adaptive framework for optimization of the hyperparameters. This flexibility gives the architecture an edge over other methods by adapting to the dataset and the required environment. Most of the other types of architectures need to perform hyperparameter tuning beforehand and thus requiring manual intervention. This causes the system to be reset and a different set of parameters for a different type of data and application. This rigidity can cost both time and resources. Moreover, importance to every single client is given, thus affecting not only the server model performance but also the performance of every single client device. A better delivery of service for each and every client device is ensured while increasing the performance of the server model as a whole. Table 5 shows the comparison between the performance of our architecture, genetic CFL, with other architectures that incorporate clustering in federated learning. The table consists of the best accuracy of the models on the MNIST handwritten digits’ dataset and the CIFAR-10 dataset for a given number of rounds. It is evident that the number of rounds taken is significantly less keeping the accuracy higher.Table 5
Performance comparison.
AlgorithmRoundsMNISTCIFAR-10Genetic CFL1097.9976.88Byzantine robustness of CFL [31]20097.475.3FedZip [32]2098.03—Iterative federated clustering [16]—95.2581.51


## 5. Conclusion

In this work, we have applied the genetic evolutionary algorithm to optimize the hyperparameters—learning rate and batch size—during the training of the individual end device models in a cluster for the FL architecture. We have identified and filled the gaps in the existing techniques and contributed algorithm of the genetic CFL architecture. This architecture has been tested using MNIST handwritten digits’ dataset and CIFAR-10 dataset. An accuracy of 97.99% and 76.88% has been, respectively, achieved on the datasets. We discussed and analysed the observations and the performance of the genetic CFL architecture. We have also covered the favourable conditions and the limitations for the algorithm to provide the best performance in deployment. The overall performance of the models display significant rise in efficiency while reducing communication and computation cost.As part of the future work, the amount of clients and the client ratio can be scaled into larger samples closely mimicking the real-time situation due to the high scalability of the model. As the population sample increases, the optimization of the hyperparameters gets more efficient thus delivering higher throughput in the real-time scenario. The type of data processed is not limited, and this architecture can be used for various scenarios such as natural language processing tasks, image classification tasks, and recommendation systems. Genetic CFL can also be integrated with time sensitive systems to deliver better performance in very less number of rounds.



---

*Source: 7156420-2021-11-18.xml*