# A Hierarchical Federated Learning Algorithm Based on Time Aggregation in Edge Computing Environment
## 3 Dynamic Weighted Hierarchical Federated Learning Algorithm
### Hierarchical Federated Learning Algorithm  
#### 3.3.1. Hierarchical Federated Learning Architecture  
With the introduction of edge servers, the \"cloud-edge-end\" hierarchical federated learning architecture consists of three layers: device, edge, and service layers. The device layer comprises multiple user terminal devices, which are usually heterogeneous, and each client device gathers and stores a large amount of user data. The edge layer comprises multiple edge servers, which serve as intermediaries for communication between client devices and the central server. Their main function is to transfer model information and aggregate the local model parameters produced in this area one step ahead. As the top layer of the entire hierarchical architecture, the service layer is mainly responsible for distributing and updating the global model. The overall architecture of hierarchical federated learning is illustrated in Figure 2.  
Compared with the conventional federated learning training process, the edge-oriented federated learning training process adds an edge aggregation step, which increases the computational time. However, by introducing the edge layer, the number of model transmissions has been reduced. The introduction of the edge layer also enables partial model aggregation to be performed at the edge layer. Furthermore, because the communication overhead in FL is much higher than the computing overhead, and because the edge server has higher computing power, the \"cloud-edge-end\" hierarchical federated learning architecture.  
Figure 1: Schematic diagram of model dispersion change.  
Figure 2: Hierarchical federated learning architecture.  
ture still improves the overall performance. The training process of hierarchical federated learning can be summarized as follows:  
1. Model initialization: The central server initializes the global model parameters.
2. Global model distribution: The central server communicates the global model parameters to each edge server.
3. Global model forwarding: Each edge server receives the global model parameters, selects participating client devices, and sends them the global model parameters for the current round.
4. Local update: Participating clients use local data, along with the received global model parameters, to locally train and optimize the local model.
5. Local model parameters upload: Participating clients upload their trained local model parameters to the corresponding edge server.
6. Edge aggregation: The edge server receives local model parameters from various clients and aggregates them to obtain the edge aggregation model.
7. Global aggregation: After all edge servers have completed edge aggregation, the central server receives all edge aggregation model parameters for the final integration.
8. Global model update: The central server updates the global model parameters according to the aggregated model parameters for the next round of global training.  
Steps 2-8 are repeated until the maximum number of global iterations is reached.  
In this study, we assume that the hierarchical federated learning architecture consists of \(N\) client devices, \(M\) edge servers, and a central server. The model's training process can be summarized into three parts: local training, edge aggregation, and global aggregation.