Federal learning method based on spatial isomerism

By using spatiotemporal awareness adversarial generation network and knowledge distillation module in federated learning, the spatial heterogeneity of user trajectory data is simulated and processed, which solves the problem of spatial distribution deviation affecting POI recommendation quality in federated learning and significantly improves the personalization of the model. performance.

CN118674013AActive Publication Date: 2024-09-20CHONGQING UNIV

Patent Information

Application Number
CN202410716690.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-04
Publication Date
2024-09-20
Estimated Expiration
2044-06-04

AI Technical Summary

Technical Problem

In federated learning, the spatial heterogeneity of user trajectory data causes the local client to only learn information within a limited geographical area, affecting the recommendation quality of the POI model. Existing personalized federated learning methods fail to effectively handle spatial distribution deviations. .

Method used

Using a federated learning method based on spatial heterogeneity, pseudo trajectory data is generated through the pre-trained spatiotemporal awareness adversarial generation network ST-GAN, and combined with the personalized knowledge distillation module PKD and the global knowledge distillation module GKD to simulate the spatial heterogeneity of trajectory data and enhance Personalized performance of models in spatially heterogeneous environments.

Benefits of technology

Significantly improves the personalized performance of the POI recommendation model, expands the quantity and diversity of training data by generating synthetic trajectory data, enhances the learning of personalized and global information, and improves the performance of the model in spatial heterogeneity and non-independent and identically distributed environments. outperforms existing methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674013A
    Figure CN118674013A
Patent Text Reader

Abstract

The invention relates to a federated learning method based on spatial isomerism. The federated learning method comprises three key modules, namely a space-time consciousness generative adversarial network ST-GAN, a personalized knowledge distillation module PKD and a global knowledge distillation module GKD. The ST-GAN is a pseudo data generation method, and can generate more diversified learnable samples for local training and subsequent PKD and GKD processes. The PKD and the GKD are respectively deployed on a local client and a server and are used for enhancing learning of personalized knowledge and global knowledge. The method aims at relieving the adverse effect of spatial isomerism on the model performance so as to improve the personalized recommendation performance of the model on different local clients.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of big data technology, and in particular to a federated learning method based on spatial heterogeneity. Background Art

[0002] In the federated POI recommendation task, the user's trajectory data is generated based on their activities of visiting specific POIs, and these data naturally reflect the user's personalized access preferences in different geographical areas. This personalization leads to significant differences and isolation in the spatial distribution of trajectory data on local clients during collaborative training. This will result in local training on local clients in federated learning only being able to learn information within a limited geographical area, and having weak learning capabilities for long sequences across regions. Spatial distribution bias is often ignored in previous personalized federated learning, but in fact, it has a significant impact on the recommendation quality of the POI model.

[0003] For example, the check-in patterns of urban residents and suburban residents are likely to be significantly different, which is not only caused by the change in geographical location, but also related to the different types and numbers of POIs available in different regions. When federated learning is applied to POI recommendation, this spatial distribution bias is inevitable, which poses a challenge to the collaborative learning of the model. Summary of the invention

[0004] In view of the above problems existing in the prior art, 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 that can effectively improve the personalized performance of the federated POI recommendation model in a spatial heterogeneous environment.

[0005] To solve the above 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-training spatiotemporal awareness adversarial generation network ST-GAN: Obtaining real local dataset D i Train the generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN on all local clients, and use the trained generator as {G(ω i )|1≤i≤N},{G(ω i )|1≤i≤N} generates a pseudo trajectory dataset for the corresponding local client, record G(ω i ) generates a pseudo trajectory dataset for the i-th local client.

[0007] Upload all the locally trained G to the server, the server aggregates all the trained G to obtain the global generator G(ω), and uses the global generator to generate the global pseudo trajectory dataset Y g .

[0008] S2: Local training: splicing the real trajectory dataset Y i and pseudo-trajectory datasets Get the i-th local training data set Y i P , and use Y i P Train the model θ on the i-th local client i , after training t+1 times, we get the trained model N represents the number of local clients.

[0009] S3: Local model upload: upload N locally trained models Upload to the server, the global knowledge distillation module GKD uses Y g Fine-tune the uploaded local model collection During fine-tuning, the global model θ obtained by t trainings stored on the server is used g As the teacher model, the local model trained at t+1 is used As a student model, the student model learns the global information of the teacher model and obtains a global local model.

[0010] S4: Global Parameter Aggregation: Use Update the model on the server, and then Aggregate to get the global model

[0011] S5: Parameter Update: This server will Broadcast back to all local clients, on each local client, the personalized knowledge distillation module PKD uses Y i P right Fine-tune. When fine-tuning, the server broadcasts back to all local clients. As a student model, the local client As a teacher model, the student model learns the information of the teacher model and obtains a personalized global model

[0012] S6: Model update: Use Overwrite the local client This updates the local model.

[0013] S7: Determine whether the preset number of iterations has been reached. If not, return to S2. Otherwise, take the current local model as the optimal local model and execute the next step.

[0014] S8: For a user, the historical check-in trajectory of the user is obtained, and the historical check-in trajectory is input into the optimal local model, and the optimal local model outputs the Top-K points of interest as the recommendation results.

[0015] Furthermore, in S1, the process of pre-training ST-GAN is:

[0016] First, the first M trajectories of the trajectory sequence of user u in the i-th local client are segmented and expressed as X(u) is divided into POI sequence Timestamp sequence and the latitude and longitude sequences These three sequences are then input together into the generator G for pre-training, where the optimization objective of G is formula (2).

[0017]

