Image classification method, device and storage medium based on small sample continuous learning

By using the small-sample continuous learning method in image classification, combined with the memory mechanism and feature center calculation, the problem of catastrophic forgetting and over-fitting is solved, and the model's effective transfer ability and adaptability on small-sample data sets are achieved, which is suitable for Continuous learning needs in image classification.

CN113762402BActive Publication Date: 2024-09-06TSINGHUA UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111076143.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-14
Publication Date
2024-09-06
Estimated Expiration
2041-09-14

AI Technical Summary

Technical Problem

The existing technology has a catastrophic forgetting problem in image classification, especially under the conditions of small sample data sets. It is difficult for the model to maintain the memory of old tasks and effectively learn new tasks, and the performance of existing continuous learning methods declines in the case of massive categories. Or it limits model migration capabilities.

Method used

An image classification method based on small sample continuous learning is proposed. By obtaining large sample data sets and small sample data sets, calculating and storing the feature center and playback samples of each category, using the gradient descent algorithm to update the model, combined with the memory mechanism, Set up random replay samples and difficult-to-learn replay samples to avoid catastrophic forgetting, and determine the sample category by calculating the distance from the new sample to the category center to solve the over-fitting problem.

Benefits of technology

This method effectively avoids catastrophic forgetting, improves the model's transfer ability on new tasks, is in line with human learning and memory processes, has good interpretability and compatibility, is suitable for small sample data sets, and has a fixed storage capacity. Category center data can be ignored to adapt to the growing number of tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113762402B
    Figure CN113762402B
Patent Text Reader

Abstract

The present application provides an image classification method, device and storage medium based on continuous learning of small samples. The method includes: S1, obtaining a picture sample data set, including a large sample data set for pre-training and multiple small sample data sets for new task training; S2, training the model through the large sample data set, and storing the feature center and playback samples of each category; S3, training the model through the small sample data set and the stored feature center and playback samples of each category, and calculating multiple losses of the model; S4, weighting the multiple losses to obtain the total loss function, updating the model through the gradient descent algorithm, storing the feature center and playback samples of each category; S5, repeating steps S3 and S4 until all small sample data sets of new tasks are learned and the final model classifier is obtained. This method is more in line with the learning and memory process of people, avoiding the problem of catastrophic forgetting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer algorithms, and in particular to an image classification method based on continuous learning of small samples. Background Art

[0002] Image classification is an image processing method that distinguishes different categories of targets based on the different features reflected in the image information. Deep neural networks can extract image features very well and can automatically learn image features for classification.

[0003] As image information continues to increase and image classification tasks continue to change, we hope that machines will have the ability to continuously learn like humans and be able to complete new classification tasks. However, once the current deep learning model is used to learn a new task, although it may achieve a relatively high accuracy rate on the new task, it often seriously forgets or even completely forgets the old task. This kind of forgetting is called catastrophic forgetting.

[0004] In order to solve the problem of catastrophic forgetting, the concept of continuous learning was proposed, the goal of which is to use the same model to continuously learn multiple tasks without forgetting previously learned tasks. At present, continuous learning is divided into continuous learning based on network architecture modification, continuous learning based on replay, and continuous learning based on regularization. However, continuous learning based on network architecture modification often requires providing task numbers during testing, which does not conform to most situations in real life; continuous learning based on replay requires a portion of additional memory to store replay samples, and the performance of this method is significantly reduced in the case of massive categories; and continuous learning based on regularization may limit the model's transfer ability, that is, the ability to learn new tasks, and on the other hand, the accuracy in many experiments is not satisfactory.

[0005] In some areas where image data collection is difficult, such as the medical field, a large number of samples cannot be provided for training and learning, and only small sample data sets can be used. Small sample learning is applied to situations where learning samples are insufficient. The model has a large basic training set in the initial stage, and then only a very small number of samples can be learned for each new class. Small sample learning aims to improve the model's learning ability on new categories, regardless of the accuracy of the basic training set learned in the initial stage. This is very different from human learning. When people learn new tasks, they already have a certain amount of other knowledge reserves, but the learning of new tasks will not greatly affect the memory of old tasks.

