A federated learning method based on spatial heterogeneity
Patent Information
- Application Number
- CN202410716690.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2026-10-09
- Estimated Expiration
- 2044-06-04
AI Technical Summary
当联邦学习被应用于POI推荐时,这种空间分布的偏差不可避免,这对模型的协同学习带来了挑战
[0068] ① Addressing Spatial Heterogeneity: While existing personalized federated learning methods have solved the personalization problem in non-independent identically distributed (non-IID) data environments, they have failed to handle the spatial heterogeneity in POI trajectory data. This invention proposes a simulation method for the spatial heterogeneity problem, effectively simulating the biased spatial distribution of trajectory data.
Smart Images

Figure CN118674013B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of big data technology, and in particular to a federated learning method based on spatial heterogeneity. Background Technology
[0002] In federated point-of-interest (POI) recommendation tasks, user trajectory data is generated based on their visits to specific POIs, naturally reflecting users' personalized access preferences across different geographic regions. This personalization leads to significant spatial differences and isolation in the trajectory data on local clients during collaborative training. This results in local training on local clients in federated learning only learning information within a limited geographic area, exhibiting weak learning ability for long sequences across regions. Spatial distribution bias has often been overlooked in previous personalized federated learning, but in fact, it plays a significant role in the recommendation quality of POI models.
[0003] For example, check-in patterns are likely to differ significantly between urban and suburban residents. This difference stems not only from geographical location but also from variations in the types and quantities of Points of Interest (POIs) available in different regions. When federated learning is applied to POI recommendation, this spatial distribution bias is unavoidable, posing a challenge to the collaborative learning of the model. Summary of the Invention
[0004] In view of the above-mentioned problems in the existing technology, the technical problem to be solved by the present invention is: how to effectively simulate the spatial heterogeneity in trajectory data, and further propose a method to effectively improve the personalized performance of the federated point of interest recommendation model in a spatially heterogeneous environment.
[0005] To solve the above-mentioned technical problems, the present invention adopts the following technical solution: a federated learning method based on spatial heterogeneity, comprising the following steps.
[0006] S1: Pre-trained spatiotemporal awareness adversarial generative network ST-GAN: Obtaining a real local dataset D i The generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN are trained on all local clients. The trained generator is denoted as {G(ω)}. i )|1≤i≤N},{G(ω i Let )|1≤i≤N} generate a pseudo trajectory dataset for the corresponding local client, and let be the pseudo trajectory dataset. G(ω) i Generate a pseudo trajectory dataset for the i-th local client.
[0007] All locally trained datasets G are uploaded to the server. The server aggregates all trained datasets G to obtain a global generator G(ω). The global generator is then used to generate a global pseudo-trajectory dataset Y. g .
[0008] S2: Local training: stitching together the real trajectory dataset Y i and pseudo-trajectory dataset Obtain the i-th local training dataset Y i P and using Y i P Training model θ on the i-th local client i The trained model is obtained after training t+1 times. N represents the number of local clients.
[0009] S3: Local Model Upload: Upload N locally trained models Uploaded to the server, the Global Knowledge Distillation module (GKD) uses Y g Fine-tuning the uploaded local model collection During fine-tuning, the global model θ obtained from t training iterations is used on the server. g As a teacher model, the local model trained at time t+1 will be used. As a student model, it learns global information from the teacher model to obtain a globalized local model.
[0010] S4: Global parameter aggregation: using Update the model on the server, and then on the server... Aggregation is performed to obtain the global model
[0011] S5: Parameter Update: This server will... The broadcast is sent back to all local clients, and on each local client, the personalized knowledge distillation module PKD uses Y. i P right Fine-tuning is performed, during which the server broadcasts the changes back to all local clients. As a student model, it will be on the local client. As a teacher model, the student model learns information from the teacher model to obtain a personalized global model.
[0012] S6: Model Update: Using Override on local client This updates the local model.
[0013] S7: Determine if the preset number of iterations has been reached. If not, return to S2; otherwise, use the current local model as the optimal local model and proceed to the next step.
[0014] S8: For a user, obtain the user's historical check-in trajectory and input the historical check-in trajectory into the optimal local model. The optimal local model outputs the Top-K points of interest as the recommendation results.
[0015] Furthermore, in S1, the pre-training process of ST-GAN is as follows:
[0016] First, the first M trajectories of user u in the i-th local client are segmented and represented as follows: X(u) is divided into POI sequences Timestamp sequence Latitude and Longitude Sequence Then, these three sequences are fed together into the generator G for pre-training, where the optimization objective of G is Equation (2).
[0017]
[0018] Where H is the batch size, P G It is based on the probability of samples generated by generator G, L G (ω) is the loss function for generator training. Let these represent the labels of the j-th sample in the i-th batch and the labels of the first to (j-1)-th samples in the i-th batch, respectively. The generator calculates... and and The loss is then weighted to obtain the multidimensional input sequence Y of X(u). 1:M =(y1,…,y m ,…,y M ) loss.
[0019] The parameters ω of the generator G are updated iteratively using the gradient descent method, as shown in Equation (3).
[0020]
[0021] Where α represents the learning rate hyperparameter, and This represents the gradient of the loss function with respect to the parameter ω.
[0022] The pre-trained generator G produces pseudo sequences. Compared with the true sequence Y 1:M =(y1,…,y m ,…,y M Together, they are used to train the discriminator D. The goal of training the discriminator is to correctly distinguish between the pseudo-sequences generated by G and the real sequences. D is trained using binary cross-entropy loss, as shown in Equation (4):
[0023]
[0024] Where N pos N is the number of true sequences. neg N is the number of pseudo-sequences generated by G during training. pos =N neg =M. y i This represents the i-th real sequence. Let i represent the i-th pseudo-sequence.
[0025] The optimization objective of D is expressed as formula (5).
[0026]
[0027] in, Indicates that it comes from the real data distribution P pos The expected value of Y, a set of real training samples sampled from the dataset. A sample refers to a set of sequences of real data. Then it represents the set of negative samples generated by G. The expected value of D. During the actual training of the discriminator, the objective function shown in equation (5) is minimized iteratively to update the parameters of D. As shown in formula (6):
[0028]
[0029] in, This represents the loss function of the discriminator. This represents the parameters on it. This represents the loss function with respect to parameters. The gradient.
[0030] After the generator G and discriminator D are pre-trained, they undergo adversarial training. Adversarial training uses the policy gradient method derived from reinforcement learning.
[0031] Through time step m-1, state s m-1 The generated sequence The next action 'a' determines which POI point to generate at the next time step 'm', in order to determine the sequence. The corresponding state becomes s m This process continues until a complete pseudo-sequence is achieved. The generated sequence is scored as a reward r; if the generated sequence successfully fools D, r is 1, otherwise, if it is identified as generated, the score is 0. The optimization objective of adversarial training is to maximize the expected reward E of the generator G, as shown in Equation (7):
[0032]
[0033] Among them, RM It is the cumulative reward of the pseudo-sequence or the real sequence, s m-1 This represents the state at step m-1. This is the item generated in step m. Q is the action value.
[0034] Drawing inspiration from reinforcement learning methods, the true probability estimated by the discriminator is used as the reward, and the action value is calculated using formula (8):
[0035]
[0036] Among them, y M This represents the data point generated in step M, while This represents the sequence of data points generated in the previous 1 to M-1 steps.
[0037] The generator G will be further retrained, as shown in Equation (9).
[0038]
[0039] in, It is an intermediate state observed by sampling from G. This represents an intermediate state relative to the sampled state from the generator G. The expected value is calculated, J(ω), which represents the loss function. Since the expected value E can be approximated by sampling, the generator parameters are updated according to formula (10).
[0040]
[0041] Where, η m It is the learning rate at step m.
[0042] Furthermore, in S2, the server processes {G(ω)} i The process of aggregating |1≤i≤N} to obtain the global generator G(ω) is as follows:
[0043] The generator of the ST-GAN model deployed on all local clients {G(ω i After pre-training on the local client, )|1≤i≤N} is uploaded to the server for aggregation to obtain a global generator G(ω), as shown in formula (11).
[0044] On the server, {ω i The global generator parameter ω is obtained by aggregating |1≤i≤N}, as shown in formula (11):
[0045]
[0046] Among them, c i Y represents iP The number of trajectory points determines the weight of local client parameters during the aggregation process.
[0047] Furthermore, in S3, the Global Knowledge Distillation (GKD) module uses Y g The process of fine-tuning the global POI recommendation model t times is as follows:
[0048] In GKD, the global model θ obtained from t training iterations is stored on the server. g Treated as a teacher model, the model obtained after t+1 training iterations on the local client. Treating it as a student model, θ is calculated using KL divergence. g and The difference between them is shown in formula (16):
[0049]
[0050] Among them, SO G andTO G These are inputs from Y g The outputs of the student model and the teacher model after sampling positive samples, SN g and TN g These are inputs from Y g These are the outputs of the student and teacher models after negative samples. B represents the batch size, and D... KL This represents the KL divergence. It is the objective function or loss function. T is the temperature parameter.
[0051] In GKD, the student model uses L gkd To fine-tune its parameters to learn more global information and obtain As shown in formulas (17) and (18).
[0052]
[0053]
[0054] Among them, L gkd It is the complete GKD loss function, combined with the KL loss function. and cross-entropy loss function λ is control and Hyperparameters of relative importance.
[0055] Furthermore, in S4, the server will perform... Aggregation is performed to obtain the global model The process is shown in formula (19):
[0056]
[0057] Furthermore, in S5, the personalized knowledge distillation module PKD uses Y i P right The process of fine-tuning is as follows:
[0058] Before the global model is implemented on local clients, the server is broadcast back to all local clients. As a student model, it will be on the local client. As a teacher model, using Y i P Fine-tune the teacher model as shown in formula (12):
[0059]
[0060] Where, N pos From Y i P The number of positive samples collected, N neg It is the number of negative samples randomly collected from POIs not visited by the user; σ(·) is the sigmoid function, where α i and α j These are the scores calculated for positive and negative samples, respectively, L. bce This represents the cross-entropy loss function used in the POI model training process.
[0061] Calculation using KL divergence and The difference between them is shown in formula (13):
[0062]
[0063] L pkd =μ·L kl +(1-μ)·L bce (14)
[0064] Among them, SO P andTO P These are inputs from Y i P The outputs of the student model and the teacher model after positive samples, SN P and TN P These are inputs from Y i P These are the outputs of the student and teacher models after negative samples, where μ is a variable controlling the effect of distillation loss. pkd It is the complete PKD loss function, combined with the KL loss function L. kl and cross-entropy loss function L bceμ is the control of L kl and L bce Hyperparameters of relative importance.
[0065] After PKD fine-tuning, the global model obtains richer personalized information, as shown in formula (15):
[0066]
[0067] Compared with the prior art, the present invention has at least the following advantages:
[0068] ① Addressing Spatial Heterogeneity: While existing personalized federated learning methods have solved the personalization problem in non-independent identically distributed (non-IID) data environments, they have failed to handle the spatial heterogeneity in POI trajectory data. This invention proposes a simulation method for the spatial heterogeneity problem, effectively simulating the biased spatial distribution of trajectory data.
[0069] ② Introducing ST-GAN to generate synthetic trajectory data: By generating a large amount of diverse synthetic trajectory data, the quantity and diversity of training data are expanded, thereby improving the personalized performance of the POI recommendation model.
[0070] ③ The PKD and GKD modules enhance the learning and retention of personalized and global information: During the parameter update process, these modules effectively enhance the learning and retention of personalized and global information, improving the model's performance in spatially heterogeneous environments.
[0071] ④ Significantly Improved Model Performance: Through comparative experiments with eight personalized federated learning methods and testing on four real-world datasets, the FedKG method of this invention significantly outperforms existing methods in both non-independent and identically distributed (i.i.d.) and spatially heterogeneous environments. Under spatially heterogeneous conditions, performance is improved by 18.21%; under non-independent and identically distributed (i.i.d.) conditions, performance is improved by 7.59%. Attached Figure Description
[0072] Figure 1 This is a visualization of the heterogeneity in data volume and spatial distribution within the TKY dataset.
[0073] Figure 2 This is a flowchart of ST-GAN.
[0074] Figure 3 PKD module for personalized knowledge distillation.
[0075] Figure 4 The GKD module is used for global knowledge distillation.
[0076] Figure 5 Performance curves of different methods on four datasets under spatially heterogeneous settings.
[0077] Figure 6 This is a visualization of how spatial heterogeneity gradually intensifies as the number of local clients increases.
[0078] Figure 7 The performance improvement graph shows the application of various modules from FedKG to the FedAdam method. Detailed Implementation
[0079] The present invention will be further described in detail below. The local model and the global model in the present invention are both existing POI recommendation models.
[0080] The present invention defines the spatial heterogeneity existing in local client data under federated learning as follows.
[0081] Definition 1 "Spatial Heterogeneity": Let C = {c1, c2, ..., c N Let} represent the set of local clients distributed in a two-dimensional geographic space, where N is the total number of local clients. Each local client c n In coordinates (x n ,y n Collect the corresponding POI trajectory dataset D at ) n For any two local clients c m and c n The spatial heterogeneity between them can be quantified by the Euclidean distance between them, denoted by H. s (C) is used to measure the spatial heterogeneity of the local client set, as shown in formula (1).
[0082]
[0083] In the real world, local client devices are deployed at specific coordinates to collect and learn trajectory data from surrounding Points of Interest (POIs). Therefore, a single local client only collects data from users in its vicinity. Data deployed on spatially distant local clients often exhibits significant spatial heterogeneity. This spatial heterogeneity reflects the geographically diverse distribution of different local clients in a federated learning environment. High spatial heterogeneity can lead to models performing well in some areas but poorly in others, exacerbating geographical unfairness.
[0084] To address the spatial heterogeneity problem, this invention first analyzes the spatial distribution characteristics of user check-in data and proposes a novel spatial heterogeneous data segmentation strategy to simulate real-world scenarios where local clients are segmented based on geographical location. To overcome the challenges posed by spatial heterogeneity, this invention proposes a Federated Generation Enhancement and Bidirectional Knowledge Transfer (FedKG) method. This method aims to mitigate the adverse effects of spatial heterogeneity on model performance, thereby improving the personalized recommendation performance of the model across different local clients. Then, this invention organizes a series of experiments, including comparative experiments, ablation studies, and data visualization, to demonstrate the effectiveness of the FedKG method.
[0085] To mitigate the impact of spatial heterogeneity on the personalized performance of federated interest point recommendation models, this invention designs a spatially heterogeneous federated learning method, FedKG. It comprises a spatiotemporally aware adversarial generative network (ST-GAN), a personalized knowledge distillation module (PKD), and a global knowledge distillation module (GKD). ST-GAN is a pseudo-data generation method that generates more diverse learnable samples for local training and subsequent PKD and GKD processes. PKD and GKD are deployed on the local client and server, respectively, to enhance the learning of personalized and global knowledge. The following sections will detail the components of FedKG.
[0086] A federated learning method based on spatial heterogeneity includes the following steps:
[0087] S1: Pre-trained spatiotemporal awareness adversarial generative network ST-GAN: Obtaining a real local dataset D i The generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN are trained on all local clients. The trained generator is denoted as {G(ω)}. i )|1≤i≤N},{G(ω i Let )|1≤i≤N} generate a pseudo trajectory dataset for the corresponding local client, and let be the pseudo trajectory dataset. G(ω) i Generate a pseudo trajectory dataset for the i-th local client.
[0088] All locally trained datasets G are uploaded to the server. The server aggregates all trained datasets G to obtain a global generator G(ω). The global generator is then used to generate a global pseudo-trajectory dataset Y. g .
[0089] S2: Local training: stitching together the real trajectory dataset Y i and pseudo-trajectory dataset Obtain the i-th local training dataset Y i P and using Y i PTraining model θ on the i-th local client i The trained model is obtained after training t+1 times. N represents the number of local clients.
[0090] S3: Local Model Upload: Upload N locally trained models Uploaded to the server, the Global Knowledge Distillation module (GKD) uses Y g Fine-tuning the uploaded local model collection During fine-tuning, the global model θ obtained from t training iterations is used on the server. g As a teacher model, the local model trained at time t+1 will be used. As a student model. Figure 4 As shown, the student model learns global information from the teacher model, resulting in a globalized local model.
[0091] S4: Global parameter aggregation: using Update the model on the server, and then on the server... Aggregation is performed to obtain the global model
[0092] S5: Parameter Update: This server will... The broadcast is sent back to all local clients, at which point the local clients have... and server broadcast On each local client, the personalized knowledge distillation module PKD uses Y i P right Fine-tuning is performed, during which the server broadcasts the changes back to all local clients. As a student model, it will be on the local client. As a teacher model, the student model learns information from the teacher model to obtain a personalized global model. .
[0093] S6: Model Update: Using Override on local client This updates the local model.
[0094] S7: Determine if the preset number of iterations has been reached. If not, return to S2; otherwise, use the current local model as the optimal local model and proceed to the next step.
[0095] S8: For a user, obtain the user's historical check-in trajectory and input the historical check-in trajectory into the optimal local model. The optimal local model outputs the Top-K points of interest as the recommendation results.
[0096] Specifically, in S1, the process of pre-training ST-GAN is as follows:
[0097] A spatiotemporally aware generative adversarial network called ST-GAN can learn the spatiotemporal distribution features of POI trajectories. (See...) Figure 2 Consistent with the basic principles of GANs, ST-GAN iteratively trains a generator model G and a discriminator model D. Then, the discriminator D evaluates the fake data generated by the generator G and provides feedback rewards, thereby adjusting the parameters internal to G. Ultimately, a sufficiently good generator G is obtained, capable of outputting pseudo-trajectory data that is indistinguishable from real ones.
[0098] First, the first M trajectories of user u in the i-th local client are segmented and represented as follows: X(u) is divided into POI sequences Timestamp sequence Latitude and Longitude Sequence Then, these three sequences are fed together into the generator G for pre-training, where the optimization objective of G is Equation (2).
[0099]
[0100] Where H is the batch size, P G It is based on the probability of samples generated by generator G, L G (ω) is the loss function for generator training. Let represent the label of the j-th sample in the i-th batch and the labels of the first to (j-1)-th samples in the i-th batch, respectively. The generator G is pre-trained using maximum likelihood estimation, attempting to minimize the probability difference between the predicted and true sequences. The generator calculates... and and The loss is then weighted to obtain the multidimensional input sequence Y of X(u). 1:M =(y1,…,y m ,…,y M ) loss.
[0101] In P G The method considers multidimensional features of POI, temporal and spatial sequences. The generation of each sequence depends on the preceding sequence, reflecting the spatiotemporal relationships in the trajectory data. This method captures the complex dependencies of multidimensional trajectory data and helps the generator learn to produce more realistic trajectory samples. The parameter ω of the generator G is iteratively updated using the gradient descent method, as shown in Equation (3).
[0102]
[0103] Where α represents the learning rate hyperparameter, and This represents the gradient of the loss function with respect to the parameter ω.
[0104] The pre-trained generator G produces pseudo sequences. Compared with the true sequence Y 1:M =(y1,…,y m ,…,y M Together, they are used to train the discriminator D. The goal of training the discriminator is to correctly distinguish between the pseudo-sequences generated by G and the real sequences. D is trained using binary cross-entropy loss, as shown in Equation (4):
[0105]
[0106] Where N pos N is the number of true sequences. neg N is the number of pseudo-sequences generated by G during training. pos =N neg =M. y i This represents the i-th real sequence. Let i represent the i-th pseudo-sequence.
[0107] For a real sequence, l=1 is used as its target label. The discriminator's output for a real sequence should be close to 1, while the output for a pseudo sequence should be the opposite. If a pseudo sequence is close enough to a real sequence, the discriminator will misclassify the pseudo sequence as real. The optimization objective of D is expressed as Equation (5).
[0108]
[0109] in, Indicates that it comes from the real data distribution P pos The expected value of the real training sample set Y sampled in the middle, where a sample refers to a set of sequences of real data. Then it represents the set of negative samples generated by G. The expected value of D. During the actual training of the discriminator, the objective function shown in equation (5) is minimized iteratively to update the parameters of D. As shown in formula (6):
[0110]
[0111] in This represents the loss function of the discriminator. This represents the parameters on it. This represents the loss function with respect to parameters. The gradient.
[0112] After the generator G and discriminator D are pre-trained, they undergo adversarial training. Adversarial training uses the policy gradient method derived from reinforcement learning.
[0113] Through time step m-1, state s m-1 The generated sequence The next action 'a' determines which POI point to generate at the next time step 'm', in order to determine the sequence. The corresponding state becomes s m This process continues until a complete pseudo-sequence is achieved. The generated sequence is scored as a reward r; if the generated sequence successfully fools D, r is 1, otherwise, if it is identified as generated, the score is 0. The optimization objective of adversarial training is to maximize the expected reward E of the generator G, as shown in Equation (7):
[0114]
[0115] Among them, R M It is the cumulative reward of the pseudo-sequence or the real sequence, s m-1 This represents the state at step m-1. This is the item generated in step m. Q is the action value, used to measure the value of taking a certain action in a given state. This represents a pseudo-sequence.
[0116] Drawing inspiration from reinforcement learning methods, the true probability estimated by the discriminator is used as the reward, and the action value is calculated using formula (8):
[0117]
[0118] Among them, y M This represents the data point generated in step M, while This represents the sequence of data points generated in the previous 1 to M-1 steps.
[0119] Equation (8) shows that the calculation of Q is based on the discriminator's input to the final sequence. This feedback ensures that G's data generation not only focuses on the appropriateness of previous sequences but also considers the overall quality of the final sequence, resulting in more realistic sequence data. After obtaining a stronger discriminator D, the generator G will be further retrained as shown in Equation (9).
[0120]
[0121] in, It is an intermediate state observed by sampling from G. This represents an intermediate state relative to the sampled state from the generator G. The expected value, J(ω), represents the loss function. The generator parameters are updated by optimizing J(ω), thereby improving the quality of the generated samples. Since the expected value E can be approximated by sampling methods, the generator parameters are updated according to formula (10).
[0122]
[0123] Where, η m It is the learning rate at step m.
[0124] Specifically, in S2, the server processes {G(ω)} i The process of aggregating |1≤i≤N} to obtain the global generator G(ω) is as follows:
[0125] The generator of the ST-GAN model deployed on all local clients {G(ω i After pre-training on the local client, )|1≤i≤N} is uploaded to the server for aggregation to obtain a global generator G(ω), as shown in formula (11).
[0126] After each local client completes the training of ST-GAN, the generator G will generate personalized pseudo-trajectories for the local client. These pseudo-trajectories This will be compared with the real trajectory data Y on the local client. i Connect them to form a personalized dataset The Y i P The dataset will be used for local training on the local client and for training the PKD module. Additionally, the generator parameter ω of the local client participating in training... i It will be sent to the server.
[0127] On the server, {ω i The global generator parameter ω is obtained by aggregating |1≤i≤N}, as shown in formula (11):
[0128]
[0129] Among them, c i Y represents i P The number of trajectory points determines the weight of local client parameters during the aggregation process.
[0130] The server will then use the global generator G(ω) to generate the global dataset Y. g This global data can reflect the behavioral preferences of all users and help the GKD module further enhance its ability to capture global information in federated learning.
[0131] Specifically, in S3, the Global Knowledge Distillation (GKD) module uses Y g The process of fine-tuning the global POI recommendation model t times is as follows:
[0132] A significant challenge in applying federated learning to POI recommendation is the lack of shared information among local clients. Some users may exhibit similar behavioral patterns, and this shared information can help local models learn missing content from their datasets. To enhance the model's ability to mine shared information and further capture global information, this invention proposes a global knowledge distillation module deployed on a server. Whenever a local client uploads its locally trained model... At that time, these models will not be used directly for aggregation, but will first be processed using GKD on the uploaded data. Fine-tuning allows for the learning of deeper global information; see the diagram for GKD. Figure 4 .
[0133] G(ω) aggregates the learning parameters of all local client generators and can generate a global pseudo-trajectory dataset Y that reflects shared behavioral information. g Y g It can be used to help local models learn global information. Unlike PKD, in GKD, the global model θ obtained from t training iterations is stored on the server. g Treated as a teacher model, the model obtained after t+1 training iterations on the local client. Treating it as a student model, θ is calculated using KL divergence. g and The differences between them facilitate the transfer of information from the teacher model to the student model, as shown in formula (16):
[0134]
[0135] Among them, SO G andTO G These are inputs from Y g The outputs of the student model and the teacher model after sampling positive samples, SN g and TN g These are inputs from Y g These are the outputs of the student and teacher models after negative sampling. Positive samples refer to POI data directly sampled from the dataset that the user has visited, while negative samples refer to a set of samples randomly sampled from POIs that the user has not visited. B represents the batch size, D... KL This represents the Kullback-Leibler divergence (KL divergence), which measures the distance between the differences between two probability distributions. It is the objective function or loss function. T is the temperature parameter, which is set manually to smooth the probability distribution.
[0136] In GKD, the student model uses L gkd To fine-tune its parameters to learn more global information and obtain As shown in formulas (17) and (18).
[0137]
[0138]
[0139] Among them, L gkd It is the complete GKD loss function, combined with the KL loss function. and cross-entropy loss function λ is control and Hyperparameters of relative importance.
[0140] After processing by the GKD module, the student model learns richer global behavioral patterns, enhancing its understanding of trajectory information across geographical regions. This is particularly important in scenarios with spatial heterogeneity, where local training on each local client can only learn the check-in preferences of nearby users. For trajectory data located far from the local client, the local client may not have sufficient learning opportunities. Introducing GKD provides each local client with the opportunity to learn global preferences.
[0141] Specifically, in S4, the server will perform... Aggregation is performed to obtain the global model The process is shown in formula (19):
[0142]
[0143] Specifically, in S5, the personalized knowledge distillation module PKD uses Y i P right The process of fine-tuning is as follows:
[0144] In POI recommendation tasks, each user's local trajectory reflects their personalized preferences. In federated learning, due to the limited number of local clients, it's difficult to allocate a local client device for each user during training. Therefore, personalized information is lost during federated learning communication, especially when the global model is transmitted back to the local client to overwrite the local model. Direct overwriting discards a significant amount of personalized information learned on the local model. Therefore, this invention designs a personalized knowledge distillation module to address the problem of personalized loss during model updates in federated learning, see [link to module]. Figure 3 .
[0145] The core idea of the PKD module is to leverage local models and personalized knowledge derived from local data to help the global model learn personalized information. Before the global model is implemented on local clients, the server broadcasts the information back to all local clients. As a student model, it will be on the local client. As a teacher model, using Y i P Fine-tune the teacher model as shown in formula (12):
[0146]
[0147] Where, N pos From Y i P The number of positive samples collected, N neg It is the number of negative samples randomly collected from POIs not visited by the user; positive samples refer to those directly collected from dataset Y. i P The sampled data refers to the POIs visited by the user, while the negative samples refer to a set of samples randomly sampled from POIs not visited by the user. This invention sets the number of negative samples to 100. σ(·) is the sigmoid function, where α i and α j These are the scores calculated for positive and negative samples, respectively, L. bce This represents the cross-entropy loss function used in the POI model training process.
[0148] Calculation using KL divergence and The difference between them is shown in formula (13):
[0149]
[0150] L pkd =μ·L kl +(1-μ)·L bce (14)
[0151] Among them, SO P andTO P These are inputs from Y i P The outputs of the student model and the teacher model after positive samples, SN P and TN P These are inputs from Y i P These are the outputs of the student and teacher models after negative samples, where μ is a variable controlling the effect of distillation loss. pkd It is the complete PKD loss function, combined with the KL loss function L. kl and cross-entropy loss function Lbce μ is the control of L kl and L bce Hyperparameters of relative importance.
[0152] After PKD fine-tuning, the global model obtains richer personalized information, as shown in formula (15):
[0153]
[0154] The global model, fine-tuned by PKD, learns personalized information from different local clients; this invention refers to it as a personalized global model. After that This will cover the local model on the local client. It also participates in the next round of local training, thereby enhancing the learning of personalized information during the model update process in federated learning.
[0155] Experimental Design and Analysis
[0156] 1. Dataset and Model
[0157] Table 1. Statistical information of the dataset used in the experiment.
[0158]
[0159]
[0160] This invention was tested on four real-world datasets, including two subsets of the Foursquare dataset (NYC and TKY), as well as Gowalla and Brightkite. Statistical information for the NYC, TKY, Gowalla, and Brightkite datasets is shown in Table 1. In the partitioning of non-independent and identically distributed data and spatial heterogeneity, this invention selected the top 100 trajectory data and distributed them to 10 local clients. The test set consisted of the last POI from these 100 trajectories, which was not used in training. The POI recommendation model used in the experiments was SASRec. SASRec automatically learns the correlation between each POI and the target POI in the historical behavior sequence using a self-attention mechanism. It has low computational cost and can capture temporal and personalized information, making it very suitable for POI recommendation tasks.
[0161] 2. Experimental setup and evaluation indicators
[0162] The main settings used in the experiment are as follows: Federated learning settings included 100 iterations, 10 local clients, a maximum of 100 available users on the dataset, a learning rate of 0.01, a local client participation rate of 0.4, 4 local training steps, a batch size of 32, and 100 negative samples. The experiment was conducted on four RTX 3060 12G graphics cards. Additionally, to verify effectiveness, this invention selected 100 previously unvisited POIs near the target POI as negative samples. These, along with the target POI, formed a credible candidate list of 101 for each user's historical trajectory, used for subsequent testing.
[0163] The metrics used in the experiment included NDCG@k and HR@k. HR@k represents the hit rate of the target label in the top k probability samples. NDCG@k is a metric for ranking quality, especially in the context of recommender systems. It considers the top k items in the recommendation list and assigns higher weight to items at the top of the list.
[0164]
[0165] Valid and C k Let represent the validation set and the candidate set of the top k Points of Interest (POIs), respectively. NDCG@k is a metric for ranking quality, particularly in the context of recommender systems. It considers the top k items in the recommendation list and assigns higher weights to items at the top of the list, as shown below:
[0166]
[0167] Here, C i Let I represent the ranking of the top i candidate samples, and I be the normalization factor IdealDCG, which is equal to the maximum possible value of DCG@k. In the comparative experiment, this invention used HR@k and NDCG@k when k is 10 and 20.
[0168] 3. Introduction to Baseline Methods
[0169] The baseline methods used in this invention are the latest personalized federated learning frameworks in recent years. These are:
[0170] ①LG-FedAvg (NeurIPS'2019) aims to co-learn a compact local representation on each device and a global model across all devices. This approach allows for a smaller global model because it only processes local representations, thus reducing the number of communication parameters.
[0171] ②FedAMP (AAAI'2021): This approach explores paired collaboration between clients with similar data to mitigate the negative impact of non-independent identically distributed (ICD) models on performance. It achieves information transfer by sending each local client's personalized model to local clients with similar model parameters.
[0172] ③FedPHP (PKDD'2021): This method emphasizes the appropriate use of the personalization model in each round. It proposes a genetic private model to store the historical collection of personalization models for each customer. The genetic private model supervises the model updates in each round, thereby mitigating the personalization loss problem caused by updates.
[0173] ④MOON (CVPR'2021): This framework incorporates contrastive learning techniques into personalized federated learning improvements. It leverages the similarity of model representations extracted through contrastive learning to further enhance personalized training on local clients.
[0174] ⑤The FedNTD (NeurIPS'2022) method aims to solve the forgetting problem in FL by maintaining a global model only for non-true categories, thereby improving the performance of the global model.
[0175] ⑥ FedAdam (AAAI'2022) is an adaptive federated learning method that addresses the challenges of high communication overhead and lack of adaptability in SGD-based model updates.
[0176] ⑦ The FedALA (AAAI'2023) method aims to address statistical heterogeneity in federated learning. It proposes an Adaptive Local Aggregation (ALA) module that adaptively aggregates the downloaded global and local models to optimize the local objective for each local client.
[0177] ⑧ PGFed (ICCV'2023) is a novel personalized federated learning framework that focuses on maximizing the experiential risk contribution of each local client. This framework avoids significant communication overhead and potential privacy breaches by adaptively aggregating the experiential risks of local clients.
[0178] 4. Comparative Experiment
[0179] ① Global Comparison Experiment
[0180] Tables 2 and 3 present the performance comparison results of FedKG and the eight strong baseline methods for spatial and quantitative heterogeneity in four datasets, respectively. Clearly, FedKG outperforms the other eight strong baseline methods in all cases, highlighting its superior performance in handling quantitatively and spatially heterogeneous data.
[0181] These eight baselines exhibit varying levels of performance. FedAMP and FedPHP show the worst stability. Both methods perform poorly on the NYC and TKY datasets but well on the Gowalla and Brightkite datasets. This indicates poor generalization performance of FedAMP and FedPHP. The contrastive learning-based personalized federated methods MOON and FedNTD demonstrate satisfactory results. However, the sparse data on local clients limits the effectiveness of knowledge distillation, a challenge that the proposed data augmentation method using ST-GAN addresses.
[0182] Table 2 compares the performance of NYC and TKY datasets under heterogeneous data volume and spatial distribution.
[0183]
[0184] Table 3 compares the performance of Gowalla and Brightkite datasets under heterogeneous data volume and spatial distribution.
[0185]
[0186] The personalized aggregation approach achieves optimal overall performance. The PGFed framework achieves competitive results on all four datasets. However, PGFed's lack of consideration for data spatial distribution leads to lower performance than FedKG. FedAdam and FedALA outperform PGFed because the strategy of local fine-tuning during global model updates may further reduce the already scarce shared information between local clients.
[0187] FedKG achieves optimal performance, which this invention attributes to the following reasons: First, ST-GAN generates more diverse training samples, providing opportunities for the model to learn personalized and global information without violating privacy principles. Second, the PKD module helps the global model learn richer personalized information, reducing the personalization loss caused by model updates in each round of communication. Finally, the GKD module assists the local model on the local client in learning missing global information, especially in spatially heterogeneous scenarios, where this global information helps each local client learn information that is far from its coordinates.
[0188] ② Convergence speed
[0189] In analyzing the performance of POI recommendation in federated learning, this invention focuses on the convergence behavior of the method under different datasets and settings. Figure 5The FedKG method exhibits superior performance across various experimental settings. Specifically, FedKG demonstrates the best convergence properties across four spatially heterogeneous datasets, indicating its adaptability and robustness to recommendation tasks.
[0190] A comparison of the eight baseline methods revealed significant differences in their performance curves. MOON, FedAMP, FedALA, and PGFed exhibited relatively stable convergence across various dataset settings, likely due to their design prioritizing the stability of the data distribution. However, FedAdam and FedDyn showed marked instability in their convergence speed, possibly because their assumptions about the data distribution deviated from reality, leading to fluctuations in the learning process. Particularly when experimenting with the Gowalla dataset in a non-independent, identically distributed setting, FedNTD and FedPHP experienced performance degradation. This phenomenon may be related to the high sparsity of the Gowalla dataset, which increases the difficulty of model learning and may contribute to the instability of these methods during the learning process.
[0191] 5. Other experiments
[0192] ① Performance under different spatial heterogeneity
[0193] exist Figure 6 This invention details the trajectory distribution on local clients as the number of local clients increases from 5, 10, 15 to 20. The figures clearly show that the trajectory distribution becomes more dispersed and uneven with the increase in the number of local clients, indicating that the spatial heterogeneity of the trajectory data increases with the number of participating local clients. This increased spatial heterogeneity may lead to more fragmented information held by individual local clients. Specifically, when the number of local clients is small, each local client has a relatively wide trajectory coverage area, and the trajectory distribution is relatively uniform. However, as the number of local clients increases, the area covered by each local client's trajectory decreases, and the trajectory distribution becomes more concentrated. This leads to fragmentation of spatial relationships and may negatively impact the model's performance.
[0194] To further investigate the performance of FedKG in handling different spatially heterogeneous scenarios, this invention designed a series of comparative experiments. The experimental results are summarized in Table 4. As can be observed from the results in Table 4, the effectiveness of FedKG becomes increasingly apparent with increasing spatial heterogeneity. The results show that the FedKG method can effectively utilize its internal ST-GAN module to generate useful trajectory samples, which provide rich information for the PKD and GKD modules. This capability is particularly important in environments with a large number of local clients and high spatial heterogeneity. The trajectory samples generated by ST-GAN increase the sample diversity learned by local clients, thereby improving the model's generalization ability on heterogeneous data.
[0195] In summary, FedKG's performance under varying degrees of spatial heterogeneity validates its effectiveness in handling distributed, non-uniform, and heterogeneous datasets. Particularly in environments with severe spatial heterogeneity, FedKG significantly improves model performance by enhancing sample diversity and quality.
[0196] Table 4. Performance comparison results under different degrees of spatial heterogeneity (the larger N is, the more severe the spatial heterogeneity).
[0197]
[0198] ② Ablation test
[0199] Figure 7 Line graphs visually compare the effects of applying different modules of FedKG in the FedAdam method. Specifically, this invention tested the following improvements: using only the Personalized Knowledge Distillation (PKD) module, adjusting the hyperparameter μ to 0.1 and 0.5; using only the Global Knowledge Distillation (GKD) module, adjusting the hyperparameter λ to 0.1 and 0.5; and using only the Spatiotemporal Generative Adversarial Network (ST-GAN) module, setting the insertion ratio ρ to 100% and 50%. Finally, this invention also examined the case of simultaneously using all components of PKD, GKD, and ST-GAN.
[0200] Experimental results reveal that applying the PKD module to existing baseline methods within the FedKG framework can significantly improve the model's personalization capabilities. Specifically, the configurations of "using the PKD module with μ of 0.1" and "using the PKD module with μ of 0.5" effectively demonstrate the improvement effect of PKD on model personalization. The configurations of "using the GKD module with λ of 0.1" and "using the GKD module with λ of 0.5" achieve good improvements even when using only the GKD module by introducing global information through the server-side generator. The cases of "using the ST-GAN module with an insertion ratio ρ of 100%" and "using the ST-GAN module with an insertion ratio ρ of 50%" demonstrate the effect of local training using only data generated by ST-GAN without employing PKD or GKD. Finally, the "all modules" configuration combining PKD, GKD, and ST-GAN represents FedKG's comprehensive optimization strategy.
[0201] Among these configurations, the ST-GAN module demonstrated the strongest performance improvement when applied alone, highlighting the importance of introducing auxiliary data in federated learning scenarios to mitigate data sparsity, bias, and missing data. Meanwhile, the effectiveness of the PKD and GKD modules was also confirmed, indicating that personalized model updates are a key factor in federated learning. PKD and GKD, through knowledge distillation-based methods, helped reduce the performance loss caused by update instability, demonstrating the value of these two strategies in handling the challenges of distributed learning environments.
[0202] ③ Hyperparameter Experiment
[0203] Sensitivity experiments aim to explore key hyperparameters in FedKG. The hyperparameter μ controls the L in PKD. kl and L bce The relative importance of μ is defined by Equation (14). A higher μ value indicates a greater emphasis on personalized knowledge distillation. On the other hand, the hyperparameter λ in GKD is controlled by Equation (17). and The relative importance of these parameters reflects the impact of global knowledge distillation. As for ST-GAN, ρ and η determine the ratio of generated trajectories to original trajectories and the length of the POI sequence of the generated trajectory. These hyperparameters serve as quantitative indicators of the generated trajectory data in ST-GAN. Furthermore, the optimal hyperparameter values may vary depending on the dataset.
[0204] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A federated learning method based on spatial heterogeneity, characterized in that, Includes the following steps S1: Pre-trained spatiotemporal awareness adversarial generative network ST-GAN: Obtaining a real local dataset D i The generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN are trained on all local clients. The trained generator is denoted as {G(ω)}. i )|1≤i≤N},{G(ω i Let )|1≤i≤N} generate a pseudo trajectory dataset for the corresponding local client, and let be the pseudo trajectory dataset. G(ω) i Generate a pseudo-track dataset for the i-th local client; All locally trained datasets G are uploaded to the server. The server aggregates all trained datasets G to obtain a global generator G(ω). The global generator is then used to generate a global pseudo-trajectory dataset Y. g ; S2: Local training: stitching together the real trajectory dataset Y i and pseudo-trajectory dataset Obtain the i-th local training dataset and utilize Training model θ on the i-th local client i The trained model is obtained after training t+1 times. i = 1, 2...N, where N represents the number of local clients; S3: Local Model Upload: Upload N locally trained models Uploaded to the server, the Global Knowledge Distillation module (GKD) uses Y g Fine-tuning the uploaded local model collection During fine-tuning, the global model θ obtained from t training iterations is used on the server. g As a teacher model, the local model trained at time t+1 will be used. As a student model, it learns global information from the teacher model to obtain a globalized local model. S4: Global parameter aggregation: using Update the model on the server, and then on the server... Aggregation is performed to obtain the global model S5: Parameter Update: This server will... The broadcast is sent back to all local clients, and on each local client, the personalized knowledge distillation module PKD is used. right Fine-tuning is performed, during which the server broadcasts the changes back to all local clients. As a student model, it will be on the local client. As a teacher model, the student model learns information from the teacher model to obtain a personalized global model. S6: Model Update: Using Override on local client This updates the local model; S7: Determine if the preset number of iterations has been reached. If not, return to S2; otherwise, use the current local model as the optimal local model and proceed to the next step. S8: For a user, obtain the user's historical check-in trajectory and input the historical check-in trajectory into the optimal local model. The optimal local model outputs the Top-K points of interest as the recommendation results.
2. The federated learning method based on spatial heterogeneity as described in claim 1, characterized in that: In S1, the process of pre-training ST-GAN is as follows: First, the first M trajectories of user u in the i-th local client are segmented and represented as follows: X(u) is divided into POI sequences Timestamp sequence Latitude and Longitude Sequence Then, these three sequences are fed together into the generator G for pre-training, where the optimization objective of G is Equation (2); Where H is the batch size, P G It is based on the probability of samples generated by generator G, L G (ω) is the loss function for generator training. Let represent the label of the j-th sample in the i-th batch and the labels of the first to (j-1)-th samples in the i-th batch, respectively; the generator calculates... and and The loss is then weighted to obtain the multidimensional input sequence Y of X(u). 1:M =(y1,…,y m ,…,y M The loss; The parameters ω of the generator G are updated iteratively using the gradient descent method, as shown in Equation (3); Where α represents the learning rate hyperparameter, and This represents the gradient of the loss function with respect to the parameter ω; The pre-trained generator G produces pseudo sequences. With the true sequence Y 1:M =(y1,…,y m ,…,y M Together, they are used to train the discriminator D; the training objective of the discriminator is to correctly distinguish between the pseudo-sequence generated by G and the real sequence. D is trained using binary cross-entropy loss, as shown in Equation (4): Where N pos N is the number of true sequences. neg N is the number of pseudo-sequences generated by G during training. pos =N neg =M;y i This represents the i-th real sequence. This represents the i-th pseudo-sequence; The optimization objective of D is expressed as formula (5); in, Indicates that it comes from the real data distribution P pos The expected value of Y, a set of real training samples sampled from the dataset. A sample refers to a set of sequences of real data. Then it represents the set of negative samples generated by G. The expected value; during the actual training of the discriminator, the objective function shown in Equation (5) is minimized through iteration to update the parameters of D. As shown in formula (6): in, This represents the loss function of the discriminator. This represents the parameters on it. This represents the loss function with respect to parameters. The gradient; After the generator G and discriminator D are pre-trained, they undergo adversarial training; the adversarial training uses the policy gradient method from reinforcement learning: Through time step m-1, state s m-1 The generated sequence The next action 'a' determines which POI point to generate at the next time step 'm', in order to determine the sequence. The corresponding state becomes s m This process continues until a complete pseudo-sequence is obtained. The generated sequence scores a reward r; if the generated sequence successfully fools D, r is 1, otherwise, if it is identified as generated, the score is 0. The optimization objective of adversarial training is to maximize the expected reward E of the generator G, as shown in Equation (7): Among them, R M It is the cumulative reward of the pseudo-sequence or the real sequence, s m-1 This represents the state at step m-1. Q is the item generated in step m, and Q is the action value. Drawing inspiration from reinforcement learning methods, the true probability estimated by the discriminator is used as the reward, and the action value is calculated using formula (8): Among them, y M This represents the data point generated in step M, while This represents the sequence of data points generated in the previous 1 to M-1 steps; The generator G will be further retrained, as shown in Equation (9); in, It is an intermediate state observed by sampling from G. This represents an intermediate state relative to the sampled state from the generator G. The expected value is calculated, J(ω) represents the loss function. Since the expected value E can be approximated by sampling, the generator parameters are updated according to formula (10). Where, η m It is the learning rate at step m.
3. The federated learning method based on spatial heterogeneity as described in claim 2, characterized in that: In S2, the server targets {G(ω)} i The process of aggregating |1≤i≤N} to obtain the global generator G(ω) is as follows: The generator of the ST-GAN model deployed on all local clients {G(ω i After pre-training on the local client, )|1≤i≤N} is uploaded to the server for aggregation to obtain a global generator G(ω), as shown in formula (11); On the server, {ω i The global generator parameter ω is obtained by aggregating |1≤i≤N}, as shown in formula (11): Among them, c i express The number of trajectory points determines the weight of local client parameters during the aggregation process.
4. The federated learning method based on spatial heterogeneity as described in claim 3, characterized in that: In S3, the Global Knowledge Distillation (GKD) module uses Y. g The process of fine-tuning the global POI recommendation model t times is as follows: In GKD, the global model θ obtained from t training iterations is stored on the server. g Treated as a teacher model, the model obtained after t+1 training iterations on the local client. Treating it as a student model, θ is calculated using KL divergence. g and The difference between them is shown in formula (16): Among them, SO G andTO G These are inputs from Y g The outputs of the student model and the teacher model after sampling positive samples, SN g and TN g These are inputs from Y g These are the outputs of the student and teacher models after negative samples, where B represents the batch size and D represents the output of the teacher model. KL This represents the KL divergence. It is the objective function or loss function, and T is the temperature parameter; In GKD, the student model uses L gkd To fine-tune its parameters to learn more global information and obtain As shown in formulas (17) and (18); Among them, L gkd It is the complete GKD loss function, combined with the KL loss function. and cross-entropy loss function λ is control and Hyperparameters of relative importance.
5. The federated learning method based on spatial heterogeneity as described in claim 4, characterized in that: In S4, the server will perform... Aggregation is performed to obtain the global model The process is shown in formula (19):
6. The federated learning method based on spatial heterogeneity as described in claim 5, characterized in that: In S5, the Personalized Knowledge Distillation (PKD) module uses... right The process of fine-tuning is as follows: Before the global model is implemented on local clients, the server is broadcast back to all local clients. As a student model, it will be on the local client. As a teacher model, use Fine-tune the teacher model as shown in formula (12): Where, N pos From The number of positive samples collected, N neg It is the number of negative samples randomly collected from POIs that the user has not visited; σ(·) is the sigmoid function, where αi and αj are the scores calculated for positive and negative samples, respectively, and L bce This represents the cross-entropy loss function used in the POI model training process; Calculation using KL divergence and The difference between them is shown in formula (13): L pkd =μ·L kl +(1-μ)·L bce (14) Among them, SO P andTO P These are inputs from The outputs of the student model and the teacher model after positive samples, SN P and TN P These are inputs from These are the outputs of the student and teacher models after negative samples; μ is a variable that controls the effect of distillation loss; L pkd It is the complete PKD loss function, combined with the KL loss function L. kl and cross-entropy loss function L bce μ is the control of L kl and L bce Hyperparameters of relative importance; After PKD fine-tuning, the global model obtains richer personalized information, as shown in formula (15):