Continuous evolutionary learning method and system for joint optimization of model and sample storage resources
Through a continuous evolutionary learning method that jointly optimizes model and sample storage resources, gradient backpropagation and Hadamard product are used to update model parameters and sample weights, solving the inefficiency problem of image recognition methods under fixed memory resource constraints and improving memory space utilization. and image storage effects.
Patent Information
- Application Number
- CN202410692426.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-05-31
AI Technical Summary
Existing continuous image recognition methods based on pre-trained models do not perform satisfactorily under fixed memory resource constraints, resulting in low memory space utilization during sample storage and limited applications.
Using a continuous evolutionary learning method that jointly optimizes the model and sample storage resources, the model can learn parameters and sample weights through gradient backpropagation and Hadamard product update, dynamically adjust model parameters and sample contribution, and optimize memory space utilization.
It achieves more efficient memory space utilization, quickly adapts to downstream tasks, breaks the limitation of solely considering model memory space optimization or sample memory space optimization, and improves image storage effects.
Smart Images

Figure CN118279701B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of continuous image recognition, and in particular to a continuous evolutionary learning method and system for joint optimization of model and sample storage resources. Background Art
[0002] With the development of deep learning technology, image recognition on closed data sets has reached the level of human matching. However, in real-world scenarios, it is difficult to collect all the required training data at once. The continuous arrival of data has limited the application of image recognition methods on closed data sets, so continuous image recognition methods have begun to develop.
[0003] The continuous image recognition method is to train the model in batches according to the categories of the data set. It is expected that the model can continuously learn the knowledge of new categories and maintain the ability to recognize the categories it has seen during the continuous training process.
[0004] The rise of pre-trained models in recent years has promoted the development of continuous image recognition methods. Existing continuous image recognition methods based on pre-trained models often focus on optimizing model memory space, such as expanding the model or performing network pruning, or optimizing sample memory space, such as storing samples with richer information, to improve memory resource utilization. However, under the limitation of fixed memory resources, these methods do not perform well, resulting in low memory space utilization when storing samples, and their application is limited. Summary of the invention
[0005] The purpose of the present invention is to address the deficiencies of the above-mentioned prior art and provide a continuous evolutionary learning method and system for joint optimization of model and sample storage resources, so as to solve the problem that these methods in the prior art perform poorly under the limitation of fixed memory resources, resulting in low utilization of memory space during sample storage and limited application.
[0006] The present invention specifically provides the following technical solution: a continuous evolutionary learning method for joint optimization of model and sample storage resources, comprising the following steps:
[0007] Collect a number of consecutive images to construct a sample data set of images;
[0008] Inputting the first batch of images in the sample data set into the neural network model, calculating the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model and turning off the mask gradient and the sample weight gradient, and updating the gradient of the learnable parameters by backpropagation of the weighted loss;
[0009] Inputting the second batch of images in the sample data set into the neural network model, calculating the unweighted loss of the neural network model by opening the gradient of the learnable parameters, the mask gradient and the sample weight gradient of the neural network model, and saving the gradients of all parameters through the unweighted loss back propagation;
[0010] When calculating weighted loss and unweighted loss, choose to turn off the gradient of learnable parameters, turn on the mask gradient and sample weight gradient, update the weighted loss and unweighted loss, and backpropagate and save the backpropagation gradients of their respective neural network models through the updated weighted loss and unweighted loss;
[0011] Updating the masked gradients of the learnable parameters of the neural network model by calculating the Hadamard product between the gradients of all the parameters and the back-propagated gradients of the neural network model after the updated weighted loss is back-propagated and saved;
[0012] Perform point multiplication on the backpropagation gradient of the neural network model obtained by backpropagation after updating the unweighted loss and the weighted loss, and update the final sample weight gradient of the neural network model;
[0013] The mask change is obtained through the updated mask gradient, the number of samples to be saved is calculated through the mask change, and the samples are selected for storage based on the final sample weight gradient and the distance from the sample to the class center.
[0014] Preferably, the step of calculating the weighted loss of the neural network model and updating the gradient of the learnable parameters by backpropagating the weighted loss comprises the following steps:
[0015] Open the neural network model to learn parameters Gradients of, close the neural network model mask gradient and sample weight gradient;
[0016] The learnable parameters of the model Perform analog quantization on each part, quantize to 16 bits and then reconstruct;
[0017] After simulation quantization is calculated according to the weighted loss formula The weighted loss is calculated, and the gradient of the learnable parameters of the neural network model is updated through the weighted loss backpropagation; the specific expression is:
[0018]
[0019] in, It is In the one-hot vector corresponding to the true label of the sample, the subscript corresponding to the true label is, Indicates that the model takes After the sample prediction scores are processed by the softmax function, the corresponding probability of the true category is It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, , is the number of the first batch of image data.
[0020] Preferably, the learnable parameters of the model According to each part, analog quantization is performed separately, and then reconstruction is performed after quantization to 16 bits. The specific expression is:
[0021]
[0022] in, represents the smallest module in the learnable parameters, Represents the operation of finding maximum and minimum values; Represents an operation of finding an absolute value; For rounding operation; Represents a clipping operation. Indicates converting the value to float16 type; Indicates the weight after quantizing the value; Represents the result of quantizing a value and then dequantizing it.
[0023] Preferably, the unweighted loss of the neural network model is calculated by opening the gradient of the learnable parameters of the neural network model, the mask gradient and the sample weight gradient, and the specific expression is:
[0024]
[0025] in, is the unweighted loss, is the number of the second batch of image data.
[0026] Preferably, the mask and sample weights of the learnable parameters of the neural network model are opened, the weighted loss is calculated, and the gradients of the mask and sample weights obtained by back propagation of the neural network model are saved by back propagation of the weighted loss. The specific expression is:
[0027]
[0028] in, is the weighted loss of the mask and sample weights of the unpacked neural network model.
[0029] Preferably, by calculating the Hadamard product between the gradient of all the parameters and the back-propagated gradient of the neural network model that is back-propagated and saved after the updated weighted loss, the specific expression is:
[0030]
[0031] Among them, ⊙ represents the vector dot multiplication operation, all_val_uw_loss_grad is the gradient of all parameters of the neural network model, and mask_train_w_loss_grad is the gradient of the back propagation of the neural network model. , lr are the weight of the parameter penalty term and the learning rate of the parameter respectively.
[0032] Preferably, the back propagation gradient of the neural network model obtained by back propagation after updating the unweighted loss and the weighted loss is point-multiplied to update the final sample weight gradient of the neural network model. The specific expression is:
[0033]
[0034] in, is the weight gradient of the first batch of image data, and λ is the learning rate of sample weight.
[0035] Preferably, after collecting a plurality of continuous images to construct a sample data set of images, preprocessing the sample data set comprises the following steps:
[0036] The images were scaled to a uniform size, randomly horizontally inverted, and normalized across channels;
[0037] The image blocks in the sample data set are scaled and cropped to a uniform size by center;
[0038] According to the current task sequence number t, the training samples of the current task category are extracted from the data set, and combined with the saved samples to form the training set of the current task;
[0039] Extract test samples of all categories of the 1-t task as the test set of the current task.
[0040] Preferably, before inputting the first batch of images in the sample data set into the neural network model, the neural network model is initialized, comprising the following steps:
[0041] If the neural network model uses a pre-trained model, the mask of the learnable parameters is initialized with the parameters of the pre-trained model;
[0042] If the neural network model uses a random initialization model, the mask of the learnable parameters is initialized with the weights of the random initialization model.
[0043] The present invention provides a continuous evolutionary learning system for joint optimization of model and sample storage resources, including:
[0044] An acquisition module, used for acquiring a number of continuous images to construct a sample data set of images;
[0045] A first processing module, used for inputting a first batch of images in the sample data set into the neural network model, calculating the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model and turning off the mask gradient and the sample weight gradient, and updating the gradient of the learnable parameters by backpropagation of the weighted loss;
[0046] A second processing module is used to input a second batch of images in the sample data set into the neural network model, calculate the unweighted loss of the neural network model by opening the gradient of the learnable parameters, the mask gradient and the sample weight gradient of the neural network model, and save the gradients of all parameters through unweighted loss back propagation;
[0047] The back-propagation gradient module is used to choose to turn off the gradient of the learnable parameters when calculating the weighted loss and the unweighted loss, turn on the mask gradient and the sample weight gradient, update the weighted loss and the unweighted loss, and back-propagate and save the back-propagation gradient of each neural network model through the updated weighted loss and the unweighted loss;
[0048] A mask update module, used to update the mask gradients of the learnable parameters of the neural network model by calculating the Hadamard product between the gradients of all the parameters and the back-propagated gradients of the neural network model that are back-propagated and saved after the updated weighted loss;
[0049] The weight update module is used to perform point multiplication on the back-propagated gradient of the neural network model obtained by back-propagating the updated unweighted loss and the updated weighted loss, and update the final sample weight gradient of the neural network model;
[0050] The sample preservation module is used to obtain the mask change through the updated mask gradient, calculate the number of samples to be saved through the mask change, and select samples for storage based on the final sample weight gradient and the distance from the sample to the class center.
[0051] Compared with the prior art, the present invention has the following significant advantages:
[0052] The present invention quickly adapts the model to downstream tasks through fine-tuning of learnable parameters, dynamically adjusts model parameters by updating learnable parameter masks, and dynamically adjusts the contribution of each sample to the model by updating sample weights; by using double-layer optimization, that is, two-batch image optimization, the updates of learnable parameters, masks and sample weights are unified, making the updates of various parts more reasonable and achieving dynamic balance, breaking the previous limitations of single consideration of model memory space optimization or sample memory space optimization, and can further improve the utilization of memory space and optimize the storage effect of images. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is the overall flow chart of the present invention. DETAILED DESCRIPTION
[0054] The following is a clear and complete description of the technical solutions of the embodiments of the present invention in conjunction with the drawings in the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0055] The present invention optimizes the memory space comprehensively by updating the model learnable parameters, the masks and sample weights corresponding to the model learnable parameters in steps. The method comprises four parts: updating the model learnable parameters, updating the masks of the model learnable parameters, updating the sample weights and saving the samples. Among them, the three parts of the parameter update are respectively performed by the derived update formulas. The sample saving method first calculates the number of samples that can be saved, and then screens and saves them according to the sample weights and the similarity between the samples and the class center. For data sets with larger image sizes, the quality of the saved images can be appropriately reduced, so that more images can be saved in a fixed space, further improving the applicability of the method.
[0056] For ease of understanding and explanation, based on Figure 1 The present invention provides a continuous evolutionary learning method for joint optimization of model and sample storage resources, comprising the following steps:
[0057] Step S1: Collect a number of continuous images to construct a sample data set of images.
[0058] This step specifically includes:
[0059] Dataset preparation:
[0060] The labels in the data set are remapped, and then the data in the training set is cropped into a uniform size of 224×224, randomly reversed horizontally, and finally standardized for each channel of the image; for the data in the test set, the image blocks in the sample data set are scaled, first scaled to 256×256, then cropped to a uniform size of 224×224 at the center, and finally standardized for each channel. There are a total of T tasks, and the tth task is now being learned; that is, according to the current task sequence number t, the training samples of the current task category are extracted from the data set, and the saved samples and the training samples of the current task category in the data set are combined into a training set; the test samples of all categories of tasks 1-t are extracted as the test set of the current task.
[0061] Initialization of parameters of each part of the model:
[0062] The model mainly uses a visual encoder and a residual network. The visual encoder uses ViT B / 16, and the residual network uses ResNet18. The visual encoder is initialized with weights pre-trained on ImageNet21k, and the pre-trained weights are used to initialize the masks of the learnable parameters. The learnable parameters are the linear layer and classification layer in the network. Random initialization is used on the residual network, and the masks of the learnable parameters are initialized with the randomly initialized model weights. The learnable parameters are the entire network. The sample weights are all initialized to 1. The sparsity rate p of the model's learnable parameters is initialized to 0, assuming that the total sparsity rate is P.
[0063] Step S2: Sample the first batch of image data from the sample data set, input the first batch of images in the sample data set into the neural network model, calculate the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model, and turning off the mask gradient and sample weight gradient, and update the gradient of the learnable parameters through weighted loss backpropagation.
[0064] This step specifically includes:
[0065] Model learnable parameter update and quantization:
[0066] The sparsity ratio of the model's learnable parameters is set to The training set of the current task is a combination of the training samples and the saved samples of the current task. A batch of training data is sampled from the training set, the number of which is , open the learnable parameters of the model Gradient of , mask that turns off the model's learnable parameters Gradients and Sample Weights Gradient. During the forward propagation process of training, the model's learnable parameters and target quantization bit 16 are passed to FakeLinearQuantizationFunction.apply for simulated quantization, and the inverse quantized value is returned. During the forward propagation process during the test, the learnable parameters of the model are simulated and quantized according to each part, that is, quantized to 16 bits and then reconstructed, as shown in the following formula:
[0067]
[0068] in, It represents the smallest module with learnable parameters, which is a linear layer in the visual encoder and a convolutional layer in the residual network. Represents the operation of finding maximum and minimum values; Represents an operation of finding an absolute value; For rounding operation; Represents a clipping operation so that the values are all within in the region; Indicates converting the value to float16 type; Indicates the weight after quantizing the value; Represents the result of quantizing and then dequantizing the value. By quantizing and dequantizing the learnable parameters, the quantization error is introduced into the training process, making the trained model more robust to the quantization effect of the parameters.
[0069] Reusing the simulated quantized , calculate the weighted loss according to the following formula, and back-propagate to update the learnable parameters of the model.
[0070]
[0071] in, It is In the one-hot vector corresponding to the true label of the sample, the subscript corresponding to the true label is, Indicates that the model takes The sample prediction score is processed by the softmax function, and the corresponding probability of the real category. It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, For the convenience of description, it will be abbreviated as , is the number of the first batch of image data.
[0072] Step S3: Sample a second batch of image data from the sample data set, input the second batch of images in the sample data set into the neural network model, calculate the unweighted loss of the neural network model by opening the gradient of the learnable parameters of the neural network model, the mask gradient of the learnable parameters and the sample weight gradient, and save the gradients of all parameters through the unweighted loss back propagation.
[0073] This step specifically includes:
[0074] Sample another batch of training data from the training set, the number is , open the learnable parameters of the model , the model’s learnable mask and sample weights During forward propagation, the mask can be learned The largest 1-p part is mapped to 1, and the rest is mapped to 0, and then combined with the learnable parameters of the model. Do a dot multiplication, that is, use the sparse model parameters for forward propagation. Then calculate the unweighted loss according to the following formula, back propagate and save the gradients of all model parameters all_val_uw_loss_grad.
[0075]
[0076] Step S4: When calculating the weighted loss and unweighted loss, choose to turn off the gradient of the learnable parameters, turn on the mask gradient and sample weight gradient, update the weighted loss and unweighted loss, and back-propagate and save the back-propagated gradients of their respective neural network models through the updated weighted loss and unweighted loss.
[0077] This step specifically includes:
[0078] Use the first batch of training data to turn off the learnable parameters of the model Gradient of , opening the mask of the model's learnable parameters and sample weights The gradient of Mapping, and then Do a dot multiplication. Calculate the weighted loss according to the following formula, back propagate and save the gradient mask_train_w_loss_grad of the model back propagation.
[0079]
[0080] Using the training data from the second batch of image data, turn off the learnable parameters of the model Gradient of , opening the mask of the model's learnable parameters and sample weights The gradient of , calculate the unweighted loss according to the following formula, back propagate and save the gradient mask_val_uw_loss_grad of the model back propagation.
[0081]
[0082] Using the training data from step S2, close the learnable parameters of the model The gradient of , which opens the mask of the model's learnable parameters and sample weights The gradient of , calculate the unweighted loss according to the following formula, back propagate and calculate the gradient mask_train_uw_loss of the model back propagation for each sample.
[0083]
[0084] in, It is In the one-hot vector corresponding to the true label of the sample, the subscript corresponding to the true label is, Indicates that the model takes After the sample prediction scores are processed by the softmax function, the corresponding probability of the true category is It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, , is the number of the first batch of image data.
[0085] Step S5: Update the mask gradients of the learnable parameters of the neural network model by calculating the Hadamard product between the gradients of all parameters and the back-propagated gradients of the neural network model that are back-propagated and saved after the updated weighted loss.
[0086] The specific expression of this step is:
[0087]
[0088] Where ⊙ represents the vector dot product operation, , lr are the weight of the parameter penalty term and the learning rate of the parameter respectively.
[0089] Step S6: Perform point multiplication on the backpropagation gradient of the neural network model obtained by backpropagation after updating the unweighted loss and the weighted loss, and update the final sample weight gradient of the neural network model.
[0090] The specific expression of this step is:
[0091]
[0092] in, is the weight gradient of the first batch of image data, λ is the learning rate of the sample weight, and after obtaining the weight update gradient, the weight is updated.
[0093] Step S7: Obtain the mask variation through the updated mask gradient, calculate the number of samples to be saved through the mask variation, and select samples for optimized storage based on the final sample weight gradient and the distance from the sample to the class center.
[0094] This step specifically includes:
[0095] According to the total model sparsity rate, the total number of samples that can be saved is calculated using the following formula.
[0096]
[0097] Among them, 4 means that each parameter originally occupies 4 bytes. Indicates the space that each sparse parameter needs to occupy when represented by a single byte of 0. Indicates the space consumed when each non-sparse parameter is converted to 16-bit storage, and R indicates the number of bytes required to store each image. For smaller images, we can directly store RGB arrays. For larger images, we store low-quality JPG images. The average number of bytes of low-quality JPG images in the training set is used as an estimate of the number of bytes required to save each image. In this way, each task can save a total of Then select samples to save and start training on the next task. Specific embodiments
[0098] Dataset preparation:
[0099] Perform the following processing in VsCode:
[0100] Read the dataset and divide it into training data and test data according to the labels in the dataset. For images and labels, we finally get data in numpy.array format. The dimensions of the image are (N, H, W, C) and the dimensions of the label are (N, 1).
[0101] Preprocess the read images and labels. The labels need to be remapped, set the random seed to 1993, use the numpy.random.permutation function, take the label length as input, and generate a new label list order. The value of the i-th position in order means that the class with the original label i will be mapped to the label order[i]. Data preprocessing, for training images, use the torchvision.transform.RandomResizedCrop function to randomly crop the length and width to The image is resized and then randomly flipped horizontally using the torchvision.transform.RandomHorizontalFlip function. Finally, the data type is converted using the torchvision.transform.ToTensor function, and the image channels are normalized using the torchvision.transform.Normalize function. For the test image, the torchvision.transform.Resize function is used to scale the length and width to Size, and then use torchvision.transform.CenterCrop function to crop the center into Size, and finally convert the data type and standardize each channel according to the above operations.
[0102] Read the current task number t and the category within the task, extract the training samples of the category within the task from the training data, combine the saved old class samples, extract the test samples of the category included in 1-t tasks from the test data, and package them into the DataLoader data type.
[0103] At this point, the dataset preparation step is completed.
[0104] Model loading and initialization:
[0105] For the visual encoder, the ViT B / 16 model structure is used, with a total of 12 model blocks, and the model weights pre-trained on ImageNet21k are loaded. The trainable part is all nn.Linear classes and classification layers; for the residual network, the ResNet18 model structure is used, and the model parameters are randomly initialized. The trainable part is the entire network. The masks of the learnable parameters are initialized with their values. The weights of the training samples are all initialized to 1.
[0106] In the inference process of the nn.Linear class, first add the simulated quantization module. If it is training, pass the weight of the class and the target quantization bit 16 to the FakeLinearQuantizationFunction.apply function, and return the weight after inverse quantization; if it is testing, manually calculate the quantized weight and weight norm, and then perform inverse quantization to obtain the parameter. Perform a dot multiplication of this parameter and the mapped mask to obtain the final parameter.
[0107] For the visual encoder, the learning rate of the classification layer is set to 1e-2, and the learning rate of the remaining learnable parts is set to 1e-4. The stochastic gradient descent optimizer is used, and the learning rate is reduced by 0.1 every 40 iterations; for the residual network, the learning rate of all parts is set to 1e-3, and the Adam optimizer is used, and the learning rate is reduced by 0.1 every 45 iterations. The visual encoder is trained on CIFAR100 for 20 training times, and the residual network is trained for 100 training times. The number of training times is set to 50 on ImageNetR, 5 datasets, CORe50 and DomainNet. The sparsity rate p of the model's learnable parameters is initialized to 0. Assuming that the total sparsity rate is P, there are a total of T tasks, and now the tth task is learned.
[0108] Parameter training:
[0109] Updates to the model's learnable parameters. Open the model's learnable parameters The gradient of , turns off the learnability of the model.
[0110] Mask and sample weights Gradient of . A batch of data is taken from the training set, the number of which is , calculate the following loss and perform Updates.
[0111]
[0112] Updates to the model's learnable parameter mask. Open the model's learnable parameters , the model’s learnable mask and sample weights Gradient. Sample another batch of training data from the training set, the number is , calculate the unweighted loss according to the following formula, backpropagate and save the gradients of all model parameters all_val_uw_loss_grad.
[0113]
[0114] use The training data in , close the learnable parameters of the model Gradient of , opening the mask of the model's learnable parameters and sample weights The gradient of , calculate the weighted loss according to the following formula, back propagate and save the gradient mask_train_w_loss_grad of the model back propagation.
[0115]
[0116] Multiply the two obtained gradients to obtain the updated gradient of the mask of the model's learnable parameters, as shown below.
[0117]
[0118] Where ⊙ represents the vector dot product operation.
[0119] Update of sample learnable weights:
[0120] use The training data in , close the learnable parameters of the model The gradient of , opens the model's learnable mask and sample weights The gradient of The formula in the figure calculates the unweighted loss, backpropagates, and saves the gradient mask_val_uw_loss_grad of the model backpropagation.
[0121] use The training data in , close the learnable parameters of the model Gradient of , opening the mask of the model's learnable parameters and sample weights The gradient of The formula in the figure calculates the unweighted loss, backpropagates, and calculates the gradient mask_train_uw_loss of the model backpropagation for each sample.
[0122] Perform vector multiplication with the gradient mask_val_uw_loss_grad obtained in this step to obtain The weight update gradients of the training data in .
[0123]
[0124] Among them, λ is the learning rate of sample weight. After obtaining the weight update gradient, the weight is updated.
[0125] Save the sample:
[0126] The mask of learnable parameters Map to 0,1, and calculate the number of samples that can be saved in the free space according to the proportion of 0. When the image size is small, calculate according to the array size of each image in the memory. When it is large, calculate according to the bytes occupied by the image saved in low-quality JPG format. Finally, combine the sample weight and the distance from the sample to the class center to select the sample for saving.
[0127] Model testing and saving:
[0128] Use the sparse model to extract the features of the test data set and predict, and calculate the prediction accuracy. When saving, only the mapped mask needs to be saved. The 1 corresponds to the weight of the float16 bit, and the 0 corresponds to the int8 type 0. The comparison results with other methods on multiple data sets are shown in Tables 1 and 2.
[0129] Table 1 Results of CIL pretreatment of VIT-B / 16
[0130]
[0131] Table 2 Results of RESNET 18 on CIL
[0132]
[0133] Based on the above methods and statements, the present invention provides a continuous evolutionary learning system for joint optimization of model and sample storage resources, including: an acquisition module, a first processing module, a second processing module, a back-propagation gradient module, a mask update module, a weight update module and a sample preservation module.
[0134] Among them, the acquisition module is used to acquire a number of continuous images to construct a sample data set of images; the first processing module is used to input the first batch of images in the sample data set into the neural network model, and calculate the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model, and turning off the mask gradient and the sample weight gradient, and update the gradient of the learnable parameters through weighted loss backpropagation; the second processing module is used to input the second batch of images in the sample data set into the neural network model, and calculate the unweighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model, the mask gradient and the sample weight gradient, and save the gradient of all parameters through unweighted loss backpropagation; the backpropagation gradient module is used to choose to turn off the gradient of the learnable parameters, turn on the mask gradient and the sample weight gradient when calculating the weighted loss and the unweighted loss. The mask update module is used to update the mask gradient of the learnable parameters of the neural network model by calculating the Hadamard product between the gradient of all parameters and the back-propagation gradient of the neural network model saved by back-propagation after the updated weighted loss; the weight update module is used to perform dot multiplication on the back-propagation gradient of the neural network model obtained by back-propagation after updating the unweighted loss and the weighted loss, and update the final sample weight gradient of the neural network model; the sample preservation module is used to obtain the mask change through the updated mask gradient, calculate the number of samples to be saved through the mask change, and select samples for storage according to the final sample weight gradient and the distance from the sample to the class center.
[0135] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the steps of a continuous evolutionary learning method for joint optimization of model and sample storage resources are implemented.
[0136] According to the disclosed embodiments, a computing device may communicate with one or more external devices (e.g., keyboards, pointing devices, Bluetooth communications, etc.), or with any device (e.g., routers, modems, etc.) that enables a computing device to communicate with one or more other computing devices.
[0137] The above content is a further detailed description of the present invention in combination with a specific preferred embodiment. For technicians in the technical field to which the present invention belongs, several simple deductions or substitutions can be made without departing from the concept of the present invention, which should be regarded as belonging to the protection scope of the present invention.
Claims
1. A continuous evolutionary learning method for joint optimization of model and sample storage resources, characterized in that: The following steps are involved: Collect a number of consecutive images to construct a sample data set of images; Inputting the first batch of images in the sample data set into the neural network model, calculating the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model and turning off the mask gradient and the sample weight gradient, and updating the gradient of the learnable parameters by backpropagation of the weighted loss; Inputting the second batch of images in the sample data set into the neural network model, calculating the unweighted loss of the neural network model by opening the gradient of the learnable parameters, the mask gradient and the sample weight gradient of the neural network model, and saving the gradients of all parameters through the unweighted loss back propagation; When calculating weighted loss and unweighted loss, choose to turn off the gradient of learnable parameters, turn on the mask gradient and sample weight gradient, update the weighted loss and unweighted loss, and backpropagate and save the backpropagation gradients of their respective neural network models through the updated weighted loss and unweighted loss; Updating the masked gradients of the learnable parameters of the neural network model by calculating the Hadamard product between the gradients of all the parameters and the back-propagated gradients of the neural network model after the updated weighted loss is back-propagated and saved; Perform point multiplication on the backpropagation gradient of the neural network model obtained by backpropagation after updating the unweighted loss, and update the final sample weight gradient of the neural network model; The mask change is obtained through the updated mask gradient, the number of samples to be saved is calculated through the mask change, and the samples are selected for storage based on the final sample weight gradient and the distance from the sample to the class center; The updated weighted loss and unweighted loss are back-propagated and their respective neural network model back-propagated gradients are saved, wherein the updated weighted loss is specifically expressed as: in, is the weighted loss of the mask and sample weights of the open neural network model, y j is the subscript corresponding to the true label in the one-hot vector corresponding to the true label of the j-th sample, It means that the model processes the predicted score of the jth sample with the softmax function, and the corresponding probability on the real category, w j It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, Sigmoid(abs(w j )), N in is the number of the first batch of image data; Input the second batch of images into the neural network model, turn off the gradient of the learnable parameters of the neural network model, turn on the mask of the learnable parameters of the neural network model and the gradient of the sample weights, and calculate the unweighted loss.
2. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 1, characterized in that: The step of calculating the weighted loss of the neural network model and updating the gradient of the learnable parameters by backpropagating the weighted loss includes the following steps: Turn on the neural network model to learn the gradient of parameter θ, and turn off the neural network model mask gradient and sample weight gradient; The learnable parameters θ of the model are simulated and quantized according to each part, and then reconstructed after quantization to 16 bits; According to the weighted loss formula, the simulated quantized θ i,dq The weighted loss is calculated, and the gradient of the learnable parameters of the neural network model is updated through the weighted loss backpropagation; the specific expression is: Among them, y j is the subscript corresponding to the true label in the one-hot vector corresponding to the true label of the j-th sample, It means that the model processes the predicted score of the jth sample with the softmax function, and the corresponding probability on the real category, w j It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, Sigmoid(abs(w j )), N in is the number of the first batch of image data.
3. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 2, characterized in that: The learnable parameters θ of the model are simulated and quantized according to each part, and then reconstructed after quantization to 16 bits. The specific expression is: i i,dq =Scale×θ i,q Among them, θ i Indicates the smallest module among the learnable parameters. max(·) and min(·) indicate the maximum and minimum value operations. abs(·) indicates the absolute value operation. Round(·) indicates the integer operation. Clamp(·) indicates the clipping operation. 16 (·) means converting the value to float16 type; θ i,q Represents the weight after quantizing the value; θ i,dq Represents the result of quantizing a value and then dequantizing it.
4. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 2, characterized in that: The unweighted loss of the neural network model is calculated by opening the gradient of the learnable parameters of the neural network model, the mask gradient and the sample weight gradient. The specific expression is: in, is the unweighted loss, N out is the number of the second batch of image data.
5. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 1, characterized in that: By calculating the Hadamard product between the gradient of all the parameters and the back-propagated gradient of the neural network model after the updated weighted loss is back-propagated and saved, the specific expression is: Among them, ⊙ represents the vector dot product operation, all_val_uw_loss_grad is the gradient of all parameters of the neural network model, mask_train_w_loss_grad is the gradient of the back propagation of the neural network model, γ and lr are the weight of the parameter penalty term and the learning rate of the parameter, respectively.
6. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 1, characterized in that: The back propagation gradient of the neural network model obtained by back propagation after updating the unweighted loss is point-multiplied to update the final sample weight gradient of the neural network model. The specific expression is: in, is the weight gradient of the first batch of image data, λ is the learning rate of sample weight, γ is the weight of the parameter penalty term, mask_val_uw_loss_grad is the gradient of backpropagation and saving the backpropagation of the model when calculating the unweighted loss, and mask_train_uw_loss is the gradient of backpropagation and calculation of the backpropagation of the neural network model for each sample when calculating the unweighted loss.
7. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 1, characterized in that: After collecting a number of continuous images to construct a sample data set of images, preprocessing the sample data set includes the following steps: The images were scaled to a uniform size, randomly horizontally inverted, and normalized across channels; The image blocks in the sample data set are scaled and cropped to a uniform size by center; According to the current task sequence number t, the training samples of the current task category are extracted from the data set, and combined with the saved samples to form the training set of the current task; Extract test samples of all categories of the 1-t task as the test set of the current task.
8. The continuous evolutionary learning method for joint optimization of model and sample storage resources as claimed in claim 1, characterized in that: Before inputting the first batch of images in the sample data set into the neural network model, the neural network model is initialized, including the following steps: If the neural network model uses a pre-trained model, the mask of the learnable parameters is initialized with the parameters of the pre-trained model; If the neural network model uses a random initialization model, the mask of the learnable parameters is initialized with the weights of the random initialization model.
9. A continuous evolutionary learning system for joint optimization of model and sample storage resources, characterized in that: include: An acquisition module, used for acquiring a number of continuous images to construct a sample data set of images; A first processing module, used for inputting a first batch of images in the sample data set into the neural network model, calculating the weighted loss of the neural network model by turning on the gradient of the learnable parameters of the neural network model and turning off the mask gradient and the sample weight gradient, and updating the gradient of the learnable parameters by backpropagation of the weighted loss; A second processing module is used to input a second batch of images in the sample data set into the neural network model, calculate the unweighted loss of the neural network model by opening the gradient of the learnable parameters, the mask gradient and the sample weight gradient of the neural network model, and save the gradients of all parameters through unweighted loss back propagation; The back-propagation gradient module is used to choose to turn off the gradient of the learnable parameters when calculating the weighted loss and the unweighted loss, turn on the mask gradient and the sample weight gradient, update the weighted loss and the unweighted loss, and back-propagate and save the back-propagation gradient of each neural network model through the updated weighted loss and the unweighted loss; A mask update module, used to update the mask gradients of the learnable parameters of the neural network model by calculating the Hadamard product between the gradients of all the parameters and the back-propagated gradients of the neural network model that are back-propagated and saved after the updated weighted loss; The weight update module is used to perform point multiplication on the back-propagated gradient of the neural network model obtained after back-propagation of the updated unweighted loss, and update the final sample weight gradient of the neural network model; The sample preservation module is used to obtain the mask change through the updated mask gradient, calculate the number of samples to be saved through the mask change, and select samples for storage based on the final sample weight gradient and the distance from the sample to the class center; The back-propagation gradient module also back-propagates and saves the back-propagation gradients of the respective neural network models through the updated weighted loss and the unweighted loss, wherein the specific expression of the updated weighted loss is: in, is the weighted loss of the mask and sample weights of the open neural network model, y j is the subscript corresponding to the true label in the one-hot vector corresponding to the true label of the j-th sample, It means that the model processes the predicted score of the jth sample with the softmax function, and the corresponding probability on the real category, w j It is a simple notation. The actual value used is the absolute value of the sample weight after being activated by the Sigmoid function, that is, Sigmoid(abs(w j )), N in is the number of the first batch of image data; Input the second batch of images into the neural network model, turn off the gradient of the learnable parameters of the neural network model, turn on the mask of the learnable parameters of the neural network model and the gradient of the sample weights, and calculate the unweighted loss.
Citation Information
Patent Citations
Image recognition method based on deep course learning
CN111160474A
Multi-modal remote sensing target robust identification method based on double-layer optimization learning
CN116434037A
Method for realizing quantum continuous learning based on quantum data by dynamically adjusting model structure
CN117634630A
Learning method and system for object tracking based on hybrid neural network
US20230153624A1