[0006] At present, some studies have begun to focus on the accuracy of the initial training set in small-sample learning. Some of these studies generate virtual tasks based on the initial training set to train the classifier of the new task through meta-learning. Although it is called small-sample continuous learning, it does not meet the context and definition of continuous learning. According to the memory mechanism, when continuously learning new samples, whether it is the memory of the existing initial training set or the memory of the learned new classes, catastrophic forgetting must be avoided. Summary of the invention

[0007] In view of the above problems, the present application provides an image classification method, device and system based on small sample continuous learning. The technical solution of the present application is as follows:

[0008] According to a first aspect of an embodiment of the present application, there is provided an image classification method based on small sample continuous learning, comprising:

[0009] S1, obtaining a sample image dataset, wherein the sample dataset includes a large sample dataset for pre-training and a plurality of small sample datasets for new task training;

[0010] S2, training the model using the large sample data set, and storing the feature center and playback samples of each category;

[0011] S3, training the model using the small sample data set and the stored feature centers of each category and the playback samples, and calculating multiple losses of the model classifier;

[0012] S4, weighting the multiple losses to obtain a total loss function, updating the model through a gradient descent algorithm, and storing the feature center and playback samples of each category after the model is updated;

[0013] S5, repeat steps S3 and S4 until the small sample data sets of all new tasks are learned and the final model classifier is obtained.

[0014] According to a second aspect of an embodiment of the present application, there is provided an image classification device using small sample continuous learning based on a memory mechanism, comprising:

[0015] An acquisition module is used to acquire a picture sample data set, wherein the sample data set includes a large sample data set for pre-training and a plurality of small sample data sets for new task training;

[0016] A first training module, used for training the model using the large sample data set, and storing the feature center and playback samples of each category;

[0017] A second training module trains the model using the small sample data set and calculates multiple losses of the model classifier;

[0018] A model updating module, which weights the multiple losses to obtain a total loss function, updates the model through a gradient descent algorithm, and stores the feature center of each category and playback samples after the model is updated;

[0019] The repeated solving module is used to repeatedly execute the second training module and the model updating module until the small sample data sets of all new tasks are learned and the final model classifier is obtained.

[0020] According to a third aspect of an embodiment of the present application, there is provided an electronic device, including:

[0021] processor;

[0022] a memory for storing instructions executable by the processor;

[0023] The processor is configured to execute the instructions to implement the image classification method based on small sample continuous learning described in the first aspect above.

[0024] According to a fourth aspect of an embodiment of the present application, a storage medium is provided. When instructions in the storage medium are executed by a processor, the image classification method based on continuous learning of small samples described in the first aspect above can be implemented.

[0025] The technical solution provided by the embodiments of the present application brings at least the following beneficial effects:

[0026] The image classification method based on small sample continuous learning in the embodiment of the present application is more in line with the human learning and memory process. Two types of playback, random playback samples and difficult-to-learn playback samples, are set to help the model consolidate its memory of previous learning tasks, thereby avoiding catastrophic forgetting problems. According to the different modes of storing and processing long-term memory and short-term memory in the brain, two types of data, playback samples and category feature means, are stored, which is more interpretable. At the same time, two situations of small sample data sets are taken into account, which is compatible and universal. The category of the sample is judged by calculating the distance from the new sample to the category center, thereby solving the problem of overfitting that is prone to occur in small sample continuous learning, and has strong migration ability. In addition, the sample capacity that needs to be stored is fixed, and the category center data that needs to be stored can be ignored.

[0027] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application, and do not constitute an improper limitation on the present application.

[0029] Figure 1 The figure is a flowchart of an image classification method based on continuous learning of small samples according to an exemplary embodiment.

[0030] Figure 2 is a framework diagram of a small sample continuous learning method based on a memory mechanism according to an exemplary embodiment;

[0031] Figure 3 is a schematic diagram showing a situation in which task boundaries are clear according to an exemplary embodiment;

[0032] Figure 4 is a schematic diagram of a situation without task boundaries according to an exemplary embodiment;

[0033] Figure 5 The figure is a block diagram of an image classification device based on continuous learning of small samples according to an exemplary embodiment. DETAILED DESCRIPTION

