# Federated Learning-Based Service Caching in Multi-Access Edge Computing System
## 4 Proposed Service Caching Framework
### FL-Based Service Popularity Score
#### 4.2.1 Distributed Training Phase  
The training process for each operational round is shown in Figure 3. The system performs five steps to train the model effectively. These steps include data preprocessing, local model training, transmission of the local model to the cloud server, aggregation of the global model, and sending the global model to the MEC servers. (1) Data Preprocessing: Initially, the servers of the MEC system gather data on service requests from all users involved within their coverage area during each operation time slot. The dataset comprises unique user identification numbers, geographical coordinates, and specific services requested by the users. Figure 3: FL-based Service Caching Training Phase. Figure 2: Workflow of SCFL of each MEC server. As stated in the previous section, \(S_{all}\) denotes the total number of services the system offers. During each user time slot, individual users initiate requests for multiple types of services. Hence, the query data of the user \(u\) at \(t_{u}\) can be denoted by a one-dimensional matrix in the following format:  
\[R_{u}(t_{u})=[r_{1}(t_{u}),r_{2}(t_{u}),\ldots,r_{S_{all}}(t_{u})], \tag{5}\]  
where the binary variables \(r_{i}(t_{u})\in[0,1]\) indicate whether user \(u\) has requested service \(i\) in time slot \(u_{t}\). The data are gathered during each operation time slot of the training or inference phase. Hence, it is necessary to aggregate the user-request data throughout the whole duration of each operation time slot. Note that \(t_{m}\gg t_{u}\) indicates that each user can make multiple requests during each \(t_{m}\) period. \(R_{u}\) represents the request data of user \(u\) during operation time slot \(t_{m}\). Thus, \(R_{u}\in\mathbb{R}^{1\times S_{all}}\) can be determined as follows:  
\[R_{u}(t_{m})=\{\sum_{t_{u}\in t_{m}}r_{i}(t_{u}),1\leq i\leq S_{all}\}, \tag{6}\]  
The request data of all the users is merged into a 2-dimensional matrix using each MEC server. The matrix \(Q_{m}(t_{m})=[R_{1}(t_{m}),\ldots,R_{U}(t_{m})]\in\mathbb{R}^{U\times S_{all}}\) denotes the processed request data of MEC server \(m\) in \(t_{m}\). This matrix reflects the request characteristics of all users on each MEC server in each operation time slot. Hence, it can be efficiently used as an input during the training phase of deep learning neural networks. Figure 4 illustrates the data-preparation process. (2) Local Model Training: Following the data preprocessing, the MEC servers begin with the training of the local model. The structure of the AAE is shown in Figure 5. AAE comprises a typical AE component and a discriminator component inspired by Generative Adversarial Networks (GAN) [23]. Hence, in addition to the reconstruction loss inherited from AE, AAE also aims to minimize the regularization loss of GAN. Regularization loss reduction facilitates matching the latent representation \(\mathbf{z}\) with the prior distribution. Simultaneously, minimizing reconstruction helps the data generated from the latent space \(\mathbf{z}\), which is mapped to a prior distribution, to accurately reflect the characteristics of the input data. Figure 4: Process of data preparation on each MEC server at operation time slot \(t_{m}\). The data \(Q_{m}(t_{m})\in\mathbb{R}^{l\times S_{all}}\) serve as the dataset for the AAE model. Specifically, data samples \(R_{u}(t_{m})\in\mathbb{R}^{1\times S_{all}}\) are used as the input layer of the network, and the latent space \(\mathbf{z}\in\mathbb{R}^{1\times d_{z}}\) is the middle layer, where \(d_{z}\) is the dimension of the latent space. \(\mathbf{q}_{\phi}(\mathbf{z}|R_{u}(t_{m}))\) and \(\mathbf{p}_{\theta}(\hat{R}_{u}(t_{m})|\mathbf{z})\) are the probabilistic encoder and decoder of the AE model, respectively. The training phase of the AE guarantees that the conditional distribution \(\mathbf{q}_{\phi}(\mathbf{z}|R_{u}(t_{m}))\) effectively transforms the input data into the distribution \(\mathbf{p}(\mathbf{z})\) of the latent space.