Algorithm 1 Federated learning with Selective Forwarding Attack Detection. |
-
1:
Input: Local datasets for each CPS node
-
2:
Output: Global Model
-
3:
Initialization:
-
4:
Set communication rounds T, local models M, learning rate , aggregation method
-
5:
Initialize global model
-
6:
Fog Layer Processing:
-
7:
for to T do
-
8:
Receive local models from CPS nodes:
-
9:
Aggregate models:
-
10:
Broadcast global model to all CPS nodes
-
11:
end for
-
12:
CPS Layer for Local Model Training:
-
13:
for to n do
-
14:
Initialize local model
-
15:
for to T do
-
16:
Receive global model
-
17:
Train local model using KNN, LR, SVM, NB
-
18:
Transmit local model to Fog layer
-
19:
end for
-
20:
end for
-
21:
Final Aggregation:
-
22:
Finalize the global model
|