[0034] In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiment of the present application will be clearly and completely described below in conjunction with the accompanying drawings. In order to enable ordinary persons in the art to better understand the technical solution of the present application, the technical solution in the embodiment of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims.

[0036] In the related art, the problem of few-shot class-incremental learning (FSCIL) is defined, and a framework based on neural gas to solve the problem is proposed. However, although the solution of neural gas can better avoid catastrophic forgetting and improve the transfer ability of new task learning, it is far from people's learning habits and memory behaviors and is not explainable. At the same time, the problem of FSCIL defined does not take into account that task learning in real life does not have a similar distribution and streaming. Therefore, it is crucial to define a scenario of small-shot continuous learning similar to the memory mechanism and provide a framework to solve the problem.

[0037] Figure 1 It is a flowchart of an image classification method based on small sample continuous learning according to an embodiment of the present application, and the method may include the following steps.

[0038] It should be noted that the small sample continuous learning problem defined in the embodiment of the present application is as follows:

[0039] Before starting small sample continuous learning, the neural network model has been trained on a large number of samples of some categories. Use the pre-trained neural network model for small sample continuous learning. Each task has some new categories, and the new categories do not overlap with the pre-trained categories. In the process of small sample continuous learning, each new category can only learn a very small number of M training samples. After training N new tasks, the model completes the training and obtains the final model. In this process, it is necessary to ensure the accuracy of the model on the new categories learned during the continuous learning process, and to ensure the accuracy of the model on the pre-trained categories.

[0040] The framework of the small sample continuous learning method based on memory mechanism proposed in this application is as follows Figure 2 See the Figure 2 , the data sets of this method include two, data set 1 is the data set required for pre-training of a large number of samples, and data set 2 is the data set for continuous learning of small samples. The main steps include pre-training, storing sample information, calculating the loss of the new model, and updating the new model. The content that needs to be stored in the learning process includes the memory information in the training process and the final model obtained by training. The stored memory information includes the feature center of each category and a part of the real samples. The real samples stored here are divided into two parts, one is the randomly selected samples of each category, and the other is the samples that are more difficult to learn in the learning process.

[0041] The above storage mechanism is similar to the memory process. During the review stage, a part of the samples of each category will be reviewed to ensure that no category is forgotten. At the same time, a part of the samples that are more difficult to learn will be recorded and reviewed intensively. In addition, the method of storing both samples and feature centers for each category is similar to the way the human brain processes memory information. The human brain stores part of the short-term memory in the hippocampus complex, while the medial prefrontal cortex is used to store long-term memory. The mean center of each category is just like the processed memory information, which is the memory of the existing learned samples, equivalent to the long-term memory stored in the prefrontal cortex, and the part of the original samples stored is equivalent to the short-term memory.

[0042] In summary, the framework proposed in this application to solve the problem of continuous learning with small samples refers to the principles of brain learning and memory, and can effectively avoid the problems of catastrophic forgetting and poor transferability during the learning process.

[0043] According to the above framework, the image classification method based on small sample continuous learning in the embodiment of the present application may include the following steps:

[0044] In step 101, a picture sample dataset is obtained, which is divided into a large sample dataset for pre-training and a plurality of small sample datasets for new task training;

[0045] In this embodiment, existing data sets, such as CUB (Caltech-UCSD Birds-200-2011, California Institute of Technology Birds 200-2011 Dataset), CIFAR100 Dataset, Tiny ImageNet Dataset are split to make them suitable for the scenario of small sample continuous learning proposed in this application. 40%-60% of the categories of the data set are set as pre-trained large sample categories, and a small number (less than 50) samples of each of the remaining sample categories are selected as new task sample training sets for small sample continuous learning. These new task samples are distinguished according to the two situations of having task boundaries and having no task boundaries, that is, they are divided into several tasks that appear in sequence or appear randomly one by one.

[0046] In the embodiment of the present application, the scenario of continuous learning of small samples is divided into two types. The first is the case where the task boundaries are clear, and the second is the case where there are no task boundaries, that is, the samples of each category in the new task appear in a streaming manner (randomly appearing one after another). These two situations are respectively as follows: Figure 3 and Figure 4 shown.