[0018] Where H is the batch size, P G is the probability of the sample generated by the generator G, L G (ω) is the loss function for generator training, They represent the label of the jth sample in the i-th batch and the labels of the 1st to j-1th 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 =(y 1 ,…,y m ,…,y M ) loss.

[0019] The parameters ω of the generator G are iteratively updated by the gradient descent method, as shown in formula (3).

[0020]

[0021] where α represents the learning rate hyperparameter, and It represents the gradient of the loss function with respect to the parameter ω.

[0022] The pre-trained generator G generates pseudo sequences With the real sequence Y 1:M =(y 1 ,…,y m ,…,y M ) are used together to train the discriminator D. The training goal of the discriminator is to correctly distinguish the pseudo sequences generated by G from the real sequences. The binary cross entropy loss is used to train D, as shown in formula (4):

[0023]

[0024] Where N pos is the number of true sequences, N neg is the number of pseudo sequences generated by G, during the training process N pos =N neg =M.y i represents the i-th real sequence, represents the i-th pseudo sequence.

[0025] The optimization objective of D is expressed as formula (5).

[0026]

[0027] in, Represents the distribution of real data P pos The expected value of the real training sample set Y sampled in, where the sample refers to the sequence set of real data, It represents the set of negative samples generated by G In the actual training process of the discriminator, the objective function shown in formula (5) is minimized by iteration to update the parameters of D As shown in formula (6):

[0028]

[0029] in, represents the loss function of the discriminator, Represents the parameters above. It represents the loss function for the parameter gradient.

[0030] After the generator G and discriminator D are pre-trained, they are trained adversarially. Adversarial training uses the policy gradient method from reinforcement learning:

[0031] At time step m-1, state s m-1 , the generated sequence and the next action a determines which POI point is generated at the next time step m to determine the sequence The corresponding state becomes s m This process continues until the complete pseudosequence The score of the sequence is the reward r; if the generated sequence successfully deceives D, then r is 1, otherwise, if it is recognized as generated, the score is 0. The optimization goal of adversarial training is to maximize the expected reward E of the generator G, as shown in formula (7):

[0032]

[0033] Among them, R M is the cumulative reward of the pseudo sequence or the real sequence, s m-1 represents the state of the m-1th step, is the item generated at step m. Q is the action value.

[0034] Drawing on the reinforcement learning method, 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 represents the data points generated in the Mth step, and It represents the sequence of data points generated from 1 to M-1 steps ago.

[0037] The generator G will be further retrained as shown in formula (9).

[0038]

[0039] in, is the intermediate state sampled from G, Represents the intermediate state sampled from the generator G The expected value of the calculation, J(ω) represents the loss function. Since the expectation E can be approximated by sampling method, the parameters of the generator are updated according to formula (10).

[0040]

[0041] Among them, η m is the learning rate at the mth step.

[0042] Furthermore, in S2, the server {G(ω i )|1≤i≤N} to obtain the global generator G(ω):

[0043] The generator {G(ω i )|1≤i≤N} is uploaded to the server for aggregation after completing pre-training on the local client to obtain a global generator G(ω), as shown in formula (11).

[0044] On the server, i |1≤i≤N} are aggregated to obtain the global generator parameter ω, as shown in formula (11):

[0045]

[0046] Among them, ci Represents Y i P The number of trajectory points in the CNN, which determines the weight of local client parameters during the aggregation process.

[0047] Furthermore, in S3, the global knowledge distillation module GKD uses Y g The process of fine-tuning the t-time global POI recommendation model is as follows:

[0048] In GKD, the global model θ obtained by t trainings stored on the server is g Considered as the teacher model, the model obtained after t+1 training on the local client Considered as a student model, the KL divergence is used to calculate θ g and The difference between them is shown in formula (16):

[0049]

[0050] Among them, SO G andTO G Input from Y g The output of the student model and the teacher model after sampling positive samples, SN g and TN g Input from Y g is the output of the student model and the teacher model after negative samples. B represents the batch size, D KL represents the KL divergence, 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, As shown in formula (17) and formula (18).

[0052]

[0053]

[0054] Among them, L gkd It is the complete GKD loss function, combined with the KL loss function and the cross entropy loss function λ is the control and Relative importance of hyperparameters.

[0055] Further, in S4, the server Aggregate to get 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:

[0058] Before the global model is overwritten to the local client, the server broadcasts back to all local clients As a student model, the local client As the teacher model, use Y i P Fine-tune the teacher model as shown in formula (12):

[0059]

[0060] Among them, N pos From Y i P The number of positive samples collected, N neg 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, L bce It represents the cross entropy loss function used in the POI model training process.

[0061] Use KL divergence calculation 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 Input from Y i P The output of the student model and the teacher model after the positive sample, SN P and TN P Input from Y i P is the output of the student model and the teacher model after negative samples, and μ is a variable that controls the impact of distillation loss. pkd It is the complete PKD loss function, combined with the KL loss function Lkl And the cross entropy loss function L bce , μ is the control L kl and L bce Relative importance of hyperparameters.

[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] ① Solving the problem of spatial heterogeneity: Although existing personalized federated learning methods solve the personalization problem in non-independent and identically distributed (non-IID) data environments, they fail to deal with the spatial heterogeneity in POI trajectory data. This paper proposes a simulation method for the spatial heterogeneity problem, which effectively simulates 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 amount and diversity of training data are expanded, thereby improving the personalized performance of the POI recommendation model.

[0070] ③PKD and GKD modules enhance the learning and retention of personalized and global information: During the parameter updating process, these modules effectively enhance the learning and retention of personalized and global information, and improve the performance of the model in spatially heterogeneous environments.

