# FLGQM: Robust Federated Learning Based on Geometric and Qualitative Metrics
## 2 Materials and Methods
### Flgom
#### 2.2.2 Aggregation Rule
Our quality metrics have a good advantage over current defense approaches that directly utilize small datasets from the server for quality metrics of local models. Firstly, we abandon the practice of centralizing the data in the server and delegate the quality metrics to the clients, which better satisfies the principle of federated learning. Secondly, our quality metrics are distributed across multiple clients, which provides better fault tolerance and accuracy than utilizing a central dataset for evaluation. **Aggregation**. We first define the composite metric score (\(CMS\)) of the local model \(w^{t}_{m}\), which is a combination of the geometry and quality metric scores. \[CMS_{m}=GMS_{m}+QMS_{m} \tag{9}\]  
Then, we calculate the global model by weighted averaging the local model, where the weights are determined based on the composite metric scores. \[w^{t}=\frac{1}{\sum_{i=1}^{M}CMS_{i}}\sum_{i=1}^{M}CMS_{i}\cdot w^{t}_{i} \tag{10}\]Algorithm 1 describes the complete FLGQM algorithm. Through the above process, we can obtain a more robust global model. ```
1:Input: Clients' total number \(K\), the client set \(C\), train clients' total number \(P\), union clients' total number \(H\), communication rounds' total number \(T\), local epochs' total number \(E\), the minibatch size \(b\). 2:Input: Global model \(w\)
3:Server executes:
4:for\(t\in\{1,2,\cdots,T\}\)do
5:// The server randomly selects clients and distributes the gobal model. 6:client(C) executes:
7:for\(p\in\{1,2,\cdots,P\}\) in parallel do
8:\(w_{p}^{t}\gets ClientUpdate(p,w^{t-1})\)
9: send \(w_{p}^{t}\) to server
10:end
11:for\(p\in\{1,2,\cdots,P\}\)do
12:\(cs_{p}= \begin{cases}0,\ \ Cos(w_{p}^{t-1},w_{p}^{t})<0,\\ 1,\ \ Cos(w_{p}^{t-1},w_{p}^{t})\geq 0\end{cases} \)
13:end
14:// Reject models with a value of 0. The remaining client set is \(C^{t_{1}}=c_{1},\ldots,c_{l},\ldots c_{L}\subseteq C^{t},L\leq P\). 15:for\(l\in\{1,2,\cdots,L\}\)do
16:\(cg_{l}=ReLU\big{(}Cos\big{(}w_{l}^{t},w^{t-1}\big{)}\big{)}\)
17:end
18:// Reject models with a value of 0. The remaining client set is \(C^{t_{2}}=\{c_{1},\ldots,c_{m},\ldots,c_{M}\}\subseteq C^{t_{1}},M\leq L\). 19:for\(m\in\{1,2,\cdots,M\}\)do
20:\(GMS_{m}^{t}=cg_{m}\cdot EDAS\big{(}w_{m}^{t},w^{t-1}\big{)}\)
21:end
22:// The server randomly samples \(H\) clients from \(C^{noin}=C-C^{t}\), and forms a union set \(U^{t}\). 23:// The server sends the set \(W_{goodInGeo}=w_{1}^{t},\ldots,w_{m}^{t},\ldots,w_{M}^{t}\) to union clients. 24:client(\(U^{t}\)) executes:
25:for\(h\in\{1,2,\cdots,H\}\) in parallel do
26:for\(m\in\{1,2,\cdots,M\}\)do
27:\(sv_{h}^{m}\leftarrow\)accuracy in dataset \(\mathbb{D}_{h}\)
28:end
29:\(UCS_{h}^{t}\leftarrow[sv_{h}^{1},\ldots,sv_{h}^{m},\ldots,sv_{h}^{M}]\)
30:send \(UCS_{h}^{t}\) to server
31:end
32:for\(m\in\{1,2,\cdots,M\}\)do
33:\(TCS_{m}^{t}=[sv_{1}^{m},\ldots,sv_{h}^{m},\ldots,sv_{H}^{m}]\)
34:\(sv^{m}=\frac{1}{1-2\beta H}\sum_{x\in TCS_{m}^{\beta}}x\)
35:\(QMS_{m}^{t}=\frac{1}{log\big{(}\frac{1}{\beta\omega}\big{)}}\)
36:\(MS_{m}^{t}=MMS_{m}^{t}+QMS_{m}^{t}\)
37:end
38:aggregation \(w^{t}=\frac{1}{\sum_{i=1}^{M}{\rm MS}_{i}}\sum_{i=1}^{M}MS_{i}\cdot w_{i}^{t}\)
39:end
```  
**Algorithm 1** FLGQM.