[0047] exist Figure 3 In the example, the task that is pre-trained with a large number of sample categories is recorded as task 0, and the task that is continuously learned with a small number of samples is recorded as task 1-taskN. Each task appears separately. When learning the current task, all samples of the current task can be accessed, but samples of previous tasks and pre-trained samples cannot be accessed. However, during the training process, a limited number of samples can be selected to be added to the memory bank, which has a fixed capacity and can be accessed at any time during the learning process. In this case, tasks appear one by one with clear boundaries, and the sample categories of each task have no intersection.

[0048] Figure 4 In the small sample continuous learning phase, new task samples appear randomly one by one. Figure 4 Situation and Figure 3 The difference in the situation is that Figure 4 Except for the pre-training stage, all other new samples appear randomly without a certain task boundary. New categories of samples appear one after another, and previously appeared samples cannot be accessed during training, but some samples can also be added to a fixed-capacity memory bank, and the samples in the memory bank can be accessed at any time during the learning process.

[0049] The specific problem descriptions for the two new task scenarios are as follows:

[0050] 1) When the task boundaries are clear

[0051] Assume that there are N+1 learning tasks in total, the first of which is a pre-training task with a large number of samples, and the next N are new tasks with small samples and continuous learning. The overall training dataset is in, is the training data set for the tth task. is the total number of samples for the tth task, is the image of the jth sample of the tth task, is the category label of the jth sample of the tth task.

[0052] Since the amount of data in the pre-training dataset is much larger than the amount of data in the subsequent small sample learning, the dataset needs to meet the following requirements: In this application, L (t) Represents the category of the training data of the tth task. Here, it is required that the categories learned in each task do not overlap, that is,

[0053] 2) Cases without task boundaries

[0054] The pre-training dataset is The dataset for small sample continuous learning is denoted as Compared with tasks with clear task boundaries, In the continuous learning task here, all tasks have no clear boundaries, and samples of new categories They appear randomly one after another. If you use L (0) Represents the category of data in the pre-training dataset, L (I) Represents the category of data in the continuous learning dataset, then The categories in pre-training and continuous learning training do not overlap.

[0055] For example, by training the model classifier Θ through the data set, on the one hand, catastrophic forgetting does not occur (ensuring that the pre-training category And the accuracy of the new class that has been learned), on the other hand, faced with a small amount of data in the new learning category, the classifier Θ will not overfit.

[0056] In step 102, a model classifier is trained using the large sample data set, and feature centers, difficult-to-learn samples, and random samples of each category are stored.

[0057] This example uses the ResNet18 network structure as the model classifier to train the pre-training data set The model can be written as

[0058]

[0059] g(z i )=y i

[0060] in, As a feature extractor, the sample x i The feature extraction is z i , At the model level, it can be understood as the model except for the last layer of the fully connected layer. g is a linear classifier used to extract the feature z i , mapped to the sample category logits (that is, the output of the last layer, which is also the input of SoftMax) output y i , and then the possible categories are finally obtained through the SoftMax function.

[0061] Among them, the feature center μ of each category c c , the difficult-to-learn samples are used for playback, and the random samples are used for playback.

[0062] In some embodiments, the feature center μ of each category is calculated as follows:

[0063] For category c in the pre-training sample set, calculate the feature center corresponding to the category:

[0064]

[0065] Among them, D c is a set of sample images of category c, satisfying: As mentioned above, this is the feature extraction part of the model. c The vector is stored.

[0066] For samples after task0, when the task boundaries are clear, the steps for calculating the feature center of the category are the same and can be performed after each task is learned. The difference in the formula is that for task t,

[0067] However, for streaming learning without task boundaries, the formula for calculating the feature center of the category needs to be updated in real time based on new samples:

[0068] |D c |=|D c ′|+1

[0069]

[0070]

[0071] Where x is the current sample and the corresponding y=c, D c ′ is the set of c-type samples before sample x appears. Here, we only need to record the total number |D c ′|. μ′ c is the characteristic mean of the c-type samples before the sample x appears. c with |D c | is the adjusted category mean and quantity.

[0072] Compared with image data, μ c As long as we store floating point vectors and only need to store one vector per class, the extra capacity required is negligible.