[0071] ④ Significantly improve model performance: Through comparative experiments with eight personalized federated learning methods and tests on four real data sets, the FedKG method of the present invention significantly outperforms existing methods in both non-IID and spatial heterogeneity environments. Under spatial heterogeneity conditions, the performance is improved by 18.21%; under non-IID conditions, the performance is improved by 7.59%. BRIEF DESCRIPTION OF THE DRAWINGS

[0072] Figure 1 This is a visualization of data volume heterogeneity and spatial heterogeneity in the TKY dataset.

[0073] Figure 2 Flowchart of ST-GAN.

[0074] Figure 3 PKD module for personalized knowledge distillation.

[0075] Figure 4 GKD module for global knowledge distillation.

[0076] Figure 5Performance improvement curves of different methods in four datasets under spatial heterogeneous settings.

[0077] Figure 6 A visualization of the increasing spatial heterogeneity as the number of local clients increases.

[0078] Figure 7 This is the performance improvement chart of the FedAdam method after applying each module in FedKG. DETAILED DESCRIPTION

[0079] The present invention is 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 = {c 1 ,c 2 ,…,c N} represents a 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 At the coordinate (x n ,y n ) to collect the corresponding POI trajectory dataset D 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, see formula (1).

[0082]

[0083] In the real world, local client devices are deployed at a certain coordinate to collect and learn the trajectory data of the surrounding POIs. Therefore, a single local client will only collect data about users near it. There is usually significant spatial heterogeneity between the data deployed on local clients that are far apart in space. Spatial heterogeneity reflects the differences in the distribution of different local clients in the geographical locations in the federated learning environment. High spatial heterogeneity may cause the model to perform well in some areas and poorly in other areas, exacerbating the unfairness of geographical locations.

[0084] In order to solve the problem of spatial heterogeneity, the present invention first deeply analyzes the spatial distribution characteristics of user check-in data and proposes a new spatial heterogeneous data segmentation strategy to simulate the scenario in which local clients are divided according to geographical locations in the real world. To address the challenges brought by spatial heterogeneity, the present invention proposes a federated generation enhancement and bidirectional knowledge transfer method (FedKG), which aims to alleviate the adverse effects of spatial heterogeneity on model performance and improve the personalized recommendation performance of the model on different local clients. Then, the present invention organizes a series of experiments, including comparative experiments, ablation studies, and data visualization, to verify the effectiveness of the FedKG method.

[0085] In order to reduce the impact of spatial heterogeneity on the personalized performance of the federated point of interest recommendation model, the present invention designs a federated learning method FedKG based on spatial heterogeneity. Spatiotemporal-aware adversarial generative network ST-GAN, personalized knowledge distillation module PKD and global knowledge distillation module GKD. ST-GAN is a pseudo data generation method that can generate 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 knowledge and global knowledge. Next, the present invention will introduce the various components of FedKG in detail.

[0086] A federated learning method based on spatial heterogeneity includes the following steps:

[0087] S1: Pre-training spatiotemporal awareness adversarial generation network ST-GAN: Obtaining real local dataset D i Train the generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN on all local clients, and use the trained generator as {G(ω i )|1≤i≤N},{G(ω i )|1≤i≤N} generates a pseudo trajectory dataset for the corresponding local client, record G(ω i ) generates a pseudo trajectory dataset for the i-th local client.

[0088] Upload all the locally trained G to the server, the server aggregates all the trained G to obtain the global generator G(ω), and uses the global generator to generate the global pseudo trajectory dataset Y g .

[0089] S2: Local training: splicing the real trajectory dataset Y i and pseudo-trajectory datasets Get the i-th local training data set Y i P , and use Y i PTrain the model θ on the i-th local client i , after training t+1 times, we get the trained model N represents the number of local clients.

[0090] S3: Local model upload: upload N locally trained models Upload to the server, the global knowledge distillation module GKD uses Y g Fine-tune the uploaded local model collection During fine-tuning, the global model θ obtained by t trainings stored on the server is used g As the teacher model, the local model trained at t+1 is used As a student model. Figure 4 As shown, the student model learns the global information of the teacher model and obtains a global local model

[0091] S4: Global Parameter Aggregation: Use Update the model on the server, and then Aggregate to get the global model

[0092] S5: Parameter Update: This server will Broadcast back to all local clients, and the local clients now have and server broadcast On each local client, the personalized knowledge distillation module PKD uses Y i P right Fine-tune. When fine-tuning, the server broadcasts back to all local clients. As a student model, the local client As a teacher model, the student model learns the information of the teacher model and obtains a personalized global model .

[0093] S6: Model update: Use Overwrite the local client This updates the local model.

[0094] S7: Determine whether the preset number of iterations has been reached. If not, return to S2. Otherwise, take the current local model as the optimal local model and execute the next step.

[0095] S8: For a user, the historical check-in trajectory of the user is obtained, and the historical check-in trajectory is input into the optimal local model, and 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:

[0097] The spatiotemporal-aware generative adversarial network named ST-GAN can learn the spatiotemporal distribution characteristics of POI trajectories. Figure 2 Consistent with the basic principles of GAN, ST-GAN iteratively trains the generator model G and the discriminator model D. The discriminator D then evaluates the fake data generated by the generator G and provides feedback rewards to adjust the parameters inside G. Finally, a good enough generator G is obtained, which can output fake trajectory data that is indistinguishable from the real thing.

[0098] First, the first M trajectories of the trajectory sequence of user u in the i-th local client are segmented and expressed as X(u) is divided into POI sequence Timestamp sequence and the latitude and longitude sequences These three sequences are then input together into the generator G for pre-training, where the optimization objective of G is formula (2).

