A small sample meta-training method based on key neuron inactivation
By deactivating key neurons in few-sample image classification, the training of non-key neurons is promoted, thereby improving feature representation capabilities, solving the problem of insufficient feature representation in the meta-training stage, and achieving higher image recognition accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-25
- Publication Date
- 2026-03-24
AI Technical Summary
Existing few-sample image classification methods lack diverse feature representation capabilities during the meta-training stage, resulting in insufficient feature extraction for the target task and affecting recognition performance.
By deactivating key neurons during training, the training of non-key neurons and their ability to learn feature representations are promoted. A metric module is constructed using a ResNet-10 backbone network and a GNN network. The cross-entropy loss function is used to guide model training. Key neuron deactivation modules are inserted layer by layer to evaluate the criticality of neurons and output featureless representations.
It improves the performance of image classification, especially on the mini-Imagenet dataset, where the accuracy of one-shot learning reaches 69% and the accuracy of five-shot learning reaches 85.87%, which is better than existing methods.
Smart Images

Figure CN120431446B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of computer vision or deep learning, small sample learning, image classification, network training strategy, network structure design, and specifically relates to a small sample meta-training method based on key neuron inactivation. BACKGROUND
[0002] Image classification refers to determining the category to which the main target in the image belongs. As a basic task in the field of computer vision, image classification has important research significance. In recent years, with the assistance of public large-scale datasets, deep learning algorithms have been widely used in image classification and have far exceeded traditional algorithms in effect. However, the dependence of deep learning algorithms on large-scale datasets limits their application in engineering. Therefore, small sample learning based on a small amount of task-related samples has been extensively and deeply studied in recent years. Small sample image classification technology refers to classifying images based on a small amount of labeled data related to the target task. The research on small sample image classification technology is of great significance for the application of deep learning-based image classification algorithms in open environments, data-sensitive or data-scarce fields.
[0003] Meta-learning is an important algorithm in the study of small sample image classification. In 2016, Google proposed a meta-learning memory enhancement network that can quickly absorb new sample data and make accurate predictions using these data. From 2016 to 2018, metric-based small sample classification methods were proposed, including Relation Network, Prototypical Network, and Graph Neural Network. The common feature of these methods is that the model contains two parts: a feature encoder and a metric module. The difference is that the metric module of different networks constitutes different methods, and the metric module of the graph neural network can be a generalization of the other two methods. Until recent years, these metric-based methods have received widespread attention, and a large number of improved algorithms based on them have been proposed, such as the feature transformation algorithm in 2020, the adversarial task enhancement algorithm in 2021, and the adversarial feature enhancement algorithm in 2022. Among these metric algorithms, the graph neural network has shown good stability and high accuracy.
[0004] Despite the numerous few-shot learning algorithms proposed, a satisfactory answer remains elusive to the question of "how to improve the feature representation capabilities learned by the network during the meta-training phase." Existing methods, lacking diverse feature representations learned during meta-training, suffer from insufficient feature representation extraction for the target task, limiting their few-shot recognition performance. A crucial setting in few-shot learning algorithms is that training and test samples belong to different categories. In this case, the primary goal of the meta-training phase is no longer to enable the model to learn abstract features specific to a particular category, but rather to acquire rich feature representation capabilities. This would provide sufficient prior knowledge to handle tasks composed of new categories, but current algorithms rarely address this issue. Summary of the Invention
[0005] To address the shortcomings of existing few-shot image classification methods in acquiring feature representations during the meta-training phase, this invention provides a few-shot meta-training method based on the inactivation of key neurons. This method inactivates key neurons during training, promoting the training of non-key neurons and their ability to learn feature representations. This allows the model to fully learn feature representations from prior knowledge, extracting diverse and robust feature representations for the target task and improving image classification performance.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0007] A few-sample meta-training method based on the inactivation of key neurons includes the following steps:
[0008] Step 1: Collect publicly labeled datasets as source datasets to train the network model;
[0009] Step 2: Perform data augmentation on the sample images in the source dataset and divide them into different few-shot learning tasks;
[0010] Step 3: Construct a network model with neuron inactivation modules for few-shot learning tasks based on metric learning; the network model uses ResNet-10 as the backbone network, inserts key neuron inactivation modules layer by layer in the backbone network, selects GNN network as the metric module, and uses the cross-entropy function to calculate the loss of the network model on the few-shot learning task.
[0011] Step 4: In each round of meta-training, the keyness of neurons is evaluated and sorted based on the gradient backpropagated to each neuron according to the loss of the network model on the few-shot learning task. Neurons with a keyness greater than a preset value are output with no feature representation and are recorded as key neurons inactivated. The key neuron inactivation cycle is set to occur from the shallow network to the deep network so that the network model updates its parameters with respect to the input few-shot learning task until training is completed and a trained network model is obtained.
[0012] Step 5: Evaluate the effect of the small sample learning model obtained by training.
[0013] Further, the specific process of the data set making in step 1 is as follows:
[0014] Step 1.1: Source data set Including sample pictures and sample picture corresponding category label, the source data set Is divided into training set And validation set According to the proportion of 8:2, the category of sample pictures in the training set And validation set Do not intersect;
[0015] Step 1.2: The source data set All samples in the working environment of the location information and the corresponding category label are saved in the file in json format.
[0016] Further, the specific process of data augmentation and task division in step 2 is as follows:
[0017] Step 2.1: All sample pictures in the training set Random data augmentation transformation operation is carried out, including random scaling and clipping, random brightness contrast adjustment, random horizontal flip, wherein the size of all input sample pictures is unified to 224 pixels x 224 pixels through random scaling and clipping;
[0018] Step 2.2: All input sample pictures are converted into tensor type, and all data are normalized to mean 0 and standard deviation 1, and then the processed sample pictures are extracted into the data loader by category;
[0019] Step 2.3: Random sampling on the source data set Form a plurality of small sample learning tasks, each small sample learning task is composed of a support set and a query set, the support set in the small sample learning task contains N categories, each category contains K marked sample pictures, the query set in the small sample task contains Q unlabeled samples belonging to the N categories as the classification target of each small sample task, define the small sample task as Wherein And Respectively represent the sample pictures on the support set and the query set, And Respectively represent the category label corresponding to the sample picture in the support set and the query set, record on the training set And validation set Of the source data set The small sample learning task set obtained by sampling is And .
[0020] Further, the specific process of constructing the network architecture based on the metric method in step 3 is as follows:
[0021] Step 3.1: The ResNet-10 backbone network is divided into 4 network layers, and a key neuron inactivation module is inserted at the end of each network layer. When the key neuron inactivation module is working, it point multiplies 0 to the feature representation vector output by the key neuron and point multiplies 1 to the feature representation vector output by other neurons; when the key neuron inactivation module is not working, it point multiplies 1 to the feature representation vector output by all neurons;
[0022] Step 3.2: After the ResNet-10 backbone network containing the neuron inactivation module obtains the feature representation of the sample picture, the GNN network is used as the metric module to classify the sample pictures in the query set based on the feature representation, obtain the posterior probability of the sample pictures belonging to each category, and calculate the cross-entropy loss between the posterior probability and the real category label to guide the model to perform supervised small sample training; the metric function corresponding to the metric module is , and the label of the predicted query sample picture is , where represents the feature representation vector of the sample picture extracted by the backbone network; according to the predicted label of the query sample picture , the loss of the small sample learning task is calculated. , where is the cross-entropy loss function.
[0023] Further, the specific process of determining the key neurons according to the gradient values backpropagated to each neuron in step 4 is as follows:
[0024] Step 4.1: Use the register_hook() function in the forward propagation code of the backbone network, which records the gradient values backpropagated to the feature representation vectors output by each neuron during backpropagation. The gradient value backpropagated to the neuron is the sum of the gradient values backpropagated to all feature representation vectors;
[0025] Step 4.2: Calculate the criticality of each neuron according to the gradient values backpropagated to the feature vectors: let the feature map output by the layer of the network model for the task be , where is the number of neurons in the layer, and represent the width and height of the output feature map of the layer, respectively. Let the feature map The backpropagation gradient value is For neurons The criticality of the network model is calculated based on the backpropagation gradients of the network model on all few-shot learning tasks in the current iteration round, as follows: ,in Describe neurons Its criticality in the current network This is the set of all few-shot learning tasks input in the current iteration round;
[0026] Step 4.3: Sort neurons according to their criticality and given inactivation ratio. Identify the key neurons in the current layer that need to be deactivated;
[0027] Step 4.4: Activate the inactivation modules of key neurons layer by layer, wherein in each training round, only one neuron inactivation module of a network layer in the network model is activated;
[0028] Step 4.5: From the validation set The set of small sample learning tasks obtained by upsampling We randomly sampled 600 tasks. When all neuron deactivation modules were ineffective, we evaluated the network model on these 600 tasks to determine which iteration yielded the optimal network model. We then selected the best-trained network model for few-shot learning.
[0029] Furthermore, step 4.3 includes: calculating the... After determining the criticality of each neuron in the layer, sort the neurons according to their criticality from highest to lowest, and find the one ranked ( The neurons and their criticality were recorded as ; Filter all neurons, if the neuron's criticality is greater than Then the neuron is determined to be a key neuron to be inactivated. When the key neuron inactivation module of the layer is activated, the first The feature representation vector output by the layer has a value of 0 for all channels corresponding to the key neurons.
[0030] Furthermore, step 4.4 includes: for the first... Training rounds, if ,in This represents the division and remainder operation, which makes the first (or second) number in the network model... The neuronal inactivation module of the layer takes effect, according to the inactivation ratio. The proportion of these factors inactivates key neurons, among which, For the total number of training rounds, The growth rate of the proportion of neuron inactivation is controlled; two forward propagations and two back propagations are required in each training round; all neuron inactivation modules are not active in the first forward propagation, and the first back propagation is performed according to the calculated loss; the forward propagation and the back propagation are performed again according to the back propagation result and the current iteration round, so that the corresponding key neuron inactivation module is active in the second forward propagation, and then the second back propagation is performed, and the entire neural network is optimized according to the gradient of the second back propagation.
[0031] Further, the specific process of evaluating the effect of the small sample learning model obtained by training in step 5 is as follows:
[0032] Further, the specific process of evaluating the effect of the small sample learning model obtained by training in step 5 is as follows:
[0033] On the other hand, the application provides a small sample meta-training device based on key neuron inactivation, comprising: a data acquisition unit for collecting a publicly labeled data set as a source data set to train a network model;
[0034] A data processing unit is configured to perform data enhancement on sample pictures in the source data set and divide them into different small sample learning tasks;
[0035] A model construction unit is configured to construct a network model containing a neuron inactivation module for a small sample learning task based on metric learning; the network model uses ResNet-10 as a backbone network, inserts key neuron inactivation modules into the backbone network layer by layer, selects a GNN network as a metric module, and uses a cross-entropy function to calculate the loss of the network model on the small sample learning task;
[0036] A model training unit is configured to, in each meta-training round, evaluate the key degree of neurons and sort them according to the gradient of the loss of the network model on the small sample learning task back-propagated to each neuron, output neurons with a key degree greater than a preset value without feature representation, and record them as key neuron inactivation, and set the key neuron inactivation cycle from the shallow network to the deep network to occur, so that the network model updates parameters with respect to the input small sample learning task until the training is completed, and a trained network model is obtained.
[0037] A model evaluation unit is configured to evaluate the effect of the small sample learning model obtained by training.
[0038] In a third aspect, the present application provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the key neuron inactivation-based few-shot meta-training method described above.
[0039] In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, enable the processor to implement the key neuron inactivation-based few-shot meta-training method described above.
[0040] The present application has the following beneficial effects:
[0041] 1. The present application proposes a new training strategy to improve the feature representation capability of the small sample image classification algorithm obtained in the meta-training stage, without introducing additional data and additional network structure, so as to efficiently learn a network with strong feature representation capability, and improve the effect of feature representation and classification of the target task;
[0042] 2. According to the key neuron inactivation-based few-shot meta-training method, the image recognition accuracy is 69% under the condition of one-shot learning using mini-Imagenet as the source data set and only one labeled sample per class, which is higher than that of the existing method;
[0043] 3. According to the key neuron inactivation-based few-shot meta-training method, the image recognition accuracy is 85.87% under the condition of five-shot learning using mini-Imagenet as the source data set and only five labeled samples per class, which is higher than that of the existing method. BRIEF DESCRIPTION OF DRAWINGS
[0044] Figure 1 is a flowchart of the key neuron inactivation-based few-shot meta-training method of the present application;
[0045] Figure 2 is a neural network structure diagram used in the present application. DETAILED DESCRIPTION
[0046] The specific implementation and working principle of the present application will be further described in detail below in combination with the drawings.
[0047] As shown in Figure 1 , a key neuron inactivation module-based few-shot meta-training method, the specific steps are as follows:
[0048] Step 1: Collect a publicly labeled data set as a source data set to train a network model;
[0049] The specific process of the data set making in step 1 is as follows:
[0050] Step 1.1: Source data set Including sample pictures and the category labels corresponding to the sample pictures, the source data set Is divided into a training set And a validation set According to the proportion of 8:2, the categories to which the sample pictures in the training set And the validation set Do not intersect;
[0051] Step 1.2: Save the position information of all samples in the working environment and the corresponding category labels in the source data set In a json format file.
[0052] Step 2: Data augmentation is performed on the sample pictures in the source data set, and the sample pictures are divided into different small sample learning tasks;
[0053] The specific process of data augmentation and task division in step 2 is as follows:
[0054] Step 2.1: Perform multiple random data augmentation transformation operations on all sample pictures in the training set , including random scaling and cropping, random brightness and contrast adjustment, and random horizontal flipping, wherein the size of all input sample pictures is unified to 224 pixels x 224 pixels through random scaling and cropping;
[0055] Step 2.2: Convert all input sample pictures to tensor type, and perform normalization operation with mean 0 and standard deviation 1 on all data, and then extract the processed sample pictures to the data loader by category;
[0056] Step 2.3: Randomly sample multiple small sample learning tasks on the source data set , each small sample learning task is composed of a support set and a query set, the support set in the small sample learning task contains N categories, and each category contains K labeled sample pictures, the query set in the small sample task contains Q unlabeled samples belonging to the N categories as the classification target of each small sample task, and the small sample task is defined as , wherein and represent the sample pictures on the support set and the query set, respectively, and represent the category labels corresponding to the sample pictures in the support set and the query set, respectively, and the sample set on the training set and the validation set of the source data set is sampled to obtain a small sample learning task set and .
[0057] Step 3: Construct a network model with neuron inactivation modules for few-shot learning tasks based on metric learning; the network model uses ResNet-10 as the backbone network, inserts key neuron inactivation modules layer by layer in the backbone network, selects GNN network as the metric module, and uses the cross-entropy function to calculate the loss of the network model on the few-shot learning task.
[0058] The specific process of constructing the network model containing the neuron inactivation module in step 3 is as follows:
[0059] Step 3.1: Divide the ResNet-10 backbone network into 4 network layers, and insert a key neuron inactivation module at the end of each network layer. When the key neuron inactivation module is working, multiply the feature representation vector output by the key neuron by 0 and multiply the feature representation vector output by the other neurons by 1. When the key neuron inactivation module is not working, multiply the feature representation vector output by the all neurons by 1.
[0060] Table 1 ResNet10 backbone network architecture
[0061]
[0062] Step 3.2: After obtaining the feature representation of the sample images using the ResNet-10 backbone network containing the neuron inactivation module, a GNN network is used as the metric module. Based on the feature representation, the sample images in the query set are classified to obtain the posterior probability of each sample image belonging to each category. The cross-entropy loss is then calculated between the posterior probability and the true class label to guide the model in supervised few-sample training. The metric function corresponding to the metric module is denoted as... , by the metric function The predicted labels for the query sample images are represented as follows: ,in This indicates that the feature representation vector of the sample image is extracted using a backbone network; the label of the query sample image is then predicted. Computational few-shot learning task loss in This is the cross-entropy loss function.
[0063] Step 4: In each round of meta-training, the keyness of neurons is evaluated and sorted based on the gradient backpropagated to each neuron according to the loss of the network model on the few-shot learning task. Neurons with a keyness greater than a preset value are output with no feature representation and are recorded as key neurons inactivated. The key neuron inactivation cycle is set to occur from the shallow network to the deep network so that the network model updates its parameters with respect to the input few-shot learning task until training is completed and a trained network model is obtained.
[0064] The specific process for determining the key neurons in step 4 based on the backpropagation gradient values of each neuron is as follows:
[0065] Step 4.1: Use the register_hook() function in the forward propagation code of the backbone network. The register_hook() function records the gradient values that are backpropagated to the feature representation vectors output by each neuron during backpropagation. The backpropagated gradient values on the neurons are the sum of the backpropagated gradient values on all feature representation vectors.
[0066] Step 4.2: Calculate the criticality of each neuron based on the gradient values backpropagated to the feature vector: Let the criticality of each neuron in the network model be... Layered tasks The output feature map is ,in This represents the number of neurons in that layer. and Let the width and height of the output feature map of this layer be denoted as , and the feature map be denoted as . The backpropagation gradient value is For neurons The criticality of the network model is calculated based on the backpropagation gradients of the network model on all few-shot learning tasks in the current iteration round, as follows: ,in Describe neurons Its criticality in the current network This is the set of all few-shot learning tasks input in the current iteration.
[0067] Step 4.3: Sort neurons according to their criticality and given inactivation ratio. Identify the key neurons to be inactivated in the current layer, including: calculating the first... After determining the criticality of each neuron in the layer, sort the neurons according to their criticality from highest to lowest, and find the one ranked ( The neurons and their criticality were recorded as ; Filter all neurons, if the neuron's criticality is greater than Then the neuron is determined to be a key neuron to be inactivated. When the key neuron inactivation module of the layer is activated, the first The feature representation vector output by the layer has a value of 0 for all channels corresponding to the key neurons.
[0068] Step 4.4: Activate the key neuron inactivation modules layer by layer. In each training epoch, only one neuron inactivation module in the network model is activated, including: for the [number]th layer during training... Training rounds, if ,in This represents the division and remainder operation, which makes the first (or second) number in the network model... The neuronal inactivation module of the layer takes effect, according to the inactivation ratio. The proportion of these factors inactivates key neurons, among which, For the total number of training rounds, The rate of increase in the proportion of inactivated neurons is controlled; each training round requires two forward propagations and two backward propagations; during the first forward propagation, all inactivated neuron modules are inactive, and the first backward propagation is performed based on the calculated loss; based on the result of the backward propagation and the current iteration round, forward propagation and backward propagation are performed again, so that the corresponding key inactivated neuron modules in the second forward propagation become active, and then the second backward propagation is performed, and the entire neural network is optimized based on the gradient of the second backward propagation.
[0069] Step 4.5: From the validation set The set of small sample learning tasks obtained by upsampling We randomly sampled 600 tasks. When all neurons were deactivated and the modules were ineffective, we evaluated the network model on these 600 tasks to determine which iteration yielded the optimal network model. During training, we selected the optimal network model for few-shot learning by evaluating its performance on the validation set.
[0070] Step 5: Evaluate the performance of the few-shot learning model obtained from training.
[0071] Step 5.1: Collect images that do not overlap with the categories of the source dataset as the target dataset. The trained network model uses a backbone network without any neuron deactivation in the meta-testing stage to complete the few-shot learning task on the target dataset and obtain few-shot learning results.
[0072] In this embodiment, the network obtained after 300 training iterations is used, wherein Each iteration of training includes 100 tasks from the training set and 600 tasks from the validation set; when evaluating the model, a total of 1000 tasks from the test set are used.
[0073] In another aspect, the present application provides a small sample meta-training device based on key neuron inactivation, which comprises various units capable of realizing various steps of the foregoing method, in particular:
[0074] A data acquisition unit is configured to collect a public labeled dataset as a source dataset to train a network model;
[0075] A data processing unit is configured to perform data augmentation on sample pictures in the source dataset and divide the sample pictures into different small sample learning tasks;
[0076] A model construction unit is configured to construct a network model containing a neuron inactivation module for the small sample learning task based on metric learning; the network model uses ResNet-10 as a backbone network, inserts a key neuron inactivation module into the backbone network layer by layer, selects a GNN network as a metric module, and uses a cross-entropy function to calculate the loss of the network model on the small sample learning task;
[0077] A model training unit is configured to, in each round of meta-training, evaluate the key degree of each neuron according to the gradient of the loss of the network model on the small sample learning task backpropagated to the neuron and sort the neurons, output neurons with a key degree greater than a preset value as a featureless representation, and record the neurons as key neuron inactivation; the key neuron inactivation is set to occur in a cycle from a shallow network to a deep network, so that the network model is updated with respect to the input small sample learning task until the training is completed, and a trained network model is obtained.
[0078] A model evaluation unit is configured to evaluate the effect of the small sample learning model obtained by training.
[0079] In a third aspect, the present application provides an electronic device, comprising: one or more processors; a memory for storing one or more programs; wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the foregoing small sample meta-training method based on key neuron inactivation.
[0080] In a fourth aspect, the present application provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, can enable the processor to implement the foregoing small sample meta-training method based on key neuron inactivation.
[0081] The above specific examples further illustrate the purpose, technical solutions and beneficial effects of the present application. It should be understood that the above description is only a specific embodiment of the present application and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A few-sample meta-training method based on the inactivation of key neurons, characterized in that, Includes the following steps: Step 1: Collect publicly labeled datasets as source datasets to train the network model; Step 2: Perform data augmentation on the sample images in the source dataset and divide them into different few-shot learning tasks; Step 3: Construct a network model with neuron inactivation modules for few-shot learning tasks based on metric learning; the network model uses ResNet-10 as the backbone network, inserts key neuron inactivation modules layer by layer in the backbone network, selects GNN network as the metric module, and uses the cross-entropy function to calculate the loss of the network model on the few-shot learning task. Step 4: In each round of meta-training, the criticality of neurons is evaluated and sorted based on the gradient backpropagated to each neuron according to the loss of the network model on the few-shot learning task. Neurons with a criticality greater than a preset value are output with no feature representation and are recorded as key neurons inactive. The key neuron inactivation cycle is set from shallow network to deep network so that the network model updates its parameters with respect to the input few-shot learning task until training is completed and a trained network model is obtained. Step 5: Evaluate the performance of the few-shot learning model obtained from training.
2. The few-sample meta-training method based on key neuron inactivation according to claim 1, characterized in that, Step 1 includes: Step 1.1: Source Dataset The source dataset includes sample images and their corresponding category labels. The training set was divided into two groups at an 8:2 ratio. and verification set training set and verification set The sample images belong to different categories; Step 1.2: Transfer the source dataset The location information of all samples in the working environment and their corresponding category labels are stored in a JSON file.
3. The few-sample meta-training method based on key neuron inactivation according to claim 2, characterized in that, Step 2 includes: Step 2.1: Process the training set All sample images are subjected to various random data augmentation transformations, including random scaling and cropping, random brightness and contrast adjustment, and random horizontal flipping. Random scaling and cropping are used to unify the size of all input sample images to 224 pixels × 224 pixels. Step 2.2: Convert all input sample images into tensor types, and normalize all data to a mean of 0 and a standard deviation of 1. Then extract the processed sample images into the data loader by category. Step 2.3: In the source dataset Multiple few-shot learning tasks are formed by random sampling. Each few-shot learning task consists of a support set and a query set. The support set of each few-shot learning task contains N categories, and each category contains K labeled sample images. The query set of each few-shot learning task contains Q unlabeled samples belonging to each of the N categories as the classification target for each few-shot learning task. The few-shot learning task is defined as follows: ,in and These represent sample images from the support set and query set, respectively. and These represent the category labels corresponding to sample images in the support set and query set, respectively, and are recorded in the source dataset. training set and verification set The set of small sample learning tasks obtained by upsampling is and .
4. The few-sample meta-training method based on key neuron inactivation according to claim 3, characterized in that, Step 3 includes: Step 3.1: Divide the ResNet-10 backbone network into 4 network layers, and insert a key neuron inactivation module at the end of each network layer. When the key neuron inactivation module is working, multiply the feature representation vector output by the key neuron by 0 and multiply the feature representation vector output by the other neurons by 1. When the key neuron inactivation module is not working, multiply the feature representation vector output by the all neurons by 1. Step 3.2: After obtaining the feature representation of the sample images using the ResNet-10 backbone network containing the neuron inactivation module, a GNN network is used as the metric module. Based on the feature representation, the sample images in the query set are classified to obtain the posterior probability of each sample image belonging to each category. The cross-entropy loss is then calculated between the posterior probability and the true class label to guide the model in supervised few-sample training. The metric function corresponding to the metric module is denoted as... , by the metric function The predicted labels for the query sample images are represented as follows: ,in This indicates that the feature representation vector of the sample image is extracted using a backbone network; the label of the query sample image is then predicted. Computational few-shot learning task loss in This is the cross-entropy loss function.
5. The few-sample meta-training method based on key neuron inactivation according to claim 4, characterized in that, Step 4 includes: Step 4.1: Use the register_hook() function in the forward propagation code of the backbone network. The register_hook() function records the gradient values that are backpropagated to the feature representation vectors output by each neuron during backpropagation. The backpropagated gradient values on the neurons are the sum of the backpropagated gradient values on all feature representation vectors. Step 4.2: Calculate the criticality of each neuron based on the gradient values backpropagated to the feature vector, including: Let the criticality of the neuron in the network model be... Layer-by-layer few-shot learning task The output feature map is ,in This represents the number of neurons in that layer. and Let the width and height of the output feature map of this layer be denoted as , and the feature map be denoted as . The backpropagation gradient value is For neurons The criticality of the network model is calculated based on the backpropagation gradients of the network model on all few-shot learning tasks in the current iteration round, as follows: ,in Describe neurons Its criticality in the current network This is the set of all few-shot learning tasks input in the current iteration round; Step 4.3: Sort neurons according to their criticality and given inactivation ratio. Identify the key neurons in the current layer that need to be deactivated; Step 4.4: Activate the inactivation modules of key neurons layer by layer, wherein in each training round, only one neuron inactivation module of a network layer in the network model is activated; Step 4.5: From the validation set The set of small sample learning tasks obtained by upsampling Several tasks are randomly sampled. When all neuron deactivation modules are ineffective, the network model is evaluated on the performance of the network model on the several tasks to determine which iteration of the network model is optimal. The trained network model is then selected for few-shot learning.
6. The few-sample meta-training method based on key neuron inactivation according to claim 5, characterized in that, Step 4.3 includes: calculating the first... After determining the criticality of each neuron in the layer, sort the neurons according to their criticality from highest to lowest, and find the one ranked ( The neurons were analyzed and their criticality was recorded. ; Filter all neurons, if the neuron's criticality is greater than Then the neuron is determined to be a key neuron to be inactivated. When the key neuron inactivation module of the layer is activated, the first The feature representation vector output by the layer has a value of 0 for all channels corresponding to the key neurons.
7. The few-sample meta-training method based on key neuron inactivation according to claim 5, characterized in that, Step 4.4 includes: for the first... Training rounds, if ,in This represents the division and remainder operation, which makes the first (or second) number in the network model... The neuronal inactivation module of the layer takes effect, according to the inactivation ratio. The proportion of these factors inactivates key neurons, among which, For the total number of training rounds, Control the rate of increase in the proportion of inactive neurons.
8. The few-sample meta-training method based on key neuron inactivation according to claim 5, characterized in that, In step 4.4, each training round requires two forward propagations and two backward propagations. During the first forward propagation, all inactive neuron modules are inactive, and the first backward propagation is performed based on the calculated loss. Based on the result of the backward propagation and the current iteration round, forward propagation and backward propagation are performed again, so that the inactive key neuron modules corresponding to the second forward propagation are active. Then, the second backward propagation is performed, and the entire neural network is optimized based on the gradient of the second backward propagation.
9. The few-sample meta-training method based on key neuron inactivation according to claim 1, characterized in that, Step 5 includes: collecting images that do not overlap with the categories of the source dataset as the target dataset; using a backbone network without any neuron deactivation in the meta-testing stage to complete the few-shot learning task on the target dataset and obtain few-shot learning results.
10. A small-sample meta-training device based on the inactivation of key neurons, characterized in that, include: The data acquisition unit is used to collect publicly labeled datasets as source datasets for training network models. The data processing unit is used to perform data augmentation on sample images in the source dataset and divide them into different few-shot learning tasks. The model building unit is used to build a network model for few-shot learning tasks based on metric learning, which includes a neuron inactivation module. The network model uses ResNet-10 as the backbone network, inserts key neuron inactivation modules layer by layer in the backbone network, selects GNN network as the metric module, and uses the cross-entropy function to calculate the loss of the network model on the few-shot learning task. The model training unit is used in each round of meta-training to evaluate the criticality of neurons based on the gradient backpropagated to each neuron according to the loss of the network model on the few-shot learning task and to sort them. Neurons with a criticality greater than a preset value are output with featureless representation and are recorded as key neuron inactivation. The key neuron inactivation cycle is set from shallow network to deep network so that the network model updates its parameters with respect to the input few-shot learning task until training is completed and a trained network model is obtained. The model evaluation unit is used to evaluate the performance of the few-shot learning model obtained through training.
11. An electronic device, characterized in that, include: One or more processors; Memory, used to store one or more programs; When one or more programs are executed by the one or more processors, the one or more processors implement the few-sample meta-training method based on the inactivation of key neurons as described in any one of claims 1-9.
12. A computer-readable storage medium, characterized in that, It stores executable instructions that, when executed by a processor, enable the processor to implement a few-sample meta-training method based on the inactivation of key neurons as described in any one of claims 1-9.
Citation Information
Patent Citations
Small sample and zero sample image classification method based on metric learning and meta-learning
CN109961089A
Small sample learning method and device based on cross-sample attention aggregation
CN114639000A