[0073] In some embodiments, the random sample set for each category is calculated as follows:

[0074] Use random selection to store samples into set X rand . The total number of samples that can be stored in all categories is fixed to M. First, calculate the number of samples that can be stored in each category M c =M / |c|. For a new sample (x, y=c), if the number of samples actually stored in class c is less than M c , then deposit directly, if greater than or equal to M c , then a random number is generated to determine whether to replace one of the original samples or abandon the sample (x, y).

[0075] In some embodiments, the calculation method of the difficult-to-learn sample set for each category is as follows:

[0076] In this embodiment, the difficulty of sample learning is determined by learning the sample and then calculating the difficulty of the sample in X rand The higher the loss function rise, the more likely it is that the sample is easily confused with the original one, and the greater the impact on the existing knowledge. If the loss function rise value ΔL is greater than a certain threshold, the sample can be stored in the difficult-to-learn sample set X. diff The difficult-to-learn samples are sorted according to the ascending value ΔL. If the set is full, the sample with the smallest ΔL is discarded.

[0077] In step 103, the model is trained using the small sample data set and the previously stored feature centers of each category and the playback samples, and multiple losses of the model are calculated;

[0078] The losses include playback sample classification loss, feature extraction offset loss, and new task classification loss.

[0079] Among them, the playback sample classification loss LReplay , feature extraction offset loss L Deviation And the new task classification loss L Classification The calculation method is as follows:

[0080] In some embodiments, by calculating the current model in the random sample set X rand and the difficult sample set X diff The Euclidean distance between the class output logits and the previously stored logits is used to obtain the replay sample classification loss L Replay :

[0081]

[0082] in, The model classifier and feature extractor currently learned; This is the model classifier and feature extractor for learning the playback sample x. To save storage, you don’t need to record the model, you only need to record the logits corresponding to the playback sample.

[0083] In some embodiments, for each category, the feature center of the category is recorded. In order to avoid the feature extractor from being too offset, the feature extraction offset loss is used here to limit the change of the feature extractor. The feature extraction offset loss L for each sample (x, y) is Deviation The calculation formula is:

[0084]

[0085] Among them, μ c is the characteristic mean of the stored c-type samples, is the current feature extractor.

[0086] In some embodiments, the new task classification loss L is calculated Classification ; For the case of task boundaries, the loss function can be calculated batch by batch:

[0087]

[0088] Among them, B is the number of samples in a batch, i is the current sample number, c is the current category, and C is the total number of categories. When sample i belongs to the true category c, y ic =1, otherwise y ic =0, p icThe probability that sample i output by the SoftMax layer belongs to category c. In this application, the data input to the SoftMax layer is the distance from the sample feature to the center of each feature currently stored, rather than the logits output. For streaming learning, it is necessary to calculate for a single sample. The loss function calculation formula for a single sample is the cross entropy function:

[0089]

[0090] Among them, x i is the current sample, i is the current sample number, c is the current category, C is the total number of categories, when sample i belongs to category c, y ic =1, otherwise y ic =0, p ic The probability that sample i output by the SoftMax layer belongs to category c.

[0091] In step 104, a total loss function is obtained by weighting the multiple losses, and the model is updated by a gradient descent algorithm. After the model is updated, the feature center, difficult-to-learn samples, and random samples of each category are stored;

[0092] In step 105, steps 103 and 104 are repeated until the small sample data sets of all new tasks are learned and the final model classifier is obtained.

[0093] This application proposes a small sample continuous learning method based on a memory mechanism that is more in line with the small sample continuous learning scenario of human learning and memory process. When this learning scenario is applied to the field of machine learning, it is consistent with the ever-evolving and ever-changing learning needs. In addition, this application divides small sample continuous learning into two situations, including both the continuous learning scenario with obvious task boundaries and the streaming learning scenario with fuzzy task boundaries, making it more compatible and universal.

[0094] The method of this application is based on the principles of human learning and memory, and designs a method of continuous learning for the situation of continuous learning of small samples. According to people's review behavior and problem sorting behavior, the method of this application sets up two types of playback: random playback samples and difficult learning playback samples, which helps the model consolidate the memory of previous learning tasks, thereby avoiding catastrophic forgetting. On the other hand, according to the different modes of storing and processing long-term memory and short-term memory in the brain, this application stores two types of data, playback samples and category feature means, respectively. In summary, the method of this application is more interpretable.