[0099]

[0100] Where H is the batch size, P G is the probability of the sample generated by the generator G, L G (ω) is the loss function for generator training, denote the label of the jth sample in the i-th batch and the labels of the 1st to j-1th samples in the i-th batch respectively. The generator G is pre-trained using maximum likelihood estimation, trying to minimize the probability difference between the predicted sequence and the true sequence. The generator is calculated by and and The loss is then weighted to obtain the multidimensional input sequence Y of X(u) 1:M =(y 1 ,…,y m ,…,y M ) loss.

[0101] In P G The multi-dimensional features of POI, time and space sequences are considered in [3]. The generation of each sequence depends on its previous sequence, reflecting the spatiotemporal relationship in the trajectory data. This method captures the complex dependencies of multi-dimensional trajectory data and helps the generator learn to produce more realistic trajectory samples. The parameters ω of the generator G are iteratively updated by the gradient descent method, as shown in formula (3).

[0102]

[0103] where α represents the learning rate hyperparameter, and It represents the gradient of the loss function with respect to the parameter ω.

[0104] The pre-trained generator G generates pseudo sequences With the real sequence Y 1:M =(y 1 ,…,y m ,…,y M ) are used together to train the discriminator D. The training goal of the discriminator is to correctly distinguish the pseudo sequences generated by G from the real sequences. The binary cross entropy loss is used to train D, as shown in formula (4):

[0105]

[0106] Where N pos is the number of true sequences, N neg is the number of pseudo sequences generated by G, during the training process N pos =N neg =M.y i represents the i-th true sequence, represents the i-th pseudo sequence.

[0107] For the real sequence, l = 1 is used as its target label. The output of the discriminator for the real sequence should be close to 1, while the opposite is true for the fake sequence. If the fake sequence is close enough to the real sequence, the discriminator will misjudge the fake sequence as real. The optimization objective of D is expressed as formula (5).

[0108]

[0109] in, Represents the real data distribution P pos The expected value of the real training sample set Y sampled in, where the sample refers to the sequence set of real data. It represents the set of negative samples generated by G In the actual training process of the discriminator, the objective function shown in formula (5) is minimized by iteration to update the parameters of D As shown in formula (6):

[0110]

[0111] in represents the loss function of the discriminator, Represents the parameters above. It represents the loss function for the parameter gradient.

[0112] After the generator G and discriminator D are pre-trained, they are trained adversarially. Adversarial training uses the policy gradient method from reinforcement learning:

[0113] At time step m-1, state s m-1 , the generated sequence and the next action a determines which POI point is generated at the next time step m to determine the sequence The corresponding state becomes s m This process continues until the complete pseudosequence The score of the sequence is the reward r; if the generated sequence successfully deceives D, then r is 1, otherwise, if it is recognized as generated, the score is 0. The optimization goal of adversarial training is to maximize the expected reward E of the generator G, as shown in formula (7):

[0114]

[0115] Among them, R M is the cumulative reward of the pseudo sequence or the real sequence, s m-1 represents the state of the m-1th step, is the item generated at step m. Q is the action value, which is used to measure the value of taking an action in a given state. Represents a pseudo sequence.

[0116] Drawing on the reinforcement learning method, 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 represents the data points generated in the Mth step, and It represents the sequence of data points generated from 1 to M-1 steps ago.

[0119] Formula (8) shows that the calculation of Q is based on the final sequence from the discriminator Feedback from the original dataset ensures that G’s data generation not only focuses on the appropriateness of the previous sequence, but also considers the overall quality of the final sequence. and a stronger discriminator D, the generator G will be further retrained as shown in formula (9).

[0120]

[0121] in, is the intermediate state sampled from G, Represents the intermediate state sampled from the generator G The expected value of the calculation, J(ω) represents the loss function. By optimizing J(ω), the parameters of the generator are updated to improve the quality of the generated samples. Since the expectation E can be approximated by sampling methods, the parameters of the generator are updated according to formula (10).

[0122]

[0123] Among them, η m is the learning rate at the mth step.

[0124] Specifically, in S2, the server {G(ω i )|1≤i≤N} to obtain the global generator G(ω):

[0125] The generator {G(ω i )|1≤i≤N} is uploaded to the server for aggregation after completing pre-training on the local client 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. The real trajectory data Y on the local client i Connect to form a personalized data set The Y i P The dataset will participate in the local training of the local client and the training of the PKD module. In addition, the generator parameters ω of the local client participating in the training i will be sent to the server.

[0127] On the server, i |1≤i≤N} are aggregated to obtain the global generator parameter ω, as shown in formula (11):

[0128]

[0129] Among them, c i Represents Y i P The number of trajectory points in the CNN, which determines the weight of local client parameters during the aggregation process.

[0130] Afterwards, the server will 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 module GKD uses Y g The process of fine-tuning the t-time global POI recommendation model is as follows:

[0132] In applying federated learning to POI recommendation, an important problem is the lack of shared information between local clients. Some users may have similar behavior patterns, and this shared information can help the local model learn what is missing in its dataset. In order to enhance the model's ability to mine public information and further capture global information, the present invention proposes a global knowledge distillation module deployed on the server. Whenever a local client uploads its locally trained model When , these models are not directly used for aggregation, but first use GKD to Fine-tuning can learn deeper global information. See the schematic diagram of 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 the common behavior information. g .Y g It can be used to help the local model learn global information. Unlike PKD, in GKD, the global model θ obtained by t trainings stored on the server is g Considered as the teacher model, the model obtained after t+1 training on the local client Considered as a student model, KL divergence is used to calculate θ g and The difference between them promotes the information transfer from the teacher model to the student model, as shown in formula (16):

