Method for training model by using data essence
By generating the essence of the data and combining the replay memory area and the essence memory area to train the model, the problem of AI/ML model performance degradation in the conversion of new and old data during training is solved, and the accuracy of the model on new and old data is improved, which is similar to the human memory mechanism.
Patent Information
- Application Number
- CN202410310237.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-18
- Publication Date
- 2025-09-19
AI Technical Summary
AI/ML models are prone to catastrophic forgetting when converting between old and new data for training, resulting in the model being unable to maintain good performance on both new and old data. Existing technical means, such as retaining a small amount of important data when training new data, have limited effectiveness.
The data essence training method is adopted to generate the data essence and store it in the essence memory area, and the generative model is used to restore the data structure. The playback memory area and the essence memory area training model are combined to simulate the human memory method to retain important data features.
It effectively reduces the loss of model performance during training when converting new and old data, and improves the accuracy of the model on new and old data, similar to how humans recall events from vague memories and retain important data knowledge.
Smart Images

Figure CN120673188A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to artificial intelligence (AI) and machine learning (ML), and in particular to a method for training models using the essence of data. Background Art
[0002] Catastrophic forgetting is a major concern in the practical application of AI / ML models. This occurs when a model gradually forgets previously trained data as it continues to train on new data. This results in the model failing to perform well on both new and old data, resulting in, for example, a decrease in classification accuracy.
[0003] Traditionally, combating performance loss involves retaining a small amount of important data and incorporating this retained data into new training. This approach can help mitigate performance loss, but its effectiveness is limited. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to further reduce the model performance degradation caused by the conversion training of new and old data.
[0005] According to one embodiment of the present invention, a method for training a model using data essence is performed on a computing device and includes: executing an essence generation process based on raw data to generate data essences, adding the data essences to an essence memory, and repeatedly executing a training process until the model converges. The training process includes obtaining a training batch, updating a replay memory based on the training batch, wherein the replay memory before the update includes multiple data from the previous training batch, and training the model based on the replay memory and the essence memory.
[0006] In summary, the present invention proposes a method for training a model using the essence of data, the purpose of which is to further reduce the loss of model performance caused by the conversion of old and new data during training. The concept of the present invention is to simulate the way humans store memory: the less important parts of the memory will gradually become blurred, while the more important parts remain vivid. Using this concept, the old data is converted into a highly refined data essence and then stored. In the new training, the stored data essence is restored to the original data structure using a generative model, and then re-input into the model that is being trained with new data, thereby helping the model retain the data knowledge that has been trained before and reducing the performance loss caused by model updates. The mechanism of the present invention is similar to how humans use vivid parts from fuzzy memories to help recall events.
[0007] The above description of the content of the present invention and the following description of the embodiments are used to demonstrate and explain the spirit and principle of the present invention, and to provide further explanation of the scope of the patent application of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] Figure 1 is a flow chart of a method for training a model using data essence according to an embodiment of the present invention;
[0009] Figure 2 and Figure 3 are respectively a schematic diagram and a flow chart of an essence generation procedure according to an embodiment of the present invention;
[0010] Figure 4 and Figure 5 are respectively a schematic diagram and a flow chart of a pre-training phase according to an embodiment of the present invention;
[0011] Figure 6 is a flowchart of calculating an attention score according to one embodiment of the present invention;
[0012] Figure 7 is a flow chart of a training program according to one embodiment of the present invention;
[0013] Figure 8 is a flow chart of a method for updating a playback memory area according to an embodiment of the present invention;
[0014] Figure 9 is a flow chart of an empirical fusion algorithm according to an embodiment of the present invention; and
[0015] Figure 10 and Figure 11 These are the block diagrams of the first model and the second model respectively.
[0016] Component number description
[0017] T1-T3, U1-U4, V1-V3, U21-U23, W1-W3, W21-W25, W31-W34: Steps
[0018] P0-P2: Phase
[0019] 11: Encoding Model
[0020] 13: Attention Module
[0021] 15: Noise generation module
[0022] 16: Decoding model
[0023] 17: Multiplication module
[0024] 19: Addition module
[0025] Raw data
[0026] Feature Map
[0027] noise
[0028] Data Nature
[0029] Attention score
[0030] Training data
[0031] Output
[0032] Model
[0033] First Model
[0034] Second model
[0035] 19: Generative Models
[0036] 21: First Feature Generator
[0037] 23: Second Feature Generator
[0038] 25: Classifier
[0039] M R : Data recall DETAILED DESCRIPTION
[0040] The following detailed description of the features and advantages of the present invention is provided in the following embodiments. This description is sufficient to enable anyone skilled in the art to understand the technical content of the present invention and implement it accordingly. Furthermore, based on the disclosure, claims, and figures of this specification, anyone skilled in the art can readily understand the objects and advantages of the present invention. The following examples are provided to further illustrate the concepts of the present invention and are not intended to limit the scope of the present invention in any way.
[0041] The method for training a model using data essence proposed in the present invention is executed by a computing device. In one embodiment, the computing device can be at least one of the following: a personal computer, a network server, a central processing unit (CPU), a graphics processing unit (GPU), a microcontroller (MCU), an application processor (AP), a field programmable gate array (FPGA), an application specific integrated circuit (ASIC), a system-on-a-chip (SOC), a deep learning accelerator, or any electronic device with similar functions. The present invention is not limited to the hardware type of the computing device.
[0042] Figure 1 This is a flow chart of a method for training a model using data essence according to an embodiment of the present invention, including steps T1 to T3. This method is suitable for continuous learning (CL), which refers to continuously performing multiple training tasks in a time sequence to continuously update the model. Each training task can use Figure 1 When the method of the present invention is applied to CL, the corresponding pseudo code is shown in Table 1. Please refer to Figure 1 and Form 1.
[0043] Table 1. Pseudocode of the method of using data essence to train models applied to continuous learning scenarios.
[0044]
[0045]
[0046] Please refer to row 01 of Form 1. Figure 1 Prior to the illustrated method, the computing device initializes a replay memory, an essence memory, and a model. The memory can be physical or virtual storage space and is used to store training data and the essence of data extracted based on the training data. The present invention is not limited to hardware or software implementation of the memory. In one embodiment, the replay memory and essence memory can be implemented using a network attached storage (NAS).
[0047] The following describes steps T1 to T3, assuming that Figure 1 The method shown corresponds to the i-th training task in CL (corresponding to row 02 of Table 1).
[0048] In steps T1 and T2 (corresponding to rows 03 and 04 of Table 1), the computing device executes an essence generation program to generate a data essence, which is then stored in the essence memory area. Because the training data used in the (i-1)th training task may not be available during the i-th training task, to prevent the model from losing performance due to catastrophic forgetting in subsequent training tasks, the data for the current training task is refined into a data essence and stored.
[0049] In step T3 , the computing device repeatedly executes the training procedure (corresponding to rows 05-08 of Table 1) until the model converges (corresponding to row 09 of Table 1).
[0050] The following first passes Figures 2 to 6 Explain how the data is generated, and then Figures 7 to 9 Describe the details of how the training program was performed.
[0051] Figure 2 and Figure 3 Schematic diagram and flow chart of the essence generation process according to one embodiment of the present invention. Figure 2 As shown, this procedure includes a feature generation phase P1 and an essence generation phase P2, wherein the feature generation phase P1 corresponds to step U1, and the essence generation phase corresponds to steps U2 to U4.
[0052] In step U1, the computing device converts the original data Input to the encoding model (encoder) 11, encoding model 11 simulates the way humans store memory (data) and converts the data into a feature map that only machines can understand
[0053] In one embodiment, before step U1 , the essence generation process further includes a pre-training phase. Figure 4 and Figure 5 They are respectively a schematic diagram and a flow chart of the pre-training stage according to an embodiment of the present invention. Please refer to Figure 4 and Figure 2 The pre-training stage P0 is used to train the encoding model 11 required for the feature generation stage P1 and the attention module 13 required for the essence generation stage P2.
[0054] In step V1, the computing device converts multiple training data Input to the encoding model 11 to generate multiple pre-trained feature maps. In one embodiment, the training data At least one of the datasets CIFAR-10, CIFAR-100, TinyImageNet, and ImageNet. The present invention does not limit the training data. the number and types of .
[0055] In step V2, the computing device inputs the plurality of pre-trained feature maps into the attention module 13 to calculate a plurality of pre-trained attention maps. In one embodiment, the attention module 13 can be integrated into the last layer of the encoding model.
[0056] In step V3, the computing device inputs the integration results of the plurality of pre-trained feature maps and the plurality of pre-trained attention maps into the decoding model 16 to generate a plurality of output results associated with the plurality of training data. In one embodiment, the encoding model 11 and the decoding model 16 are implemented using an autoencoder. The attention module 13 can be incorporated into the training of the autoencoder. In other embodiments, the encoding model 11 and the decoding model 16 can be implemented using the following examples, such as a multi-layer perceptron (MLP), a convolutional neural network (CNN), or a vision transformer.
[0057] Please return Figure 2 and Figure 3 In step U2, the computing device converts the feature map Input to the attention module 13 to calculate multiple attention scores For the calculation of attention score (or pre-trained attention score), please refer to Figure 6 . Figure 6 2 is a flowchart of calculating an attention score according to an embodiment of the present invention, including steps U21 to U23.
[0058] In step U21, the attention module 13 calculates the Generate an attention map, where the feature map The attention map includes multiple locations and is used to record multiple values, each of which represents the correlation between two of the multiple locations. For example, a 2×2 feature map is shown in Table 2 below, with four locations A, B, C, and D. Based on this feature map, a 4×4 attention map can be generated, which has 16 values (A, A), (A, B), ..., (D, D), where (X, Y) represents the correlation between location X and location Y.
[0059] In one embodiment, the attention module 13 is implemented using the self-attention module in the Self-Attention Generative Adversarial Networks (SAGAN). The self-attention module calculates a correlation matrix that represents the spatial dependency between any two positions in the input feature map. Each position is calculated and updated by the weighted sum of all other positions. The weight value is determined by learning the dependency between the two positions. Therefore, any two positions with similar features or strong dependencies will be represented in the correlation matrix and contribute to the final response, regardless of their distance on the input image or feature map.
[0060] Table 2. Examples of feature maps.
[0061] A B C D
[0062] Table 3. Examples of attention maps.
[0063]
[0064]
[0065] In step U22, the attention module 13 divides the multiple values into multiple groups and sums each group to generate multiple attention scores. Continuing with the previous example, based on the columns of the attention map, the attention module 13 generates four attention scores S1 to S4, where:
[0066] S1=(A,A)+(A,B)+(A,C)+(A,D)
[0067] S2=(B,A)+(B,B)+(B,C)+(B,D)
[0068] S3=(C,A)+(C,B)+(C,C)+(C,D)
[0069] S4=(D,A)+(D,B)+(D,C)+(D,D)
[0070] In step U23, the attention module 13 adjusts the numerical range of each attention score. In one embodiment, the numerical range is between 0 and 1. The adjustment method can use a softmax function, or divide a single attention score by the sum of all attention scores.
[0071] Please return Figure 2 and Figure 3 In step U3, the noise generating module 15 generates a plurality of noises Then the multiplication module 17 combines the multiple attention scores Multiplied by multiple noises to generate multiple weighted noises. is Gaussian noise. Assume that the adjusted attention score is Then the multiplication module 17 calculates Adding Noise The purpose of this is to simulate the blurring effect of human memory. The more important the position, the higher the corresponding attention score. The larger the noise The influence on the position should be smaller. In addition, the feature map The purpose of sending it to the noise generation module is to confirm how much noise needs to be generated and added to the attention map.
[0072] In step U4, the adding module 19 adds multiple weighted noises to the feature map Multiple locations to generate data essence Continuing from the previous example, assume that the attention scores S1 to S4 are adjusted to become The nature of the data As shown in Table 4 below.
[0073] Table 4, Example of data nature.
[0074]
[0075] Figure 7 is a flowchart of a training program according to an embodiment of the present invention, including steps W1 to W3.
[0076] In step W1 (corresponding to row 06 of Table 1), the computing device obtains a training batch including a plurality of data.
[0077] In step W2 (corresponding to row 07 of Table 1), the computing device updates the playback memory area according to the training batch. The playback memory area before the update includes multiple data of the old training batch. For details on the implementation of step W2, please refer to Figure 8 .
[0078] In step W3 (corresponding to row 08 of Table 1), the computing device trains the model based on the playback memory area and the intrinsic memory area. Figure 9 In the present invention, the algorithm corresponding to step W3 is called Experience Blending.
[0079] Figure 8 FIG. 1 is a flow chart of a method for updating a playback memory area according to an embodiment of the present invention. Figure 8 As shown, this method includes steps W21 to W25. Table 5 is the pseudo code corresponding to this method. Please refer to Figure 8 and Form 5.
[0080] Table 5. Pseudo code for updating the playback memory area.
[0081]
[0082] In step W21 (corresponding to row 71 of Table 5), the computing device extracts a candidate data from a plurality of data in a training batch.
[0083] In step W22 (corresponding to row 72 of Table 5), the computing device determines whether the storage space of the playback memory area has reached the upper limit. If so, the process proceeds to step W23; if not, the process proceeds to step W24.
[0084] In step W23 (corresponding to row 73 of Table 5), since the replay memory area is full, the computing device removes the least important one from the candidate data and multiple samples in the replay memory area. The least important sample corresponds to the lowest importance score. In one embodiment, the computing device uses the algorithm (Update Sample-wise Importance) in "y.Koh, D.Kim, J.-W.Ha and J.Choi, Online continuallearning on class incremental blurry task configuration with anytimeinference, ICLR, 2022, referred to as CLIB" to calculate the importance score of each sample. Specifically, the model is trained using a training batch. Then, the loss difference before and after batch training is measured for all samples. If the loss decreases, the importance score of the sample in the batch increases, and vice versa.
[0085] In step W24 (corresponding to row 75 of Table 5), since the playback memory area is not full, the computing device adds the candidate data to the playback memory area.
[0086] In step W25, the computing device determines whether there is more data in the training batch. If so, the process returns to step W21; if not, the process continues to step W3.
[0087] Through the above mechanism, the replay memory area can filter out more important data from the training batch and store them.
[0088] Figure 9 FIG. 1 is a flow chart of an empirical fusion algorithm according to an embodiment of the present invention. Figure 9 As shown, this algorithm includes steps W31 to W35. Table 6 is the pseudo code corresponding to this algorithm. Please refer to Figure 9 and Form 6.
[0089] Table 6, Pseudo code for updating the playback memory area.
[0090]
[0091] In step W31 (corresponding to row 081 of Table 6), the computing device initializes the first model and the second model according to the model. Figure 10 and Figure 11 They are the block diagrams of the first model and the second model respectively. Figure 10 and Figure 11 As shown, the first model and the second model All based on models The architecture is constructed, but each model is trained based on different data. The system includes a first feature generator 21, a second feature generator 23, and a classifier 25. In one embodiment, the first feature generator 21 and the second feature generator 23 can be implemented using the following methods: ResNet, VGG, MLP, Vision Transformer, but the present invention is not limited thereto.
[0092] In step W32 (corresponding to row 082 of Table 6), the computing device trains the first model based on the intrinsic memory area and the playback memory area. like Figure 10 As shown. The first feature generator 21 is based on the original data Generate the first feature, the encoding model 11 is based on the original data Generate feature map The second feature generator 23 generates a feature map based on the feature map The second feature is generated, and the classifier 25 performs classification based on the concatenation result of the first feature and the second feature, and finally outputs the classification result.
[0093] In step W33 (corresponding to row 083 of Table 6), the computing device trains the second model according to the intrinsic memory area.
[0094] Due to the nature of the data Not original data Therefore, it is necessary to modify the original artificial intelligence model so that it can understand the nature of the data And the essence of data Restore to the original data structure. The modified result is as follows Figure 11 As shown, the generative model 19 is based on the nature of the data Generate data anchor The first feature generator 21 generates the first feature based on the data memory, and the second feature generator 23 generates the first feature based on the data nature. The second feature is generated, and the classifier 25 performs classification based on the concatenation of the first feature and the second feature, and finally outputs the classification result. In one embodiment, the generative model 19 can be used Figure 4 The decoding model in 16.
[0095] In step W34 (corresponding to row 084 of Table 6), the computing device calculates the first model and the second model The weighted sum of is taken as the model. In detail, since the first model and the second model Having the same architecture, the corresponding parameters of the two models can be multiplied by weights α and (1-α) respectively and then added together to form the parameters of the final model. The present invention does not particularly limit the value of weight α.
[0096] Table 7 below compares the method of using data essence to train the model proposed in one embodiment of the present invention with the existing method CLIB. As can be seen from Table 7, the average accuracy (A) of the present invention on the two data sets is avg ) are better than CLIB.
[0097] Table 7, comparison between the present invention and CLIB.
[0098] Average accuracy CIFAR-100 TinyImageNet CLIB 49.22%±0.79 25.05%±0.52 The present invention 56.72%±0.27(+7.49%) 38.58%±0.78(+13.53%)
[0099] In summary, the present invention proposes a method for training a model using the essence of data, the purpose of which is to further reduce the loss of model performance caused by the conversion of old and new data during training. The concept of the present invention is to simulate the way humans store memory: the less important parts of the memory will gradually become blurred, while the more important parts remain vivid. Using this concept, the old data is converted into a highly refined data essence and then stored. In the new training, the stored data essence is restored to the original data structure using a generative model, and then re-input into the model that is being trained with new data, thereby helping the model retain the data knowledge that has been trained before and reducing the performance loss caused by model updates. The mechanism of the present invention is similar to how humans use vivid parts from fuzzy memories to help recall events.
[0100] While the present invention has been described above with reference to the aforementioned embodiments, they are not intended to limit the present invention. Any modifications and variations that do not depart from the spirit and scope of the present invention are intended to be within the scope of the present invention. Please refer to the attached claims for the scope of protection defined by the present invention.
Claims
1. A method for training a model using the essence of data, characterized in that: Executed by a computing device, and comprising: Executing an essence generation program according to original data to generate data essence; adding the data essence to an essence memory area; and A training procedure is repeatedly performed before the model converges, wherein the training procedure includes: Get a training batch; updating a replay memory area according to the training batch, wherein the replay memory area before the update includes a plurality of data of the old training batch; and The model is trained based on the playback memory area and the essential memory area.
2. The method for training a model using data essence according to claim 1, characterized in that: The essence generation procedure includes: generating a feature map based on the original data, wherein the original data is obtained from the playback memory area; Calculating a plurality of attention scores based on the feature map; multiplying the plurality of attention scores by a plurality of noises respectively to generate a plurality of weighted noises; and The plurality of weighted noises are added to the feature map to generate the data essence.
3. The method for training a model using data essence according to claim 2, characterized in that: Before generating the feature map according to the original data, the method further includes: Generate multiple pre-training feature maps based on multiple training data; Calculating a plurality of pre-trained attention maps based on the plurality of pre-trained feature maps; and A plurality of output results associated with the plurality of training data are generated according to the plurality of pre-trained feature maps and the plurality of pre-trained attention maps.
4. The method for training a model using data essence according to claim 2, characterized in that: Calculating the plurality of attention scores according to the feature map includes: generating an attention map according to the feature map, wherein the feature map includes a plurality of positions, and the attention map is used to record a plurality of values, each of the plurality of values representing a correlation between two of the plurality of positions; dividing the plurality of values into a plurality of groups, and summing each of the plurality of groups to generate the plurality of attention scores; and Adjusting the numerical range of each of the plurality of attention scores.
5. The method for training a model using data essence according to claim 1, characterized in that: Updating the replay memory area according to the training batch includes: Extracting candidate data from the plurality of data in the training batch; When the storage space of the replay memory area reaches an upper limit, removing the least important one from the candidate data and the plurality of samples in the replay memory area; and When the storage space of the playback memory area does not reach the upper limit, the candidate data is added to the playback memory area.
6. The method for training a model using data essence according to claim 1, characterized in that: Training the model according to the playback memory area and the essential memory area includes: Initializing the first model and the second model according to the model; Training the first model based on the essential memory area and the playback memory area; training the second model based on the intrinsic memory area; and A weighted sum of the first model and the second model is calculated as the model.