[0095] This application determines the category of the sample by calculating the distance from the new sample to the category center, thereby solving the problem of overfitting that is prone to occur in continuous learning of small samples. As a result, when learning new tasks, it has a strong transfer ability.

[0096] The sample capacity that needs to be stored in this application is fixed, and the category center data that needs to be stored can be ignored. Therefore, for the growing number of tasks, the storage space required by this method remains almost unchanged. For the growing number of tasks, the network architecture and model parameter number of this application remain almost unchanged.

[0097] Figure 5 is a block diagram of an image classification device using a small sample continuous learning based on a memory mechanism according to an embodiment of the present application. Figure 5 The device includes an acquisition module 510, a first training module 520, a second training module 530, a model updating module 540 and a repeated solving module 550.

[0098] An acquisition module 510 is used to acquire a picture sample data set, where the sample data set includes a large sample data set for pre-training and a plurality of small sample data sets for new task training;

[0099] A first training module 520, configured to train the model using the large sample data set and store the feature center and playback samples of each category;

[0100] A second training module 530 is used to train the model using the small sample data set and the stored feature centers of each category and the playback samples, and calculate multiple losses of the model classifier;

[0101] A model updating module 540 weights the multiple losses to obtain a total loss function, updates the model through a gradient descent algorithm, and stores the feature center and playback samples of each category after the model is updated;

[0102] The repeated solving module 550 is used to repeatedly execute the second training module and the model updating module until the small sample data sets of all new tasks are learned and the final model classifier is obtained.

[0103] An electronic device shown in an embodiment of the present application includes:

[0104] processor;

[0105] a memory for storing instructions executable by the processor;

[0106] The processor is configured to execute the instructions to implement the image classification method based on small sample continuous learning described in the first aspect above.

[0107] A storage medium shown in an embodiment of the present application can implement the image classification method based on small sample continuous learning as described in the first aspect above when instructions in the storage medium are executed by a processor.

[0108] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

Claims

1. An image classification method based on small sample continuous learning, characterized in that: include: S1, obtaining a sample image dataset, wherein the sample dataset includes a large sample dataset for pre-training and a plurality of small sample datasets for new task training; S2, training the model using the large sample data set, and storing the feature center and playback samples of each category; S3, training the current model through the small sample data set and the stored feature center of each category and the playback sample, and calculating multiple losses of the model; S4, weighting the multiple losses to obtain a total loss function, updating the model through a gradient descent algorithm, and storing the feature center and playback samples of each category after the model is updated; S5, repeating steps S3 and S4 until all small sample data sets of new tasks complete the learning of the model and obtain the final model classifier; The small sample data sets corresponding to the new tasks include two situations. The first situation is a situation with clear task boundaries, and each small sample data set corresponding to the new task appears separately; the second situation is a situation without task boundaries, and the small sample data sets corresponding to multiple new tasks appear randomly. For N+1 learning tasks, the first one is a pre-training task with a large sample data set, and N are new tasks with small sample continuous learning. The sample data set corresponding to the N+1 task is in, is the sample data set of the tth task, is the total number of samples for the tth task, is the jth sample image of the tth task, is the category label of the jth sample of the tth task; The first situation meets the following conditions: Among them, L (t) Represents the category of the t-th task training data; The second situation meets the following conditions: The large sample data set is denoted as The small sample data set is denoted as Use L (0) Indicates the category of data in a large sample data set, L (I) Represents the category of data in a small sample data set, then The calculation method of the feature center of each category includes: For category c in the large sample data set and category c corresponding to the small sample data set in the first case, the feature center corresponding to the category is calculated by the first formula, which is expressed as follows: Among them, D c is a sample data set of class c, is a feature extractor; For the category c corresponding to the small sample data set in the second case, its feature center is obtained by the second formula, which is expressed as follows: |D c |=|D′ c |+1 Where x is the current sample and the corresponding y=c, D′ c is the set of c-type samples before sample x appears, μ′ c is the characteristic mean of the c-type samples before the sample x appears, μ c with |D c | is the adjusted category mean and quantity.