[0134]

[0135] Among them, SO G andTO G Input from Y g The output of the student model and the teacher model after sampling positive samples, SN g and TN g Input from Y g is the output of the student model and the teacher model after negative samples. Positive samples refer to the POI data visited by the user sampled directly from the dataset, while negative samples refer to the sample set randomly sampled from the POI points that the user has not visited. B represents the batch size, D KL stands for Kullback-Leibler divergence (KL divergence), which is a measure of the distance between the differences between two probability distributions. 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, As shown in formula (17) and formula (18).

[0137]

[0138]

[0139] Among them, L gkd It is the complete GKD loss function, combined with the KL loss function and the cross entropy loss function λ is the control and Relative importance of hyperparameters.

[0140] After being processed by the GKD module, the student model will learn richer global behavior patterns, which can enhance the student model's understanding of trajectory information across geographical regions. Especially in scenarios with spatial heterogeneity, local training on each local client can only learn the check-in preferences of nearby users. For trajectory data far away from the local client, the local client may not have enough learning opportunities. The introduction of GKD provides each local client with the opportunity to learn global preferences.

[0141] Specifically, in S4, the server Aggregate to get 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:

[0144] In the POI recommendation task, each user's local trajectory reflects their personalized preferences. In federated learning, due to the limitation of the number of local clients, it is difficult to assign a local client device to each user to participate in the training. Therefore, personalized information will be lost in the federated learning communication process, especially when the global model is transmitted back to the local client to overwrite the local model. Direct overwriting will discard a lot of personalized information learned on the local model. Therefore, the present invention designs a personalized knowledge distillation module to solve the problem of personalized loss in the model update process in federated learning, see Figure 3 .

[0145] The core idea of ​​the PKD module is to use the local model and the personalized knowledge from the local data to help the global model learn personalized information. Before the global model is overlaid on the local client, the server broadcasts back to all local clients. As a student model, the local client As the teacher model, use Y i P Fine-tune the teacher model as shown in formula (12):

[0146]

[0147] Among them, N pos From Y i P The number of positive samples collected, N neg is the number of negative samples randomly collected from POIs that the user has not visited; positive samples refer to those directly collected from the dataset Y i P The negative samples are the POI data that the user has visited, while the negative samples are the sample sets randomly sampled from the POI points that the user has not visited. The number of negative samples is set to 100 in the present invention. σ(·) is the sigmoid function, where α i and α j are the scores calculated for positive and negative samples respectively, L bce It represents the cross entropy loss function used in the POI model training process.

[0148] Use KL divergence calculation 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 Input from Y i P The output of the student model and the teacher model after the positive sample, SN P and TN P Input from Y i P is the output of the student model and the teacher model after negative samples, and μ is a variable that controls the impact of distillation loss. pkd It is the complete PKD loss function, combined with the KL loss function L kl And the cross entropy loss function Lbce , μ is the control L kl and L bce Relative importance of hyperparameters.

[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 the personalized information of different local clients, which is referred to as the personalized global model in this paper. Afterwards Will overwrite the local model on the local client And participate 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] The present invention experiments on four real-world datasets, including two subsets of the Foursquare dataset (NYC and TKY), as well as Gowalla and Brightkite. For statistical information on the NYC, TKY, Gowalla, and Brightkite datasets, please see Table 1. In the partitioning of non-independent and identically distributed and spatially heterogeneous data, the present invention selects the first 100 trajectory data and distributes them to 10 local clients. The test set consists of the last POI in these 100 trajectories, which is not involved in the training. The POI recommendation model used in the experiment is SASRec. SASRec uses a self-attention mechanism to automatically learn the correlation between each POI and the target POI in the historical behavior sequence. It has low computational cost and can capture time and personalized information, so it is very suitable for POI recommendation tasks.

[0161] 2. Experimental settings and evaluation indicators

[0162] The main setting information used in the experiment is as follows. The settings of federated learning include 100 iterations, 10 local clients, 100 maximum available users in the data set, 0.01 learning rate, 0.4 local client participation rate, 4 local training steps, 32 batch size, and 100 negative samples. The experiment was conducted on 4 RTX 3060 12G graphics cards. In addition, in order to verify the effectiveness, the present invention selects 100 previously unvisited POIs near the target POI as negative samples. Together with the target POI, they form a trusted candidate list of each user's historical trajectory with a length of 101 for subsequent testing.

[0163] The metrics used in the experiments include 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 to measure the quality of ranking, especially in the context of recommendation systems. It considers the top k items in the recommendation list and gives higher weights to the items at the top of the list.

[0164]

[0165] Valid and C k denotes the validation set and the ranking candidate set of the top k POIs, respectively. NDCG@k is a metric to measure the quality of ranking, especially in the context of recommendation systems. It considers the top k items in the recommendation list and assigns higher weights to the items at the top of the list, as follows:

[0166]

[0167] Here, C i represents the top i rankings of candidate samples, and I is the normalization factor IdealDCG, which is equal to the maximum possible value of DCG@k. In the comparative experiment, the present invention uses HR@k and NDCG@k when k is 10 and 20.

[0168] 3. Introduction of Baseline Methods

[0169] The baseline method used in this paper is the latest personalized federated learning framework in recent years. They are:

[0170] ①LG-FedAvg (NeurIPS'2019) aims to jointly learn compact local representations on each device and a global model across all devices. This approach allows the global model to be smaller because it only processes local representations, thereby reducing the number of communicated parameters.

[0171] ②FedAMP(AAAI'2021): This method explores pairwise collaboration between clients with similar data to mitigate the negative impact of non-IID on performance. It achieves information transfer by sending the personalized model of each local client to local clients with similar model parameters.

[0172] ③FedPHP (PKDD'2021): This method emphasizes the appropriate use of personalized models in each round. It proposes a genetic private model to store the historical collection of personalized models for each customer. The genetic private model supervises the model update in each round, thereby alleviating the problem of personalized loss caused by the update.

[0173] ④MOON (CVPR'2021): This framework incorporates contrastive learning techniques into personalized federated learning improvements. It uses the similarity of model representations extracted through contrastive learning to further enhance personalized training on the local client.

[0174] ⑤The FedNTD (NeurIPS'2022) method aims to solve the forgetting problem in FL and improve the performance of the global model by maintaining the global model only for non-real categories.

[0175] ⑥FedAdam (AAAI'2022) is an adaptive federated learning method that addresses the challenges of large 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 downloaded global models and local models to optimize the local objectives of each local client.

[0177] ⑧PGFed (ICCV'2023) is a new personalized federated learning framework that focuses on maximizing the empirical risk contribution of each local client. This framework avoids a lot of communication overhead and potential privacy leakage by adaptively aggregating the empirical risk of local clients.

[0178] 4. Comparative Experiment

[0179] ① Global comparison experiment

[0180] Tables 2 and 3 show the performance comparison results of FedKG and eight strong baseline methods in four datasets, respectively, when spatial heterogeneity and quantitative heterogeneity are adopted. Obviously, FedKG outperforms the other eight strong baseline methods in all cases, highlighting its superior performance in processing quantitative heterogeneous and spatial heterogeneous data.

[0181] The eight baselines show different levels of performance. Among them, FedAMP and FedPHP have the worst stability. These two methods perform poorly on the NYC and TKY datasets, but perform well on the Gowalla and Brightkite datasets. This shows that FedAMP and FedPHP have poor generalization performance. The personalized federation methods MOON and FedNTD based on contrastive learning show satisfactory results. However, the sparse data of the local client limits the effectiveness of knowledge distillation, which is a challenge that the method of data enhancement using ST-GAN proposed in this invention can solve.

[0182] Table 2 Performance comparison of NYC and TKY data under data volume heterogeneity and spatial heterogeneity.

[0183]

[0184] Table 3 Performance comparison of Gowalla and Brightkite data under data volume heterogeneity and spatial heterogeneity.

[0185]

[0186] The personalized aggregation based methods achieve the best overall performance. The PGFed framework achieves competitive results on all four datasets. However, PGFed lacks consideration of the spatial distribution of data, resulting in lower performance than FedKG. FedAdam and FedALA perform worse than PGFed because the strategy of local fine-tuning during global model update may further reduce the already scarce shared information between local clients.

[0187] FedKG achieves the best performance, which the present invention believes can be attributed 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 the privacy principle. Second, the PKD module helps the global model learn richer personalized information, reducing the personalized loss caused by model updates in each round of communication. Finally, the GKD module assists the local model on the local client to learn the missing global information, especially in the spatial heterogeneity scenario, this global information helps each local client learn information that is far away from its coordinates.

[0188] ②Convergence speed

[0189] In an in-depth analysis of the POI recommendation performance in federated learning, this paper focuses on the convergence behavior of the method under different datasets and settings. Figure 5It can be observed that the FedKG method exhibits excellent performance in a variety of experimental settings. Specifically, FedKG exhibits the best convergence characteristics in four spatially heterogeneous datasets, which demonstrates its adaptability and robustness for recommendation tasks.

[0190] When comparing the eight baseline methods, it was found that their performance curves were significantly different. MOON, FedAMP, FedALA, and PGFed all showed relatively stable convergence under various dataset settings, which may be because these methods pay more attention to the stability of data distribution in their design. However, the convergence speed of FedAdam and FedDyn showed obvious instability, which may be because the assumptions of these methods on data distribution deviate from the actual situation, resulting in fluctuations in the learning process. In particular, when using the Gowalla dataset for non-IID setting experiments, FedNTD and FedPHP suffered a performance degradation. This phenomenon may be related to the high sparsity of the Gowalla dataset, which increases the difficulty of model learning and may cause instability in the learning process of these methods.

[0191] 5. Other Experiments

[0192] ① Performance under different spatial heterogeneity

[0193] exist Figure 6 In the figure, the present invention shows in detail the distribution of trajectories on local clients when the number of local clients increases from 5, 10, 15 to 20. It can be clearly seen from the figure that the distribution of trajectories becomes more dispersed and uneven as the number of local clients increases, indicating that as the number of local clients participating in the calculation increases, the spatial heterogeneity of trajectory data is also increasing. This increase in spatial heterogeneity may cause the information held by individual local clients to become more fragmented. Specifically, when the number of local clients is small, each local client has more trajectories covering a relatively wide area, and the trajectory distribution is relatively uniform. However, as the number of local clients increases, the area covered by the trajectory of each local client becomes smaller, and the trajectory distribution becomes more concentrated, which leads to the fragmentation of spatial relationships and may have a negative impact on the performance of the model.

[0194] In order to further study the performance of FedKG in dealing with different spatial heterogeneous scenarios, the present invention designed a series of comparative experiments. The experimental results are summarized in Table 4. From the results in Table 4, it can be observed that with the increase of spatial heterogeneity, the effectiveness of FedKG becomes more and more obvious. 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 ability 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 of local client learning, thereby improving the generalization ability of the model on heterogeneous data.

[0195] In summary, the performance of FedKG under different degrees of spatial heterogeneity demonstrates its effectiveness in dealing with distributed, non-uniform and heterogeneous datasets. In particular, in environments with severe spatial heterogeneity, FedKG can significantly improve model performance by enhancing the diversity and quality of samples.

[0196] Table 4 Performance comparison results under different degrees of spatial heterogeneity (the larger N is, the more serious the spatial heterogeneity is)

[0197]

[0198] ② Ablation experiment

[0199] Figure 7 The line graph visually compares the effects of applying different modules of FedKG in the FedAdam method. Specifically, the present invention tests the following improvements: using only the personalized knowledge distillation (PKD) module, adjusting the value of the hyperparameter μ to 0.1 and 0.5; using only the global knowledge distillation (GKD) module, adjusting the value of 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, the present invention also examines the case where all components of PKD, GKD, and ST-GAN are used at the same time.

[0200] The experimental results reveal that applying the PKD module to the existing baseline methods under the FedKG framework can significantly improve the personalization ability of the model. Specifically, the configurations of "using the PKD module, μ is 0.1" and "using the PKD module, μ is 0.5" effectively demonstrate the improvement effect of PKD on model personalization. The two configurations of "using the GKD module, λ is 0.1" and "using the GKD module, λ is 0.5" can also achieve good improvement by introducing global information through the server-side generator to use only the GKD module. The cases of "using the ST-GAN module, the insertion ratio ρ is 100%" and "using the ST-GAN module, the insertion ratio ρ is 50%" show the effect of local training only through the data generated by ST-GAN without using PKD and GKD. Finally, the "all modules" configuration that combines PKD, GKD and ST-GAN represents the comprehensive optimization strategy of FedKG.

[0201] Among these configurations, the ST-GAN module shows the strongest performance improvement when applied alone, which emphasizes the importance of introducing auxiliary data in federated learning scenarios to alleviate data sparsity, bias, and missing issues. At the same time, the effectiveness of the PKD and GKD modules has also been confirmed, indicating that personalization of model updates is a key factor in federated learning. PKD and GKD help reduce the performance loss caused by update instability through knowledge distillation-based methods, proving the value of these two strategies in dealing with challenges in distributed learning environments.

[0202] ③Hyperparameter experiment

[0203] The sensitivity experiment aims to explore the key hyperparameters in FedKG. The hyperparameter μ controls the L kl and L bce The relative importance of is defined in Equation (14). A higher value of μ indicates a greater emphasis on personalized knowledge distillation. On the other hand, the hyperparameter λ in GKD controls the and The relative importance of 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 POI sequences of generated trajectories. These hyperparameters serve as quantitative indicators of generated trajectory data in ST-GAN. In addition, the optimal hyperparameter values ​​may vary from dataset to dataset.

[0204] Finally, it should be noted that the above embodiments are only used to illustrate the technical solution of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solution of the present invention can be modified or replaced by equivalents without departing from the purpose and scope of the technical solution of the present invention, which should be included in the scope of the claims of the present invention.

Claims

1. A federated learning method based on spatial heterogeneity, characterized in that: The following steps are included S1: Pre-training spatiotemporal awareness adversarial generation network ST-GAN: Obtaining real local dataset D i Train the generator G and discriminator D in the spatiotemporal awareness adversarial generative network ST-GAN on all local clients, and use the trained generator as {G(ω i )|1≤i≤N},{G(ω i )|1≤i≤N} generates a pseudo trajectory dataset for the corresponding local client, record G(ω i ) Generate a pseudo trajectory dataset for the i-th local client; Upload all the locally trained G to the server, the server aggregates all the trained G to obtain the global generator G(ω), and uses the global generator to generate the global pseudo trajectory dataset Y g ; S2: Local training: splicing the real trajectory dataset Y i and pseudo-trajectory datasets Get the i-th local training data set And use Train the model θ on the i-th local client i , after training t+1 times, we get the trained model i=1,2……N, where N represents the number of local clients; S3: Local model upload: upload N locally trained models Upload to the server, the global knowledge distillation module GKD uses Y g Fine-tune the uploaded local model collection During fine-tuning, the global model θ obtained by t trainings stored on the server is used g As the teacher model, the local model trained at t+1 is used As a student model; make the student model learn the global information of the teacher model and obtain a global local model S4: Global Parameter Aggregation: Use Update the model on the server, and then Aggregate to get the global model S5: Parameter Update: This server will Broadcast back to all local clients, on each local client, the personalized knowledge distillation module PKD uses right Fine-tune. When fine-tuning, the server broadcasts back to all local clients. As a student model, the local client As a teacher model, the student model learns the information of the teacher model and obtains a personalized global model S6: Model update: Use Overwrite the local client Thereby updating the local model; S7: Determine whether the preset number of iterations has been reached. If not, return to S2. Otherwise, take the current local model as the optimal local model and execute the next step. S8: For a user, the historical check-in trajectory of the user is obtained, and the historical check-in trajectory is input into the optimal local model, and the optimal local model outputs the Top-K points of interest as the recommendation results.

2. The spatially heterogeneous federated learning method according to claim 1, characterized in that: In S1, the process of pre-training ST-GAN is: First, the first M trajectories of the trajectory sequence of user u in the i-th local client are segmented and expressed as X(u) is divided into POI sequence Timestamp sequence and the latitude and longitude sequences Then these three sequences are input together into the generator G for pre-training, where the optimization objective of G is formula (2); Where H is the batch size, P G is the probability of the sample generated by the generator G, L G (ω) is the loss function for generator training, They represent the label of the jth sample in the i-th batch and the labels of the 1st to j-1th 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 ) losses; The parameters ω of the generator G are iteratively updated by the gradient descent method, as shown in formula (3); where α represents the learning rate hyperparameter, and It represents the gradient of the loss function with respect to the parameter ω; The pre-trained generator G generates pseudo sequences With the real sequence Y 1:M =(y1,…,y m ,…,y M ) are used together to train the discriminator D; the training goal of the discriminator is to correctly distinguish the pseudo sequences generated by G from the real sequences; The binary cross entropy loss is used to train D, as shown in formula (4): Where N pos is the number of true sequences, N neg is the number of pseudo sequences generated by G, during the training process N pos =N neg =M;y i represents the i-th true sequence, represents the i-th pseudo sequence; The optimization objective of D is expressed as formula (5); in, Represents the distribution of real data P pos The expected value of the real training sample set Y sampled in, where the sample refers to the sequence set of real data, It represents the set of negative samples generated by G The expected value of D; In the actual training process of the discriminator, the objective function shown in formula (5) is minimized by iteration to update the parameters of D As shown in formula (6): in, represents the loss function of the discriminator, Represents the parameters above. It represents the loss function for the parameter The gradient of After the generator G and discriminator D are pre-trained, they are trained adversarially; adversarial training uses the policy gradient method from reinforcement learning: At time step m-1, state s m-1 , the generated sequence and the next action a determines which POI point is generated at the next time step m to determine the sequence The corresponding state becomes s m , and this process continues until the complete pseudo-sequence is generated, the score of the sequence is the reward r; if the generated sequence successfully deceives D, then r is 1, otherwise, if it is identified as generated, the score is 0. The optimization goal of adversarial training is to maximize the expected reward E of the generator G, as shown in formula (7): Among them, R M is the cumulative reward of the pseudo sequence or the real sequence, s m-1 represents the state of the m-1th step, is the item generated in step m, Q is the action value; Drawing on the reinforcement learning method, 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 represents the data points generated in the Mth step, and It represents the sequence of data points generated from the first 1 to M-1 steps; The generator G will be further retrained as shown in formula (9); in, is the intermediate state sampled from G, Represents the intermediate state sampled from the generator G The expected value of the calculation, J(ω) represents the loss function. Since the expectation E can be approximated by sampling method, the parameters of the generator are updated according to formula (10); Among them, η m is the learning rate at the mth step.

3. The spatially heterogeneous federated learning method according to claim 2, characterized in that: In S2, the server {G(ω i )|1≤i≤N} to obtain the global generator G(ω): The generator {G(ω i )|1≤i≤N} is uploaded to the server for aggregation after completing pre-training on the local client to obtain a global generator G(ω), as shown in formula (11); On the server, i |1≤i≤N} are aggregated to obtain the global generator parameter ω, as shown in formula (11): Among them, c i express The number of trajectory points in the CNN, which determines the weight of local client parameters during the aggregation process.

4. The spatially heterogeneous federated learning method according to claim 3, characterized in that: In S3, the global knowledge distillation module GKD uses Y g The process of fine-tuning the t-time global POI recommendation model is as follows: In GKD, the global model θ obtained by t trainings stored on the server is g Considered as the teacher model, the model obtained after t+1 training on the local client Considered as a student model, the KL divergence is used to calculate θ g and The difference between them is shown in formula (16): Among them, SO G andTO G Input from Y g The output of the student model and the teacher model after sampling positive samples, SN g and TN g Input from Y g is the output of the student model and the teacher model after negative samples, B represents the batch size, and D KL represents the KL divergence, is the objective function or loss function, T is the temperature parameter; In GKD, the student model uses L gkd To fine-tune its parameters to learn more global information, As shown in formula (17) and formula (18); Among them, L gkd It is the complete GKD loss function, combined with the KL loss function and the cross entropy loss function λ is the control and Relative importance of hyperparameters.

5. The spatially heterogeneous federated learning method according to claim 4, characterized in that: In S4, the server will Aggregate to get the global model The process is shown in formula (19):

6. The spatially heterogeneous federated learning method according to claim 5, characterized in that: In S5, the personalized knowledge distillation module PKD uses right The process of fine-tuning is: Before the global model is overwritten to the local client, the server broadcasts back to all local clients As a student model, the local client As a teacher model, use Fine-tune the teacher model as shown in formula (12): Among them, N pos is from The number of positive samples collected, N neg is the number of negative samples randomly collected from POIs that the user has not visited; s(·) is the sigmoid function, where αi and αj are the scores calculated for positive and negative samples respectively, and L bce It represents the cross entropy loss function used in the POI model training process; Use KL divergence calculation and The difference between them is shown in formula (13): L pkd =μ·L kl +(1-μ)·L bce (14) Among them, SO P andTO P Input from The output of the student model and the teacher model after the positive sample, SN P and TN P Input from is the output of the student model and the teacher model after negative samples, μ is a variable that controls the impact of distillation loss; L pkd It is the complete PKD loss function, combined with the KL loss function L kl And the cross entropy loss function L bce , μ is the control L kl and L bce Relative importance of hyperparameters; After PKD fine-tuning, the global model obtains richer personalized information, as shown in formula (15):

Citation Information

Patent Citations

  • Federal learning model aggregation method based on dynamic adaptive knowledge distillation

    CN116681144A

  • Image classification method based on federal knowledge distillation and ensemble learning

    CN117523291A

  • Methods, devices and media for re-weighting to improve knowledge distillation

    US20220343175A1

Cited By

  • Heterogeneous federated learning method based on spatio-temporal data distillation

    CN119692436A

  • Heterogeneous federal learning method and system based on personalized information separation

    CN119849602A

  • A Heterogeneous Federated Learning Method and System Based on Personalized Information Separation

    CN119849602B