Class increment image classification method based on task prompt attention network
By adopting a Transformer-based task prompt attention network in class incremental image classification, the stability-plasticity dilemma and resource limitation problems are solved, and efficient image classification and knowledge update are achieved.
Patent Information
- Application Number
- CN202411991661.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-31
- Publication Date
- 2025-04-18
AI Technical Summary
Class incremental image classification methods face the problems of stability-plasticity dilemma, sample imbalance and storage computing resource limitations, and it is difficult to effectively learn new knowledge while maintaining old knowledge.
Using a task prompt attention network based on Transformer structure, by introducing task-related self-attention modules and task prompt attention modules into the model, the encoder feature extracts some parameters, and only saves task-specific prompt weights for each task to alleviate catastrophic forgetting.
It effectively alleviates catastrophic forgetting in class-incremental image classification, solves the stability-plasticity dilemma, and improves the storage efficiency and classification accuracy of the model by reducing the amount of parameters and calculation costs.
Smart Images

Figure CN119851029A_ABST
Abstract
Description
Technical Field
[0001] The present invention is applicable to class-incremental image classification in the field of computer vision, and belongs to the technical field of image classification. Background Art
[0002] Incremental Learning (IL), also known as lifelong learning or continuous learning, is a new machine learning paradigm that aims to enable the model to gradually learn new knowledge over time without forgetting what it has learned before. This is consistent with the way real-world data is acquired: data is acquired in batches, which requires the model to be dynamically updated and avoid catastrophic forgetting of old task knowledge when training new tasks, reducing the computational cost of retraining.
[0003] Incremental learning mainly includes three learning settings: (1) Task-Incremental Learning (Task-IL): The model is trained between tasks with different data distributions and categories. The task ID is known during testing and the classifiers are independent. (2) Domain-Incremental Learning (Domain-IL): The model learns data with the same category but different domains. The task ID is unknown during testing and the classifiers are independent. (3) Class-Incremental Learning (Class-IL): The model learns data of different categories. The task ID is unknown during testing and all categories of data need to be predicted. The classifiers are shared. Since real-world data changes dynamically, the model needs to continuously learn new knowledge. Among the three settings, class-incremental learning is consistent with the setting of learning new knowledge in the real world. Traditional machine learning methods provide complete and static training data at one time and forget the learned categories when learning new categories. The goal of class-incremental learning is to enable the model to gradually learn new categories and reduce the forgetting of old category knowledge, so that the model can still effectively perform incremental learning under limited computing and storage resources. The technology designed by this patent belongs to the category of incremental image classification technology, that is: the model takes image classification as the task, learns images of different categories, the task ID is unknown during testing and all categories of images need to be predicted, and the classifiers are shared.
[0004] At present, there are four methods for incremental image classification: replay-based methods, regularization-based methods, knowledge distillation-based methods, and dynamic structure-based methods. Replay-based methods mitigate catastrophic forgetting by saving a small portion of old category data or features. For example, iCaRL mitigates catastrophic forgetting by maintaining a storage area for storing old task samples, but storing old samples takes up storage space; regularization-based methods consolidate old knowledge by introducing additional regularization terms in the loss function, and impose constraints on important parameters to mitigate catastrophic forgetting. For example, the elastic weight consolidation method (EWC) adds regularization terms to the loss function to constrain model parameter changes so that it keeps important parameters for old categories unchanged, thereby mitigating catastrophic forgetting. However, the importance of parameters needs to be evaluated, which increases the computational complexity; knowledge distillation-based methods provide soft labels through the old model when training new categories, and use them as targets for training, thereby maintaining knowledge of old categories. For example, the UCIR method directly penalizes changes in the feature distribution of input samples in the new and old feature spaces. However, the knowledge distillation method needs to save the output of the old model, which increases computational overhead; dynamic structure-based methods provide different model parameters for each task by modifying or expanding the network structure, thereby mitigating catastrophic forgetting. For example, the dynamically extended representation learning (DER) method consists of an old task feature extractor and a new task feature extractor to form a super feature extractor to extract the current task features, dynamically expand the network structure, and alleviate catastrophic forgetting. However, the dynamic increase in the network structure leads to a large number of parameters.
[0005] The current incremental image classification methods have the following three main difficulties to be solved: (1) Stability-Plasticity Dilemma: The model needs to maintain the ability to learn old knowledge to avoid catastrophic forgetting, that is, stability, and also needs to integrate the new knowledge learned, that is, plasticity. (2) Sample imbalance: The number of old samples saved by the playback-based method is far less than that of new classes, which will cause the model to be biased towards recognizing new classes during training; (3) Storage and computing resource limitations: Due to limited storage resources, the model cannot save all old class samples, resulting in increasingly high storage and computing costs.
[0006] Since the visual Transformer has achieved good results in the field of computer vision, this paper proposes a class-incremental image classification method based on the task-cued attention network based on the Transformer structure. The encoder feature extraction part shares parameters to reduce the computational cost, and the decoder part saves a set of task-specific cue weight parameters for each task and constructs a task-specific attention module to alleviate catastrophic forgetting, which effectively solves the class-incremental image classification dilemma and improves the classification accuracy. Summary of the invention
[0007] The present invention proposes a class incremental image classification method based on task prompt attention. In the neural network model, the Transformer model shows powerful functions. Based on the Transformer, the method adopts multiple multi-head self-attention modules as feature extractors, and then uses the designed task-related attention module to save specific attention weights for each task, which alleviates the problem of catastrophic forgetting in the class incremental image classification setting. At the same time, by introducing the task-related attention module, the knowledge of the new task can be learned while ensuring that the knowledge of the old task is not forgotten, which alleviates the stability-plasticity dilemma. In addition, as the number of categories increases, the number of model parameters of most parameter isolation-based methods will continue to increase, resulting in increased storage and computing overhead. The method proposed in the present invention adds a smaller task attention module to the framework, which only increases a small amount of parameters while ensuring the effect, and does not increase the computing cost. In summary, the present invention effectively alleviates the catastrophic forgetting in the class incremental image classification, solves the stability-plasticity dilemma, and avoids the problem of excessive model parameter storage cost.
[0008] The class-incremental image classification method based on task-cued attention network proposed in the present invention can effectively avoid the shortcomings of traditional class-incremental image classification methods. It takes Transformer as the main structure and introduces task-related self-attention modules to effectively alleviate catastrophic forgetting and solve the stability-plasticity dilemma. At the same time, this module introduces fewer additional parameters, thereby improving the storage efficiency of model parameters.
[0009] The present invention is achieved through the following technical solutions:
[0010] The input is RGB image data. The specific steps are as follows: Step 1: Establish a task-related attention model;
[0011] Step 1. Incremental segmentation of the data set into classes;
[0012] There are two datasets used: CIFAR100 and ImageNet-100, both of which are widely used for class-incremental image classification. CIFAR100 contains RGB image data of 100 categories, each image size is 32×32, and is often used for small image classification tasks. ImageNet-100 is a subset of ImageNet, containing RGB image data of 100 categories, each image size is 224×224.
[0013] According to the setting of class-incremental image classification, the dataset is first randomly shuffled by category, and then divided into several subsets according to the class increment steps. Each subset represents a task and contains different categories. The subtasks are gradually introduced into the model for training. For the CIFAR100 dataset, three class increment steps were experimented, namely 10 steps, 20 steps, and 50 steps. For the ImageNet-100 dataset, an experiment with 10 class increment steps was conducted.
[0014] Step 2. Design the overall structure of the model;
[0015] For task t, is the training data set, where Represents the input image sample set. 3×H×W means that the input RGB image has 3 channels, the image height is H, and the width is W. Represents the input sample The corresponding label set. First enter RGB image in After a block embedding module, the image is divided into tokens N represents the number of tokens, d represents the token dimension, and then the obtained tokens are input into the traditional Transformer module, which outputs features after passing through L traditional Transformer modules The task prompt is sent to the Transformer module to obtain the corresponding task-related classification logit: Then concatenate the above task-related classification logits to get the final classification logit The specific process is as follows:
[0016] Chunk embedding module x 0 =PatchEmb(x), (1)
[0017] Traditional Transformer module x l =Trans (l) (x l-1 ),l=1…L, (2)
[0018] Task prompt Transformer module
[0019]
[0020] where φ t′ is a linear classifier. During testing, the model will load the weights of the corresponding tasks to the test samples.
[0021] Step 3. Specific design of traditional Transformer module;
[0022] The traditional Transformer module consists of L Transformer layers, each of which consists of a normalization layer, a multi-head self-attention layer, and an MLP layer. The specific calculation formula is:
[0023]
[0024] Where Norm(·) represents the normalization layer, x l represents the output feature of the lth Transformer layer, L represents the total number of Transformer layers, MHA l represents the l-th multi-head self-attention layer. The specific calculation formula is as follows:
[0025]
[0026] Where H represents the total number of attention heads, Represents Query, Key and Value respectively. Represents the corresponding weight matrix. Multi-head attention concatenates the outputs of multiple self-attention heads and passes through a linear layer The final output is obtained by transformation W o is the convolution kernel parameter.
[0027] Step 4. Specific design of task prompt Transformer module;
[0028] We design a task-cued Transformer module and place it after the traditional Transformer module and before the classifier, while maintaining the classification effect while also saving a set of task-specific parameters for each task.
[0029] The task prompt Transformer module contains t branches, each of which consists of a normalization layer, a task prompt self-attention TPA layer, and an MLP layer. The normalization layer and the MLP layer are designed similarly to the traditional Transformer module, while the task prompt self-attention layer learns and saves the task prompt key T for each task. t',h ,t′=1…t,h=1…H′, H′ represents the number of attention heads of the task prompt self-attention layer to maintain the knowledge memory of each task.
[0030] Specifically, represents the final feature embedding of the task cue attention module for the t'th task, t'=1…t. The calculation formula of the task cue Transformer module is:
[0031]
[0032] TPA t′ (·) represents the task cue attention module for task t', t'=1…t, and its specific design is as follows:
[0033]
[0034] in Respectively represent the Query, Key and Value in the traditional Transformer module, Represents the corresponding weight matrix. T t,h For The task hint key is the weight, which guides the model to learn and retain task-related knowledge. Then the outputs of multiple self-attention heads are concatenated and passed through the linear layer. The final output is obtained by transformation
[0035] Finally, the output of the multi-head attention t′=1...t are sent to t classifiers φ respectively 1 ,…,φ t , the corresponding output logits are The results are spliced to get the final classification result The classification results are used to calculate the model accuracy using the loss function.
[0036] Step 2: Calculate model loss;
[0037] The model loss consists of three parts: classification loss, knowledge distillation loss, and new and old class balance loss.
[0038] Classification Loss is the cross entropy loss, and its specific expression is:
[0039]
[0040] in represents the final logit of sample x predicted by the t-th task model, represents the one-hot label vector of sample x, Represents the playback sample set of the tth task.
[0041] Knowledge Distillation Loss In order to make the feature extractor anti-forgettable, its specific expression is:
[0042] in Represents the output features of the replayed sample x in the model of the old task t-1 after the task prompt Transformer module t'th branch, t' = 1...t, concat Represents the concatenated representation of the output features of the replayed sample x obtained by the parallel branch of the old model task prompt Transformer module.
[0043] The model classifier classifies the old class into an overall category, which helps the model distinguish between old class images and new class images, and the new and old class balance loss function:
[0044]
[0045] in is the new and old class balanced label of sample x, that is, when When bagt is the one-hot label vector of the new category; when hour, One-hot label vector for all old classes after merging.
[0046] The total loss of the model is:
[0047]
[0048] Where α and β are hyperparameters.
[0049] Compared with existing methods, the present invention effectively solves the stability-plasticity dilemma in class-incremental image classification and the problem of excessive parameters in dynamic structure methods. Existing methods based on Transformer dynamic structures usually only alleviate catastrophic forgetting from the structural level. The classification accuracy is low when the same structure is used. The use of different structures for each task leads to large parameters and computational costs, while ignoring the balanced structure and instance level. The present invention adopts dual modules. The self-attention module extracts common features between tasks, and the task prompt attention module ensures the learning of task-specific knowledge, and saves task weights instead of updating tokens. Learning is performed at the sample level, which effectively reduces the number of parameters and alleviates catastrophic forgetting while ensuring classification accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 It is a flow chart of incremental image classification.
[0051] Figure 2 It is based on the task-related attention model. DETAILED DESCRIPTION
[0052] The present invention is described in detail below with reference to the accompanying drawings and embodiments.
[0053] The class-incremental image classification method based on task-cued attention network proposed in the present invention can effectively avoid the shortcomings of traditional class-incremental image classification methods. It takes Transformer as the main structure and introduces task-related self-attention modules to effectively alleviate catastrophic forgetting and solve the stability-plasticity dilemma. At the same time, this module introduces fewer additional parameters, thereby improving the storage efficiency of model parameters. Figure 2 The overall structure diagram of the model is given.
[0054] The present invention is achieved through the following technical solutions:
[0055] The input is RGB image data. The flowchart of this method is as follows Figure 1 As shown, the specific steps are as follows:
[0056] Step 1: Establish a task-related attention model;
[0057] Step 1. Incremental segmentation of the data set into classes;
[0058] There are two datasets used in this paper: CIFAR100 and ImageNet-100, both of which are widely used for class-incremental image classification. CIFAR100 contains RGB image data of 100 categories, each image size is 32×32, and is often used for small image classification tasks. ImageNet-100 is a subset of ImageNet, containing RGB image data of 100 categories, each image size is 224×224.
[0059] According to the setting of class-incremental image classification, the dataset is first randomly shuffled by category, and then divided into several subsets according to the class increment steps. Each subset represents a task and contains different categories. The subtasks are gradually introduced into the model for training. For the CIFAR100 dataset, three class increment steps were experimented, namely 10 steps, 20 steps, and 50 steps. For the ImageNet-100 dataset, 10 class increment steps were experimented.
[0060] Step 2. Design the overall structure of the model
[0061] The model as a whole consists of two parts. The model framework is as follows: Figure 2 For task t, is the training data set, where Represents the input image sample set. 3×H×W means that the input RGB image has 3 channels, the image height is H, and the width is W. Represents the input sample The corresponding label set. First enter RGB image in After a block embedding module [ Figure 2 (a) Left part], divide the image into tokens (N represents the number of tokens, d represents the token dimension), and then the obtained tokens are input into the traditional Transformer module [ Figure 2 (a) The middle part, a serial structure of multiple traditional Transformer layers, which outputs features after L traditional Transformer modules The task prompt Transformer module [ Figure 2 (a) On the right, t tasks prompt the parallel structure of the Transformer layer, and the corresponding task-related classification logit is obtained: Then concatenate the above task-related classification logits to get the final classification logit The specific process is as follows:
[0062] Chunk embedding module x 0 =PatchEmb(x), (1)
[0063] Traditional Transformer module x l =Trans (l) (x l-1 ),l=1…L, (2)
[0064] Task prompt Transformer module
[0065]
[0066] where φ t′ is a linear classifier. During testing, the model will load the weights of the corresponding tasks to the test samples.
[0067] Step 3. Specific design of traditional Transformer module
[0068] The traditional Transformer module consists of L Transformer layers, each of which consists of a normalization layer, a multi-head self-attention layer, and an MLP layer. The specific calculation formula is:
[0069]
[0070] Where Norm(·) represents the normalization layer, x l represents the output feature of the lth Transformer layer, L represents the total number of Transformer layers, MHA l represents the l-th multi-head self-attention layer. The specific calculation formula is as follows:
[0071]
[0072] Where H represents the total number of attention heads, Represents Query, Key and Value respectively. Represents the corresponding weight matrix. Multi-head attention concatenates the outputs of multiple self-attention heads and passes through a linear layer The final output is obtained by transformation W o is the convolution kernel parameter.
[0073] Step 4. Specific design of task prompt Transformer module
[0074] The present invention designs a task prompt Transformer module and places it after the feature extractor (traditional Transformer module) of the model and before the classifier. While ensuring the classification effect, a set of task-specific parameters are saved for each task. This lightweight module does not need to save the parameters of the entire model, but only needs to save the task-specific parameters of this module to alleviate catastrophic forgetting, reduce storage costs, and improve computing efficiency.
[0075] The specific parallel structure of the task prompt Transformer module is as follows Figure 2 The right part of (a) contains t branches, each of which consists of a normalization layer, a task prompt self-attention (TPA) layer, and an MLP layer. The normalization layer and the MLP layer are designed similarly to the traditional Transformer module, while the task prompt self-attention layer learns and saves the task prompt key T for each task. t',h ,t′=1...t,h=1…H′(H′ represents the number of attention heads in the task prompt self-attention layer) to maintain the knowledge memory of each task.
[0076] Specifically, represents the final feature embedding of the task cue attention module for the t'th task, t'=1…t. The calculation formula of the task cue Transformer module is:
[0077]
[0078] TPA t′ (·) represents the task cue attention module for task t', t'=1…t, and its specific design is as follows:
[0079]
[0080] in They represent Query, Key, and Value in traditional Transformer respectively. Represents the corresponding weight matrix. T t,h For The task hint key is the weight, which guides the model to learn and retain task-related knowledge. Then the outputs of multiple self-attention heads are concatenated and passed through the linear layer. The final output is obtained by transformation
[0081] Finally, the output of the multi-head attention t′=1...t are sent to t classifiers φ respectively 1 ,…,φ t , the corresponding output logits are [Formula (4)], the results are concatenated to obtain the final classification result [Formula (5)], the classification results are obtained and the model accuracy is calculated using the loss function.
[0082] Step 2: Calculate model loss
[0083] The model loss consists of three parts: classification loss, knowledge distillation loss, and new and old class balance loss.
[0084] Classification Loss is the cross entropy loss, and its specific expression is:
[0085]
[0086] in represents the final logit of sample x predicted by the t-th task model, represents the one-hot label vector of sample x, Represents the playback sample set of the tth task.
[0087] Knowledge Distillation Loss In order to make the feature extractor anti-forgettable, its specific expression is:
[0088] in Represents the output feature of the replayed sample x in the model of the old task t-1 after the task prompt Transformer module t'=1…t, concat Represents the concatenated representation of the output features of the replayed sample x obtained by the parallel branch of the old model task prompt Transformer module.
[0089] In order to solve the dilemma of catastrophic forgetting of the model, the present invention points out that the model classifier classifies the old class into a whole category, which helps the model distinguish old class images from new class images. Based on the above idea, the present invention proposes the following old and new class balance loss function:
[0090]
[0091] in is the new and old class balanced label of sample x, that is, when When bagt is the one-hot label vector of the new category; when hour, One-hot label vector for all old classes after merging.
[0092] The total loss of the model is:
[0093]
[0094] Where α and β are hyperparameters.
[0095] 1. Model details and parameter settings
[0096] The encoder of the model uses L = 5 Transformer modules, each with H = 12 attention heads, and the encoding dimension is d = 384. The decoder uses a task-cued Transformer module with H' = 12 attention heads. 。 The present invention adopts the Pytorch deep learning framework and is implemented on two NVIDIA RTX 4090 GPUs. The optimizer used is the AdamW (Adam with Weight Decay) optimizer, the initial learning rate is 0.0005, the batch size is 128, and the number of iterations is 1000. The specific parameter settings are shown in Table 1.
[0097] Table 1 Parameter settings
[0098]
[0099]
[0100] 2. Input test data set
[0101] For the CIFAR-100 dataset, a total of 10,000 images from all 100 categories are used as the test set. For the ImageNet-100 dataset, a total of 5,000 images from all 100 categories are used as the test set.
[0102] The present invention experimentally verifies the above method and evaluates the effect of class-incremental image classification on CIFAR-100 and ImageNet-100 datasets.
[0103] Table 2 CIFAR-100 incremental classification results The number of playback samples is )
[0104]
[0105]
[0106] Table 3 Classification results of ImageNet-100 (number of playback samples is )
[0107]
[0108] 1. Quantitative evaluation
[0109] Table 2 shows the results on the CIFAR-100 dataset. Param (M) in the table represents the number of parameters. The results compare the AvgAcc (average accuracy: the average of all step accuracies), LastAcc (final accuracy: the accuracy of the last step) and F (forgetting rate: the average of the difference between the accuracy of each step and LastAcc) under Top-1. The best is in bold, and the second is Dytox++ in the previous row of this method. As can be seen from the table, this method performs well at 10, 20 and 50 steps, with average accuracies of 79.82%, 78.33% and 76.53% respectively. Compared with the baseline DER, they are improved by 5.18%, 4.35% and 4.48% respectively. Compared with the number of parameters, as the number of steps increases, this method only increases a small amount of parameters, while the number of DER parameters increases explosively (from 112M to 561M), which fully reflects the effectiveness of introducing task-related attention modules in reducing parameters. Furthermore, our method surpasses the state-of-the-art method DyTox++. When considering the final accuracy, our method also outperforms other methods at 10 steps, achieving 69.76% in this step compared to 67.53% for DyTox++, an improvement of 2.23%.
[0110] Table 3 shows the results on the ImageNet-100 dataset, comparing the average top-1 and top-5 accuracy at 10 steps, as well as the final accuracy. For ImageNet-100, an average top-1 accuracy of 77.87% is achieved in the 10-step setting, exceeding the baseline DER by 1.75%. In the top-5 accuracy, this method also achieves the best results, with an average accuracy of 93.4% and a final accuracy of 88.5%, respectively, which is 1.36% and 0.52% higher than DyTox++, respectively.
Claims
1. A class-incremental image classification method based on task-cued attention network, characterized in that: The input of this method is RGB image data, and the specific steps are as follows: Step 1: Establish a task-related attention model; Step 1. Incremental segmentation of the data set into classes; There are two datasets used: CIFAR100 and ImageNet-100; According to the setting of class-incremental image classification, the dataset is first randomly shuffled by category, and then divided into several subsets according to the class increment steps. Each subset represents a task and contains different categories. The subtasks are gradually introduced into the model for training. For the CIFAR100 dataset, three class increment steps are experimented, namely 10 steps, 20 steps and 50 steps. For the ImageNet-100 dataset, 10 steps of class increment steps are experimented. Step 2. Design the overall structure of the model; For task t, is the training data set, where Represents the input image sample set, 3×H×W means the input RGB image has 3 channels, the image height is H, and the width is W; Represents the input sample The corresponding label set; first enter RGB image in After a block embedding module, the image is divided into N represents the number of tokens, d represents the token dimension, and then the obtained tokens are input into the traditional Transformer module, which outputs features after passing through L traditional Transformer modules The task prompt is sent to the Transformer module to obtain the corresponding task-related classification logit: Then concatenate the above task-related classification logits to get the final classification Step 3. Specific design of traditional Transformer module; The traditional Transformer module consists of L Transformer layers, each of which consists of a normalization layer, a multi-head self-attention layer, and an MLP layer. The specific calculation formula is: Where Norm(·) represents the normalization layer, x l represents the output feature of the lth Transformer layer, L represents the total number of Transformer layers, MHA l represents the l-th multi-head self-attention layer. The specific calculation formula is as follows: Where H represents the total number of attention heads, Represents Query, Key and Value respectively. Represents the corresponding weight matrix. Multi-head attention concatenates the outputs of multiple self-attention heads and passes through a linear layer The final output is obtained by transformation W o is the convolution kernel parameter; Step 4. Specific design of task prompt Transformer module; Design a task-cued Transformer module and place it after the traditional Transformer module and before the classifier; while ensuring the classification effect, it also saves a set of task-specific parameters for each task; The task prompt Transformer module contains t branches, each of which consists of a normalization layer, a task prompt self-attention TPA layer, and an MLP layer. The normalization layer and the MLP layer are designed similarly to the traditional Transformer module, while the task prompt self-attention layer learns and saves the task prompt key T for each task. t',h ,t′=1…t,h=1…H′, H′ represents the number of attention heads in the task prompt self-attention layer to maintain the knowledge memory of each task; Finally, the output of the multi-head attention t′=1...t are sent to t classifiers φ respectively 1 ,…,φ t , the corresponding output logits are The results are spliced to get the final classification result The classification results are used to calculate the model accuracy using the loss function; Step 2: Calculate model loss; The model loss consists of three parts: classification loss, knowledge distillation loss, and new and old class balance loss; Classification Loss is the cross entropy loss, and its specific expression is: in represents the final logit of sample x predicted by the t-th task model, represents the one-hot label vector of sample x, represents the playback sample set of the tth task; Knowledge Distillation Loss In order to make the feature extractor anti-forgettable, its specific expression is: in represents the output feature of the replayed sample x in the model of the old task t-1 after passing through the t'th branch of the task prompt Transformer module, t'=1…t, Represents the concatenated representation of the output features of the replayed sample x obtained by the parallel branches of the old model task prompt Transformer module; The model classifier classifies the old class into an overall category, which helps the model distinguish between old class images and new class images, and the new and old class balance loss function: in is the new and old class balanced label of sample x, that is, when When bagt is the one-hot label vector of the new category; when hour, The one-hot label vector of the merged category for all old categories; The total loss of the model is: Where α and β are hyperparameters.
2. The class-incremental image classification method based on task-cued attention network according to claim 1, characterized in that: CIFAR100 contains RGB image data of 100 categories, each image size is 32×32, and is often used for small image classification tasks; ImageNet-100 is a subset of ImageNet, containing RGB image data of 100 categories, each image size is 224×224.
3. The class-incremental image classification method based on task-cued attention network according to claim 1, characterized in that: The specific process of step 2 is as follows: Chunk embedding module x 0 =PatchEmb(x), (1) Traditional Transformer module x l =Trans (l) (x l-1 ),l=1…L, (2) Task prompt Transformer module where φ t′ is a linear classifier.
4. The class-incremental image classification method based on task-cued attention network according to claim 1, characterized in that: In step 4, let represents the final feature embedding of the task cue attention module for the t'th task, t'=1…t; the calculation formula of the task cue Transformer module is: TPA t′ (·) represents the task cue attention module for task t', t'=1…t, and its specific design is as follows: in Respectively represent the Query, Key and Value in the traditional Transformer module, represents the corresponding weight matrix; T t,h For The task prompt key is the weight, which guides the model to learn and retain task-related knowledge; then the outputs of multiple self-attention heads are concatenated and passed through the linear layer The final output is obtained by transformation