2. The method according to claim 1, characterized in that The playback sample includes a random sample, and the method for obtaining the random sample includes: Use random selection to store samples in a random sample set; fix the total number of samples stored in all categories c to M, and calculate the maximum number of samples stored in each category M c =M / |c|, for new samples that appear, if the number of samples actually stored in category c is less than M c , then deposit directly, if it is greater than or equal to M c , then determine whether to replace one of the original samples or abandon the new sample by generating random numbers.

3. The method according to claim 2, characterized in that The playback sample includes a difficult-to-learn sample, and the method for obtaining the difficult-to-learn sample includes: If the rising value ΔL of the classification loss function on the random sample set is greater than a preset threshold, the sample is stored in a difficult-to-learn sample set. The samples in the difficult-to-learn sample set are sorted according to the rising value ΔL. If the set is full, the sample with the smallest ΔL is discarded.

4. The method according to claim 1, characterized in that: The replay samples include random samples and difficult-to-learn samples, the loss includes replay sample classification loss, and the calculation method of the replay sample classification loss includes: By calculating the current model in the random sample set X rand and the difficult sample set X diff The Euclidean distance between the class output logits and the previously stored logits is used to obtain the replay sample classification loss L Replay : in, The model classifier and feature extractor currently learned; This is the model classifier and feature extractor after learning the playback sample x.

5. The method according to claim 1, characterized in that The loss includes feature extraction offset loss, feature extraction offset loss L for each sample (x, y) Deviation The calculation formula is: wherey=c Among them, μ c is the characteristic mean of the stored c-type samples, is the current feature extractor.

6. The method according to claim 1, characterized in that The loss also includes playback sample classification loss.

7. An image classification device based on small sample continuous learning, characterized in that: include: An acquisition module is used to acquire a picture sample data set, wherein the sample data set includes a large sample data set for pre-training and a plurality of small sample data sets for new task training; A first training module, used for training the model using the large sample data set, and storing the feature center and playback samples of each category; A second training module is used to train the model through the small sample data set and the stored feature center of each category and the playback sample, and calculate multiple losses of the model classifier; A model updating module, used to weight the multiple losses to obtain a total loss function, update the model through a gradient descent algorithm, and store the feature center of each category and playback samples after the model is updated; A repeated solving module is used to repeatedly execute the second training module and the model updating module until the small sample data sets of all new tasks are learned and the final model classifier is obtained; The small sample data sets corresponding to the new tasks include two situations. The first situation is a situation with clear task boundaries, and each small sample data set corresponding to the new task appears separately; the second situation is a situation without task boundaries, and the small sample data sets corresponding to multiple new tasks appear randomly. For N+1 learning tasks, the first one is a pre-training task with a large sample data set, and N are new tasks with small sample continuous learning. The sample data set corresponding to the N+1 task is in, is the sample data set of the tth task, is the total number of samples for the tth task, is the jth sample image of the tth task, is the category label of the jth sample of the tth task; The first situation meets the following conditions: Among them, L (t) Represents the category of the t-th task training data; The second situation meets the following conditions: The large sample data set is denoted as The small sample data set is denoted as Use L (0) Indicates the category of data in a large sample data set, L (I) Represents the category of data in a small sample data set, then The calculation method of the feature center of each category includes: For category c in the large sample data set and category c corresponding to the small sample data set in the first case, the feature center corresponding to the category is calculated by the first formula, which is expressed as follows: Among them, D c is a sample data set of class c, is a feature extractor; For the category c corresponding to the small sample data set in the second case, its feature center is obtained by the second formula, which is expressed as follows: |D c |=|D′ c |+1 Where x is the current sample and the corresponding y=c, D′ c is the set of c-type samples before sample x appears, μ′ c is the characteristic mean of the c-type samples before the sample x appears, μ c with |D c | is the adjusted category mean and quantity.

8. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the image classification method based on small sample continuous learning as described in any one of claims 1 to 6.

9. A storage medium, when instructions in the storage medium are executed by a processor, can implement the image classification method based on small sample continuous learning as described in any one of claims 1 to 6.