Federal continuous learning method and device based on feature similarity and storage medium
By using feature similarity and pseudo-image samples in federated continuous learning, the problems of catastrophic forgetting, data privacy protection and resource utilization efficiency are solved, and the stability and generalization capabilities of the model are improved.
Patent Information
- Application Number
- CN202510119595.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-24
- Publication Date
- 2025-05-23
AI Technical Summary
There are catastrophic forgetting, insufficient data privacy protection and inefficient resource utilization in federated continuous learning, which affects the model's continuous learning efficiency and multitasking capabilities.
A federated continuous learning method based on feature similarity is adopted to reduce dependence on client local data by generating pseudo-image samples on the server side, and optimize the knowledge distillation process through dynamic similarity measurement, adjust the loss weight to balance the learning of new and old tasks.
有效减轻了模型对旧任务知识的遗忘,提升了模型的泛化能力和稳定性,同时优化了数据隐私保护和资源利用效率。
Smart Images

Figure CN120032205A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of federated continuous learning, and in particular to a method, device and storage medium for federated continuous learning based on feature similarity. Background Art
[0002] In the vast field of federated continuous learning, although its distributed learning characteristics and high protection of data privacy provide possibilities for many application scenarios, it still faces a series of core technical challenges. First, catastrophic forgetting is a particularly prominent problem. With the continuous introduction of new tasks, the model tends to gradually forget the old task knowledge learned in the continuous learning process, resulting in a significant decrease in performance on the old tasks. This forgetting phenomenon not only affects the efficiency and effect of the model's continuous learning, but also limits its potential for widespread application in multi-tasking environments.
[0003] Secondly, data privacy protection plays a vital role in federated continuous learning. In a distributed learning environment, how to effectively use client data for model training without leaking sensitive information has become a technical problem that needs to be solved. Although traditional federated learning methods have achieved data privacy protection to a certain extent, in the process of knowledge transfer between new and old tasks, the improvement of model performance is often limited due to inaccessible or insufficient data.
[0004] In addition, resource limitations are also an important issue that cannot be ignored in federated continuous learning. Especially in resource-constrained environments such as mobile devices or edge devices, how to achieve efficient knowledge transfer and task learning with limited storage space and computing power has become a technical challenge that needs to be overcome. These resource limitations not only affect the training speed and effect of the model, but also limit the promotion and popularization of federated continuous learning in practical applications.
[0005] In summary, federated continuous learning needs to seek new solutions and technological breakthroughs when facing core issues such as catastrophic forgetting, data privacy protection, and resource limitations. Solving these problems is not only crucial to improving the performance and effectiveness of federated continuous learning, but also has far-reaching significance for promoting its widespread application in more application scenarios. Summary of the invention
[0006] The present invention aims to overcome the three major deficiencies in existing federated continuous learning: catastrophic forgetting, insufficient data privacy protection, and inefficient resource utilization, and provides a federated continuous learning method, device, and storage medium based on feature similarity. First, the present invention aims to solve the problem of catastrophic forgetting, ensuring that the model does not forget old knowledge when learning new tasks, and maintains the stability of continuous learning. Secondly, the present invention reduces the dependence on local data on the client by generating pseudo image samples on the server side, thereby effectively reducing the memory usage of the device. Finally, the present invention optimizes the knowledge distillation process based on dynamic similarity measurement, which can not only retain existing knowledge in a balanced manner, but also smoothly integrate new tasks, thereby significantly improving the generalization ability and stability of the model.
[0007] In order to achieve the above-mentioned object of the invention, the present invention provides the following technical solutions:
[0008] In a first aspect, an embodiment of the present application provides a federated continuous learning method based on feature similarity, which may include:
[0009] S1. Receive image data from at least one client, wherein the image data of each client includes a first image sample and a first image feature vector of a new task; receive a pseudo image sample of an old task generated by a generator on the server side and its corresponding image feature vector, wherein the pseudo image sample is used to represent the data features of the old task;
[0010] S2. constructing a similarity matrix according to the image feature vectors of the first image sample and the pseudo image sample, and obtaining the maximum similarity;
[0011] S3. Using a preset nonlinear conversion function, the maximum similarity is converted into a dynamic weight;
[0012] S4. According to the dynamic weight, set the weights of knowledge distillation loss and cross entropy classification loss, and calculate the total loss of knowledge distillation loss and cross entropy classification loss;
[0013] S5. At least one client updates the local model weight based on the total loss and sends it to the server; the server receives the local model weight of at least one client and performs global aggregation, and updates the global model;
[0014] S6. After completing at least one learning cycle from S1 to S5, the server trains a generator according to the global model and sends the generator to at least one client.
[0015] In some embodiments, in step S1, random noise is input into a generator on the server side, and the generator is trained using a data-free knowledge extraction method to obtain pseudo samples of old tasks.
[0016] In the above implementation process, by introducing random noise on the server side and using the data-free knowledge extraction method to train the generator, the generator can generate more pseudo samples that are diverse and represent the characteristics of the old tasks. This method reduces the client's local data dependence in federated continuous learning, effectively protects data privacy, and improves the learning stability of the model under the old tasks through pseudo samples.
[0017] In some embodiments, the maximum similarity is calculated according to the following formula:
[0018]
[0019] Among them, S represents the similarity between the new task and the old task, n represents the dimension of the feature vector, i represents the i-th dimension in the feature vector, and f i represents the feature vector component of the i-th dimension new task image sample, p i represents the feature vector component of the old task in the i-th dimension, Indicates the maximum similarity between the new task and the old task.
[0020] In the above implementation process, the maximum similarity formula can accurately quantify the feature similarity between new tasks and old tasks, helping the model to dynamically adjust the learning strategy. Through this formula, the model can accurately evaluate the similarity and use the dynamic weight mechanism to balance the learning between new and old tasks, thereby effectively reducing catastrophic forgetting and improving the generalization ability of the model.
[0021] In some embodiments, the preset nonlinear conversion function in step S3 is a Sigmoid function, and the Sigmoid function maps the maximum similarity to a dynamic weight in the range (0,1); the dynamic weight is used to adjust the weight ratio of knowledge distillation loss and cross entropy classification loss.
[0022] In the above implementation process, the maximum similarity is mapped to a dynamic weight by using the Sigmoid function. This method can map the similarity value to a moderate weight range and accurately control the ratio of knowledge distillation loss to cross entropy classification loss. The dynamic weight mechanism can flexibly adjust the loss weight according to the changes in similarity between tasks, thereby balancing the effects of retaining old task knowledge and learning new tasks.
[0023] In some embodiments, the dynamic weight is calculated as follows: The formula for the weight ratio is w KD =w,w CE =1-w; where ω is the dynamic weight, ω KD is the knowledge distillation loss weight, ω CE is the cross entropy loss weight.
[0024] In the above implementation process, by calculating the dynamic weights and weight ratios, the model can accurately adjust the ratio of knowledge distillation to cross entropy classification loss. This method can alleviate the catastrophic forgetting problem and enhance the model's diversity and generalization ability in learning new tasks.
[0025] In some embodiments, the generator training process in step S6 also introduces a diversity loss that considers information entropy loss, and the formula is:
[0026]
[0027] Among them, L div represents the diversity loss, H info represents information entropy loss, B represents batch size, represents the i-th generated image sample, Represents the predicted probability distribution of the current model F for the i-th generated image sample.
[0028] In the above implementation process, the information entropy loss is introduced during the generator training process, and combined with the diversity loss, the diversity of pseudo samples can be effectively improved. This method not only enhances the diversity of generated samples in generator training, but also improves the consistency of sample distribution, thereby further improving the generalization ability of the model in federated continuous learning.
[0029] In some embodiments, the generator is trained using a batch loss function, wherein the formula of the batch loss function is
[0030]
[0031] Among them, L BN represents the batch statistical loss, D KL represents KL divergence, N(μ i ,σ i 2 ) represents the data distribution of real image samples, μ i is the mean of the i-th image sample in the batch, σ i represents the standard deviation of the image samples, is the variance of the i-th image sample in the batch, represents the data distribution of generated image samples, is the mean of the generated image samples, represents the standard deviation of the generated image samples, is the variance of the generated image samples.
[0032] In the above implementation process, the batch loss function is used to train the generator, and the difference between the generated samples and the real samples is measured by KL divergence, so that the generator can output more diverse and uniformly distributed pseudo samples within the batch. This method can significantly improve the quality of the generator and enhance the learning stability and generalization ability of the model in federated continuous learning.
[0033] In some embodiments, the image output by the generator is processed using a smoothing function, wherein the formula of the smoothing function is: Among them, L pr represents a smooth function, represents the generated image; represents the blurred image. Represents the square of the Euclidean norm.
[0034] In the above implementation process, by introducing a smoothing function after the generator outputs the image, this method can effectively improve the visual quality of the generated samples. The smoothing function reduces the noise and unnecessary mutations of details in the image through blurring, ensuring that the generated samples are visually clearer and smoother, thus closer to the real samples, and improving the generalization ability of the federated learning model in learning new tasks.
[0035] In a second aspect, an embodiment of the present application provides a computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the above description when executing the computer program.
[0036] In a third aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, implements the method described in the above description.
[0037] Compared with the prior art, the beneficial effects of this application are:
[0038] The present invention proposes a federated continuous learning method based on feature similarity, which solves the catastrophic forgetting problem in traditional federated continuous learning by dynamically adjusting the loss weight. Unlike the prior art, traditional methods mostly rely on fixed loss weights or store old task data to alleviate forgetting, and cannot effectively deal with the impact of the similarity difference between new and old tasks. By constructing a similarity matrix of new and old task features, the model can accurately identify the difference between the two, and use a preset nonlinear conversion function to convert the maximum similarity into a dynamic weight, thereby adjusting the weight ratio of knowledge distillation loss and cross entropy classification loss in real time. This dynamic mechanism not only reduces the model's forgetting of old task knowledge, but also optimizes data privacy protection and resource utilization efficiency when learning new tasks. At the same time, the present invention reduces the dependence on local data on the client by generating pseudo samples on the server side, effectively reduces the device memory usage, and significantly improves the generalization ability and stability of the model. Therefore, this method not only solves the problem of catastrophic forgetting, but also takes into account the optimization of data privacy protection and resource utilization, and promotes the practical application of federated continuous learning technology in environments such as multi-tasking and edge devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 This is a method flow chart of a federated continuous learning method based on feature similarity according to Embodiment 1 of the present invention;
[0040] Figure 2 Schematic diagram of a federated continuous learning method based on feature similarity according to Embodiment 2 of the present invention;
[0041] Figure 3 This is a framework diagram of the AWAS model of Example 2 of the present invention;
[0042] Figure 4 This is a schematic diagram of an adaptive federated continuous learning method based on feature similarity according to Embodiment 2 of the present invention;
[0043] Figure 5 This is an algorithm flow chart of an adaptive federated continuous learning method based on feature similarity of a client in Embodiment 2 of the present invention;
[0044] Figure 6 This is an algorithm flow chart of the adaptive federated continuous learning method based on feature similarity on the server side of Example 2 of the present invention;
[0045] Figure 7 This is a comparison chart of task accuracy on the CIFAR100 dataset of Example 2 of the present invention;
[0046] Figure 8 This is a comparison chart of task accuracy on the TinyImageNet dataset of Example 2 of the present invention;
[0047] Fig. 9 This is a comparison chart of task accuracy on the SuperImageNet dataset of Example 2 of the present invention;
[0048] Fig.10 This is a schematic diagram of the effect of increasing the number of clients on the CIFAR100 dataset on model performance according to Example 2 of the present invention;
[0049] Fig.11 This is a schematic diagram showing the effect of increasing the number of tasks on model accuracy in Example 2 of the present invention;
[0050] Fig.12 This is a comparison chart of the accuracy differences between the two models of Example 2 of the present invention on different tasks. DETAILED DESCRIPTION
[0051] The following is a further detailed description of a federated continuous learning method, device and storage medium based on feature similarity provided by the present invention in conjunction with the accompanying drawings and specific embodiments. However, this should not be understood as the scope of the above-mentioned subject matter of the present invention being limited to the following embodiments. All technologies implemented based on the content of the present invention belong to the scope of the present invention. Combined with the following description, the advantages and features of the present invention will be clearer. It should be noted that the drawings are all in a very simplified form and use non-precise proportions, which are only used to conveniently and clearly assist in explaining the purpose of the embodiments of the present invention.
[0052] Example 1
[0053] During the research process, the applicant found that when using federated continuous learning technology, if the similarity between the new task and the old task is low, it is easy to cause the model to catastrophically forget the knowledge of the old task, so it is necessary to find a balance between learning new tasks and maintaining old task knowledge. However, since the existing technology fails to dynamically adapt to the similarity difference between new and old tasks, it can only alleviate the problem of catastrophic forgetting by fixed loss weights or relying on methods to store old task data. When solving practical problems, in order to improve the adaptability of the model in new task learning and reduce the forgetting of old task knowledge, the existing technology cannot take into account data privacy protection, storage resource optimization and model performance improvement. Therefore, after studying this problem, the applicant proposed a federated continuous learning method based on feature similarity. When the model is learning a new task, the dynamic balance between learning new tasks and maintaining old knowledge is achieved by dynamically adjusting the loss weight based on the similarity of the new and old task features, thereby achieving the technical effect of reducing catastrophic forgetting, improving the generalization ability of the model, and optimizing data privacy protection and resource utilization efficiency.
[0054] like Figure 1 As shown, Figure 1A schematic diagram of the steps of a federated continuous learning method based on feature similarity provided in an embodiment of the present application. Specifically, the method includes the following steps:
[0055] S1. Receive image data from at least one client, wherein the image data from each client includes a first image sample and a first image feature vector of a new task; receive a pseudo image sample of an old task generated by a generator on the server side and its corresponding image feature vector, wherein the pseudo image sample is used to represent the data features of the old task;
[0056] S2. constructing a similarity matrix according to the image feature vectors of the first image sample and the pseudo image sample, and obtaining the maximum similarity;
[0057] S3. Using a preset nonlinear conversion function, the maximum similarity is converted into a dynamic weight;
[0058] S4. According to the dynamic weight, set the weights of knowledge distillation loss and cross entropy classification loss, and calculate the total loss of knowledge distillation loss and cross entropy classification loss;
[0059] S5. At least one client updates the local model weight based on the total loss and sends it to the server; the server receives the local model weight of at least one client and performs global aggregation, and updates the global model;
[0060] S6. After completing at least one learning cycle from S1 to S5, the server trains a generator according to the global model and sends the generator to at least one client.
[0061] Through the above methods, we can effectively solve the problems of catastrophic forgetting, insufficient data privacy protection and inefficient resource utilization in existing federated learning technology, improve the stability, generalization ability and computing resource optimization efficiency of the model, and achieve significant technical effects.
[0062] The method described in the embodiment of the present application can be applied to multiple technical fields, such as image processing, video analysis, machine vision, etc. In the above implementation, in the continuous learning process of processing new and old task data, the model can effectively reduce the catastrophic forgetting phenomenon and maintain the stability of the model in long-term learning by dynamically adjusting the knowledge distillation loss and the cross entropy classification loss weights. At the same time, by generating pseudo-image samples, the dependence on local client data is reduced, and data privacy protection is optimized. In addition, this method is based on server-side generator training, which can significantly improve the generalization ability of the model in a new task environment, thereby achieving a more efficient task learning effect.
[0063] Example 2
[0064] As an optimization of the previous embodiment, the embodiment of the present application proposes a specific implementation of a federated continuous learning method based on feature similarity. In the embodiment of the present application, the image is regarded as a special form of data, that is, visual data represented in the form of a pixel matrix.
[0065] like Figure 2 As shown in the figure, w KD represents the knowledge distillation loss weight, w CE Represents the cross entropy loss weight. As a dynamically adjusted parameter, w KD and w CE It aims to reasonably distribute the focus in the learning process and balance the mutual influence between the old task (i.e., task t-1) and the new task (i.e., task t), thereby enhancing the performance of the model on the new task. This method effectively coordinates the relationship between the knowledge extraction of the old task and the learning of the new task, significantly alleviating the problem of catastrophic forgetting.
[0066] exist Figure 2 In the figure, features are distinguished by different colors. The depth of color reflects the concentration of features in neurons. The darker the color, the higher the concentration. When there are significant differences between the new task features and the old task features, directly migrating the old task knowledge to the new task will face challenges; conversely, if the new and old task features are similar, over-reliance on the old task knowledge may cause the model to overfit the new task. To solve this problem, the embodiment of the present application proposes an innovative adaptive federated continuous learning method based on feature similarity.
[0067] Please see Figure 3 , the AWAS model (Adaptive Weight Adjustment Strategy, adaptive weight adjustment strategy based on feature similarity) is the core content of this method: First, the AWAS model accurately captures the relationship between new and old tasks by calculating the feature similarity matrix of the current task sample and the old task pseudo sample; secondly, AWAS uses the attention mechanism to dynamically adjust the weights of knowledge distillation and classification loss according to feature similarity. This dynamic optimization strategy is not only the key to achieving balanced learning of new and old tasks, but also the key to promoting the stability of federated continuous learning; finally, AWAS effectively realizes the integration of knowledge retention and new task learning through deep mining of feature similarity and dynamic weights, which can effectively solve the problem of catastrophic forgetting. The AWAS model consists of two parts: the server and the client. The client is a local model and the server is a global model. Specifically:
[0068] On the server side, the generator uses a data-free knowledge distillation method to train the input random noise data. This method aims to extract and compress knowledge from old tasks to build a more general generator. This process not only improves the memory of old knowledge, but also reduces the reliance on the client to store historical data, which can effectively reduce the privacy risk of data transmission.
[0069] In the client, users receive the trained generator from the server and use it to generate synthetic images, thereby mitigating catastrophic forgetting. These synthetic images are used to train new tasks, ensuring that the model retains its understanding of old knowledge when processing new data. In addition, the client also adopts a dynamic, similarity-driven adaptation method to adjust the balance between new tasks and old knowledge in real time by evaluating the similarity between new tasks and old knowledge. This method helps to enhance the adaptability of the model and maintain good performance in a changing task environment, thereby promoting effective knowledge transfer and continuous learning.
[0070] Get the first image sample and the first image feature vector of the new task, the pseudo image sample and the second image feature vector of the old task, and calculate the similarity between the image feature vector of the first image sample and the second image feature vector of the pseudo image sample according to the following formula:
[0071]
[0072] Among them, S represents the similarity between the new task and the old task, n represents the dimension of the feature vector, i represents the i-th dimension in the feature vector, and f i represents the feature vector component of the i-th dimension new task image sample, p i Represents the feature vector component of the i-th dimension old task.
[0073] Between new tasks and old tasks, an adaptive weight adjustment mechanism based on similarity is introduced. By dynamically adjusting the weights of knowledge distillation loss and cross entropy loss, the relationship between new and old tasks can be effectively balanced.
[0074] For each image sample, keep its maximum similarity with the second image feature vector. Represents the maximum similarity of image samples, which can be expressed as
[0075]
[0076] In federated continuous learning tasks, categories are used to represent the identifiers or labels of the categories to which data image samples belong, such as different object types in image data. Categories play a role in distinguishing and labeling in model training, and each category corresponds to a specific set of features. In the old tasks, category features are represented and saved by pseudo-image samples generated by the generator to mitigate catastrophic forgetting; in the new tasks, by dynamically adjusting the similarity weights between the new task image samples and the old task category features, the optimization of new task learning and the retention of old task knowledge are achieved.
[0077] By obtaining the maximum similarity, federated continuous learning can focus on the old task category features that are most relevant to each new image sample, ensuring that the model can effectively integrate past knowledge into the current learning model. By linking each new image sample with the feature vector of the old task that it is most closely related to, a smoother adaptation process is promoted. This mechanism helps to improve the coherence and efficiency of the learning process, allowing the model to master complex continuous learning with higher efficiency.
[0078] The purpose of dynamically adjusting weights is to make the model prioritize knowledge distillation loss when processing image samples that are similar to known prototypes, while focusing on cross entropy classification loss when processing image samples with lower similarity. This tailored approach ensures that the model effectively utilizes existing knowledge when encountering familiar data, thereby improving overall learning efficiency. In order to convert similarity into a weight for the loss function, the maximum similarity is normalized using the Sigmoid function:
[0079]
[0080] Through the Sigmoid function, the maximum similarity is mapped to a dynamic weight ω in the range (0, 1). In this way, the weight can be directly used in the loss function, thereby dynamically adjusting the contribution of different image samples when calculating the loss. The following is the knowledge distillation loss weight w KD and the cross entropy loss weight w CE Definition:
[0081] w KD =w,w CE =1-w.
[0082] To ensure effective training and evaluation, the cross entropy classification loss is used to quantify the difference between the synthetic images generated by the generator and the actual images of the dataset. The cross entropy classification loss function accurately evaluates the consistency between the model prediction and the true category of the generated image samples. The cross entropy classification loss is expressed as follows:
[0083]
[0084] Among them, L CEis the cross entropy loss, which is used to measure the difference between the generated image sample and the model prediction result; y is the one-hot encoding vector of the target category, which represents the true category of the generated image sample; T represents the transposition of y; is the generated image sample, is the image sample generated by the current model F The predicted probability distribution of .
[0085] However, relying on synthetic images sometimes leads to a lack of category diversity, which limits the generalization ability of the model in various tasks. Therefore, the information entropy loss is introduced, which is specifically used to encourage the generator to generate more diverse image samples. The mathematical definition of diversity loss is as follows:
[0086]
[0087] Among them, L div represents the diversity loss, which is used to measure the diversity of generated image samples; H info represents information entropy loss, represents the uncertainty of the predicted distribution, B represents the batch size, represents the i-th generated image sample, Represents the predicted probability distribution of the current model F for the i-th generated image sample.
[0088] Subsequently, in order to prevent the synthesized images from seriously deviating from the actual data distribution, a batch statistical loss is integrated. The formula of the batch statistical loss is:
[0089]
[0090] Among them, L BN Denotes batch statistical loss; D KL stands for KL divergence, which is a measure of the difference between two probability distributions; represents the data distribution of real image samples, μ i is the mean of the i-th image sample in the batch, σ i represents the standard deviation of the image samples, is the variance of the i-th image sample in the batch; represents the data distribution of generated image samples, is the mean of the generated image samples, represents the standard deviation of the generated image samples, is the variance of the generated image samples.
[0091] Finally, in order to maintain the inherent characteristics of the synthesized image, an image prior loss is proposed to force adjacent pixel values to move closer to similar values, thereby ensuring a smooth transition of the entire image. This smooth transition is achieved by applying a smoothing function L described by prTo achieve:
[0092]
[0093] Among them, L pr represents a smooth function, represents the generated image; Represents the blurred image, that is, by The image obtained after Gaussian blur processing;||·|| 2 represents the Euclidean norm, which calculates the difference or distance between two images; It represents the square of the Euclidean norm, that is, it calculates the square of the Euclidean distance between two sets of feature representations.
[0094] The specific goal L of the generator training process can be defined as follows:
[0095]
[0096] Among them, G represents the generator model, α represents the weight of diversity loss, β represents the weight of batch statistics loss, and γ represents the weight of smooth transition loss.
[0097] At the same time, in order to more effectively capture the characteristics of new tasks, the model only calculates the cross entropy loss of new categories to minimize the impact of previous tasks on model updates. Specifically, when the label corresponds to the category of the new task, the cross entropy loss is defined as follows:
[0098]
[0099] Among them, D CE represents the cross entropy loss, which is used to measure the difference between the model output and the true label. t (x) represents the current model F t The predicted output on the input image sample x. y represents the target label, that is, the true category label of the image sample x. Y t Represents the category set of the current task, that is, all categories related to the current task. The main advantage of this model is that it can significantly improve the adaptability and generalization ability of the model while reducing the performance degradation caused by task switching. On this basis, the knowledge distillation loss function It can be expressed as:
[0100]
[0101] in, Represents the output of the first L-1 layers of the model at time step i. That is, the feature representation of the first L-1 layers of the model (excluding the final output layer). These are the intermediate feature representations of the model, including low-level to high-level abstract information of the data, but have not yet passed the final decision layer. It is the real image sample x and the generated image sample As input to the model for calculation, they generate their corresponding feature representations. Q represents the feature representation of the output layer of the model at the previous time step, that is, the output of the Lth layer.
[0102] Finally, the knowledge transfer and balance between new and old tasks are better handled through the dynamic weight adjustment mechanism. The final objective function is as follows:
[0103]
[0104] This approach greatly enhances the model's ability to adapt to new categories. Specifically, it prioritizes image samples related to the new task during training, while reducing the influence of image samples with low similarity to the new category.
[0105] Please refer to Figure 4 , which is the specific implementation process of the adaptive federated continuous learning method based on feature similarity, including:
[0106] 101. Counter and model initialization: Initialize the discovered category count and initialize the global model; the global model includes the generation model, global classifier, global loss function, and the weight of the global model.
[0107] 102. Task loop: For each task, update the category count, add the category count of the new task to the accumulated category count, and synchronously update the current accumulated category count to the global model.
[0108] 103. Training Round Loop: In each training round under each task, perform the following operations on each client:
[0109] (1) Similarity calculation: Calculate the similarity between the image feature vector of the first image sample and the second image feature vector of the pseudo image sample of the old task to obtain a similarity matrix.
[0110] (2) Maximum similarity extraction: Find the maximum similarity in the similarity matrix and use it as the basis for subsequent dynamic adjustment.
[0111] (3) Weight adjustment: A nonlinear transformation function is used to convert the maximum similarity into a dynamic weight, which is used to balance the degree of distillation of new and old task knowledge.
[0112] (4) According to the calculated weights, set the knowledge distillation loss and cross entropy classification loss weights to adapt to the learning requirements of the new task.
[0113] (5) On the client side, the cross entropy classification loss is calculated and multiplied by the cross entropy classification loss weight, and the knowledge distillation loss is calculated and multiplied by the knowledge distillation loss weight; then, the total loss is calculated, and the cross entropy classification loss and the knowledge distillation loss are added together as the final loss for this round of learning.
[0114] 104. Global Update: After completing the loss calculation for each client, aggregate the client's updates into the global model to maintain consistency in federated learning.
[0115] 105. Generator training: After the task is completed, according to the number of currently known categories, call the "train generator" method to train a generator based on the global model to generate suitable pseudo image samples for the next task, supporting knowledge retention and reuse.
[0116] Please refer to Figure 5 , Figure 5 The following is a detailed description of the main steps of the algorithm execution process in the federated continuous learning method based on feature similarity for the client:
[0117] 201. Initialize categories and classification counts
[0118] The client first initializes the task categories and determines the number of categories and classification counts that need to be processed in the current task. This is the starting point of the algorithm and ensures that the model has a clear category range when processing tasks.
[0119] 202. Is this a new task?
[0120] Determine whether the current task is a new task: If it is a new task, update the category count and the number of task categories: Update the current category count and the total number of categories according to the information of the new task. Then, go to the subsequent steps. If it is not a new task, skip the category update step and directly process the existing task.
[0121] 203. Get the generator
[0122] The client obtains the generator from the server or an existing model. The generator generates pseudo image samples and their feature vectors based on the data features of the old task, representing the relevant information of the old task.
[0123] 204. Get the current sample feature vector
[0124] Extract the first image sample (data of the new task) from the current task and calculate its corresponding feature vector.
[0125] 205. Similarity calculation and dynamic weight generation
[0126] The feature vector of the current task sample is matched with the feature vector of the pseudo image sample, a similarity matrix is constructed, and the maximum similarity is obtained from it. Then, the maximum similarity is normalized by a preset nonlinear conversion function (such as the Sigmoid function) to generate a dynamic weight for subsequent loss weight adjustment.
[0127] 206. Dynamic loss weight allocation
[0128] The weights of the two losses are assigned according to the generated dynamic weights to ensure a balanced learning between the new and old tasks.
[0129] in:
[0130] Knowledge distillation loss weight: prioritize samples similar to old tasks and strengthen the retention of old task knowledge.
[0131] Cross-entropy classification loss weight: prioritize samples that are dissimilar to old tasks and optimize learning of new tasks.
[0132] 207. Loss calculation and model optimization
[0133] The knowledge distillation loss and the cross entropy classification loss are combined into a total loss function, and the total loss is used to optimize the local model and update the weights.
[0134] 208. Local model weight update completed
[0135] After an optimization cycle, the weights of the local model are updated. The updated weights are sent to the server for global aggregation and further federated learning.
[0136] Please refer to Figure 6 , Figure 6 This is the algorithm execution process on the server side in the federated continuous learning method based on feature similarity. The following is a detailed description of the main steps in the figure:
[0137] 301. Initialize the global model
[0138] The server first initializes a global model to integrate the learning results of all clients. This global model is the core of federated learning and ensures knowledge sharing between different clients.
[0139] 302. Check for client updates
[0140] Is there a client updating weights: If a client has completed local training and uploaded weights, go to the next step to update the global model. If no client has updated weights, pause the operation and wait for the client to complete training.
[0141] 303. Global Aggregation
[0142] The server receives the local model weights uploaded by all clients, ensuring that the global model can integrate the learning results of all clients while retaining privacy. The server integrates the weights of all clients, usually using a weighted average (for example, assigning weights based on the amount of data) to generate an updated global model.
[0143] 304. Update the global model
[0144] Based on the aggregated results, the global model weights are updated, which enables the global model to reflect the latest training results and be used for the next round of federated learning.
[0145] 305. Training Generator
[0146] Using the category information in the updated global model, the generator is trained. The generator is used to generate pseudo image samples that represent the data features of the old task. Through the generator, the server can provide the client with knowledge support for the old task without storing real data.
[0147] 306. Distributing Global Models and Generators
[0148] The updated global model and generator are sent to all clients, and the clients perform further local training based on the latest global model weights. The clients use the generator to generate pseudo image samples for knowledge distillation and optimization during task switching.
[0149] 307. End or loop
[0150] If all learning tasks are completed, the process ends. If there are still unfinished tasks, the process returns to the step of checking client updates and enters the next round of learning cycle.
[0151] The algorithms on the client and server sides work together to achieve the effect of federated continuous learning: the client side balances the learning of new tasks and the retention of old task knowledge through feature similarity and dynamic weight allocation while protecting data privacy; the server side updates the global model by aggregating the model weights of the clients and trains the generator to provide pseudo-image sample support for the clients, thereby achieving knowledge sharing and dynamic optimization while ensuring privacy, thereby improving the learning efficiency and stability of the entire system.
[0152] The performance of the proposed AWAS model is compared with two federated learning methods (FedAvg and FedProx) and one federated continuous learning method (MFCL) as baselines. The experimental results are summarized in tables and figures, highlighting the effectiveness of AWAS under various conditions.
[0153] Basic Experiments: In the first experiment, we evaluated AWAS on CIFAR-100.] , TinyImageNet and SuperImageNet. These four metrics clearly show the ability of each model to learn new tasks and maintain the performance of previously learned tasks. As expected, the FedAvg and FedProx models have the highest forgetting values. This is because they are not optimized to retain knowledge of previous tasks, resulting in the so-called catastrophic forgetting. In contrast, MFCL and our method perform well in reducing forgetting. It is worth noting that our method performs well on a range of datasets, especially on the more difficult TinyImageNet and SuperImageNet datasets. Although MFCL is also effective in mitigating forgetting, our method not only retains knowledge of old tasks more effectively, but also achieves higher accuracy when dealing with new tasks, indicating that our method has stronger generalization and anti-forgetting capabilities. Overall, our method outperforms existing methods in multiple key metrics, especially on complex datasets.
[0154] Table 1: Results of different methods on CIFAR-100, TinyImageNet and SuperImageNet.
[0155]
[0156] Experiments with different task IDs: Figure 7 , Figure 8 and Fig. 9 The accuracy performance of the model for each observation category on different datasets is demonstrated. That is, after completing each task, the performance of the model on all previous tasks is evaluated, and the average accuracy and task ID of each task are recorded. The results show that on all three datasets, this method consistently outperforms the baseline model, especially on the TinyImageNet and SuperImageNet datasets, where the accuracy improvement is particularly significant, with an improvement of at least 10%. Although the MFCL model also uses a generator to mitigate catastrophic forgetting, this method achieves a more significant improvement in accuracy through an adaptive weight adjustment method based on similarity metrics. This method dynamically adjusts the importance weights of each task, allowing the model to more efficiently integrate information from different tasks, thereby better retaining knowledge of previous tasks when learning new tasks.
[0157] Experiments with increasing client data: We believe that the number of clients in CIFAR100 is relatively small. Therefore, we choose to increase this number to 50 and set the number of clients participating in each round to 5. The results are as follows: Fig.10 shown.
[0158] Experiments with increasing number of tasks: Fig.11The accuracy performance of the model is shown as the number of tasks increases from T=10 to T=20. The data clearly shows that the method presented in this paper consistently outperforms the MFCL model as the number of tasks increases. It is worth noting that this performance gap becomes particularly pronounced after the third task, where the model achieves a significantly higher average accuracy. This trend demonstrates the model’s strong classification capabilities when faced with the inherent complexity of multi-task scenarios.
[0159] like Fig.12 As shown, across a range of tasks, the model achieves significantly lower variance in accuracy than the MFCL model. Notably, on Task 10, the model achieves an impressive variance of less than 0.003. This result demonstrates that our model is highly adaptable and consistent across multi-task learning, indicating that it is highly effective at preserving knowledge and minimizing performance fluctuations. The reduction in variance is of particular significance as it shows that our model not only achieves high accuracy, but also maintains this accuracy remarkably well across a wide range of situations. This reliability is particularly important in applications where consistency of performance is extremely important.
[0160] Since the AWAS model combines the characteristics of federated learning and continuous learning, and solves problems such as data privacy protection, computing resource limitations, and catastrophic forgetting, it has broad practical application prospects. The following are possible practical applications of the AWAS model:
[0161] 1. Personalized recommendations on mobile devices:
[0162] In mobile devices, user behavior data is highly personalized and privacy-sensitive. The AWAS model can be applied to user behavior analysis and personalized recommendation systems. It can learn and adapt to new tasks (such as new recommendation categories) on user devices through federated learning, while avoiding uploading user data to the server to protect data privacy. The pseudo-image samples generated by the generator can help the model transfer knowledge between different devices and improve the accuracy and personalization of the recommendation system.
[0163] 2. Intelligent medical health monitoring:
[0164] In the healthcare field, patients' medical records are highly sensitive information and require strict privacy protection. The AWAS model can be used in intelligent health monitoring systems to help learn models of different diseases in a distributed manner (for example, in hospitals or on devices), avoid catastrophic forgetting, and ensure that the diagnosis of new diseases does not overwrite or forget existing disease models. By generating pseudo-image samples through the generator, medical data does not need to be stored centrally, thereby effectively protecting patient privacy.
[0165] 3. Smart Home and Internet of Things (IoT) Devices:
[0166] In smart home and IoT environments, the data collected by various devices are distributed on different terminal devices and have various application scenarios (such as voice assistants, security monitoring, environmental monitoring, etc.). The AWAS model can help smart devices to continuously adapt to new device environments or tasks (such as new user commands, device functions or environmental changes) using federated learning while protecting user privacy, while maintaining memory of old tasks and improving the intelligence level of devices.
[0167] 4. Fraud Detection in the Financial Industry:
[0168] In the financial industry, customer transaction data involves privacy protection, and new fraud behaviors continue to emerge. The AWAS model can be applied to distributed fraud detection systems. Through federated learning, the model is trained on terminal devices of different banks or financial institutions to avoid uploading sensitive data to the central server. At the same time, with the introduction of new fraud patterns, the AWAS model can effectively avoid the degradation of fraud detection performance caused by catastrophic forgetting, and generate pseudo-image samples through the generator to supplement historical data and improve the detection ability of the system.
[0169] 5. Autonomous Driving System:
[0170] In autonomous driving technology, data generated by multiple sensors (such as cameras, lidar, GPS, etc.) need to be protected for privacy, and tasks under different road, weather and other environmental conditions are significantly different. The AWAS model can conduct federated learning between vehicles, train and update autonomous driving algorithms, avoid overwriting existing driving experience when learning new roads or scenes, and use pseudo-image samples generated by the generator to maintain memory of old tasks, thereby improving the adaptability and safety of the autonomous driving system.
[0171] 6. Cross-domain Natural Language Processing (NLP):
[0172] In NLP applications, language models in different fields need to adapt to multiple languages and contexts. The AWAS model can be used for cross-domain NLP tasks, training models on data from different fields through federated learning while avoiding catastrophic forgetting. By generating pseudo-image samples, the model's adaptability to new fields can be improved without centrally storing domain data, such as migrating from the medical field to the legal field, while maintaining the model's memory of the old field.
[0173] 7. Predictive Maintenance in Industrial Internet of Things (IIoT):
[0174] In industrial IoT applications, the data of each device needs to be kept private, and the failure mode of the device may change over time. The AWAS model can learn across different devices or factories through federated learning, and avoid forgetting old failure modes when introducing new types of failures. At the same time, by generating pseudo-image samples to supplement the failure data of different devices, the generalization ability and stability of the predictive maintenance system can be improved.
[0175] In summary, the method provided in the embodiments of the present application has a wide range of application scenarios, and is particularly suitable for environments that require privacy protection, data dispersion, and continuous adaptation to new tasks. It can provide effective solutions in the fields of smart health, finance, autonomous driving, recommendation systems, NLP, etc.
[0176] Example 3
[0177] An embodiment of the present application also provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, a federated continuous learning method based on feature similarity can be implemented.
[0178] The processor of the computer device is used to perform computing tasks and data processing. The device is equipped with a memory for storing computer programs, model parameters and other data. The memory receives image data and pseudo image samples uploaded by the client and stores them in the memory. The input interface receives data from the client, and the image data extracts feature vectors through the feature extraction module. The processor constructs a similarity matrix based on the feature vectors of the image samples and pseudo image samples, and converts the maximum similarity into a dynamic weight through a preset nonlinear conversion function. According to the dynamic weight, the calculation module calculates the total loss of the knowledge distillation loss and the cross entropy classification loss. After updating the local model weight according to the total loss, the processor sends the updated model weight to the server. After receiving the model weights updated by multiple clients, the server performs global aggregation to generate a global model. After completing the learning cycle, the server trains the generator according to the global model and sends the generator to the client for the next task learning.
[0179] A computer-readable storage medium is also provided, storing a computer program, which, when executed by a processor, can implement a federated continuous learning method based on feature similarity.
[0180] The computer-readable storage medium includes a computer program stored therein, and the storage medium may be a hard disk, an optical disk, a flash memory card, or other forms of available storage devices. The computer program includes multiple modules. The first part is responsible for receiving the image data and pseudo-image samples uploaded by the client and extracting their feature vectors; the second part constructs a similarity matrix and calculates the maximum similarity based on the feature vector; the third part converts the maximum similarity into a dynamic weight using a preset nonlinear conversion function; the fourth part calculation module calculates the total loss of knowledge distillation loss and cross entropy classification loss based on the dynamic weight; the fifth part update module updates the client model weight based on the total loss and sends the update result to the server. After the processor executes this computer program, according to the method steps, it receives image data, constructs a similarity matrix, calculates the loss using dynamic weights, and updates the model, ultimately improving the generalization ability and stability of the model.
[0181] Those skilled in the art will appreciate that the embodiments of the present invention may be provided as methods, systems or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware.
[0182] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0183] The above-mentioned embodiments only express several implementation methods of the present invention, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, and these all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A federated continuous learning method based on feature similarity, characterized in that: include: S1. Receive image data from at least one client, wherein the image data of each client includes a first image sample and a first image feature vector of a new task; receive a pseudo image sample of an old task generated by a generator on the server side and its corresponding image feature vector, wherein the pseudo image sample is used to represent the data features of the old task; S2. constructing a similarity matrix based on the image feature vectors of the first image sample and the pseudo image sample, and obtaining the maximum similarity; S3. Using a preset nonlinear conversion function, the maximum similarity is converted into a dynamic weight; S4. According to the dynamic weight, set the weights of knowledge distillation loss and cross entropy classification loss, and calculate the total loss of knowledge distillation loss and cross entropy classification loss; S5. At least one client updates the local model weight based on the total loss and sends it to the server; the server receives the local model weight of at least one client and performs global aggregation, and updates the global model; S6. After completing at least one learning cycle from S1 to S5, the server trains a generator according to the global model and sends the generator to at least one client.
2. The method according to claim 1, characterized in that In step S1, random noise is input into the generator on the server side, and the generator is trained using a data-free knowledge extraction method to obtain pseudo samples of old tasks.
3. The method according to claim 1, characterized in that: The maximum similarity is calculated according to the following formula: Among them, S represents the similarity between the new task and the old task, n represents the dimension of the feature vector, i represents the i-th dimension in the feature vector, and f i represents the feature vector component of the i-th dimension new task image sample, p i represents the feature vector component of the old task in the i-th dimension, Indicates the maximum similarity between the new task and the old task.
4. The method according to claim 3, characterized in that The preset nonlinear conversion function in step S3 is a Sigmoid function, and the Sigmoid function maps the maximum similarity to a dynamic weight in the range (0, 1); the dynamic weight is used to adjust the weight ratio of the knowledge distillation loss and the cross entropy classification loss.
5. The method according to claim 4, characterized in that The calculation formula of the dynamic weight is: The formula for the weight ratio is ω KD =ω,ω CE =1-ω; where ω is the dynamic weight, ω KD is the knowledge distillation loss weight, ω CE is the cross entropy loss weight.
6. The method according to claim 5, characterized in that The generator training process in step S6 also introduces a diversity loss that takes into account information entropy loss, and the formula is: Among them, L div represents the diversity loss, H info represents information entropy loss, B represents batch size, represents the i-th generated image sample, Represents the predicted probability distribution of the current model F for the i-th generated image sample.
7. The method according to claim 6, characterized in that It also includes training the generator using a batch loss function, the formula of the batch loss function is Among them, L BN represents the batch statistical loss, D KL represents the KL divergence, represents the .0 data distribution of the real image sample 0, μ i is the mean of the i-th image sample in the batch, σ i represents the standard deviation of the image samples, is the variance of the i-th image sample in the batch, represents the data distribution of generated image samples, is the mean of the generated image samples, represents the standard deviation of the generated image samples, is the variance of the generated image samples.
8. The method according to claim 7, characterized in that The method also includes processing the image output by the generator using a smoothing function, wherein the formula of the smoothing function is: Among them, L pr represents a smooth function, represents the generated image; represents the blurred image. Represents the square of the Euclidean norm.
9. A computer device, characterized in that: The computer device comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the method according to any one of claims 1 to 8 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Decentralized federal continuous learning method based on task credibility evaluation
CN121835821A