Feature dimension reduction method for small sample classification task

By using the orthogonal Procrustes problem and ViT to extract local features, combined with a feature dimensionality reduction module, the problems of misaligned local features and high dimensionality in small sample image classification are solved, achieving efficient feature dimensionality reduction and accurate classification.

CN121305252APending Publication Date: 2026-01-09LANZHOU UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511728058.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-24
Publication Date
2026-01-09

AI Technical Summary

Technical Problem

Small sample image classification suffers from local feature misalignment and high dimensionality issues, leading to decreased classification accuracy and low computational efficiency, making it difficult to apply in real-world scenarios.

Method used

A feature dimensionality reduction method is adopted, which solves the orthogonal alignment matrix by solving the orthogonal Procrustes problem, extracts local image features by combining a pre-trained visual Transformer (ViT), and uses a feature dimensionality reduction module and a distance metric module to achieve orthogonal alignment and dimensionality reduction of features.

Benefits of technology

It significantly improves the computational efficiency and classification accuracy of few-shot learning, alleviates the curse of dimensionality problem, and enhances the generalization performance and robustness of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121305252A_ABST
    Figure CN121305252A_ABST
Patent Text Reader

Abstract

A feature dimension reduction method for a small sample classification task belongs to the technical field of data processing, and comprises the following steps: dividing image data into a training set and a test set; constructing a small sample image classification model based on class related feature orthogonal alignment; performing sample feature extraction, sample feature dimension reduction and sample feature orthogonal alignment on an input image by using the small sample image classification model, calculating sample similarity and classification loss, optimizing the model, and outputting an optimal category related feature reconstruction model; and classifying the test image by using the optimal model. According to the method, efficient dimensionality reduction can be completed on the premise that discrimination information is reserved to the maximum extent, the compactness and discrimination of feature representation are improved, and the generalization performance of a classification model is improved. According to the method, the optimal alignment of the query sample and the support sample in the local feature space is realized, the geometric structure integrity of the features is kept, the precision and stability of cross-task feature alignment are improved, and the accuracy and robustness of cross-domain classification are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of data processing technology, specifically relating to a feature dimensionality reduction method for small sample classification tasks. Background Technology

[0002] In recent years, with the continuous advancement of deep learning technology, machine recognition capabilities in large-scale image classification tasks have surpassed human levels. However, when faced with scenarios where training samples are scarce, its performance still lags significantly behind human capabilities. Therefore, image classification tasks with only a small number of labeled samples—especially few-shot image classification (Few-shot Image Classification), where each class contains only one or a very small number of samples—have attracted increasing attention from researchers in recent years. Few-shot classification, as an important branch of few-shot learning, is typically based on two disjoint parts of data in the class space: base classes and novel classes. The core objective of this method is to utilize prior knowledge learned from the base classes, combined with a very limited number of labeled samples (i.e., support samples) in the novel classes, to construct an effective classification model, thereby accurately predicting the category of unlabeled samples (i.e., query samples) in the novel classes.

[0003] Few-shot image classification is a crucial and yet incompletely solved problem in the fields of computer vision and artificial intelligence. Existing large-scale image classification methods generally rely on massive amounts of labeled data, while in the real world, sample distribution often exhibits a long-tail characteristic, meaning that most categories actually have only a small number of samples. In many fields such as military, medical, industrial inspection, and astronomical observation, image data acquisition is not only costly but also limited by time, human, and economic resources, making large-scale acquisition difficult. Therefore, developing few-shot image classification technology is of great value in promoting the widespread application of image classification methods in real-world scenarios.

[0004] The core of depth-based classification methods lies in determining the category by measuring the distance between samples or between a sample and the class prototype. They typically introduce techniques such as data augmentation and transfer learning to compensate for overfitting caused by insufficient training data. They have achieved good recognition performance in various small sample classification tasks.

[0005] The core idea of ​​the few-shot image classification method based on global feature measurement is to enable deep neural networks to learn to extract highly discriminative global features through meta-training, thereby constructing a semantically clear embedding space. In this space, features of samples of the same class are close to each other, while features of samples of different classes are far apart. When faced with a new few-shot classification task, the system does not need to be retrained; it only needs to calculate the feature similarity between the query sample and the support set samples in this space and complete the classification based on the nearest neighbor principle. This method transforms the complex classification problem into an intuitive similarity comparison problem, effectively solving the problem of overfitting in traditional methods in scenarios with scarce samples. The method first has a meta-training stage, which uses a large basic dataset to repeatedly simulate the scenario of few-shot tasks to optimize the deep feature extractor, enabling it to generate global features with good metric properties. The second stage is the inference stage, where, when dealing with a new task, the trained feature extractor is directly used to calculate the feature prototypes of the support set samples and the feature representations of the query samples. By calculating metrics such as cosine similarity or Euclidean distance, the nearest neighbor classification strategy is used to achieve fast and accurate classification. The entire scheme achieves efficient non-parametric learning and has strong generalization ability and practical value.

[0006] The core idea of ​​few-sample image classification methods based on local feature semantic alignment is to focus on fine-grained comparisons of discriminative local regions within an image. This method posits that even if the overall image differs significantly, a successful match of several key local features (such as a bird's beak or a car's headlights) is sufficient for accurate classification. Therefore, it extracts multi-dimensional feature maps from the image using a deep network, treating them as a set of local feature vectors. By calculating the similarity between the query image and support set samples at the local level, and utilizing an attention mechanism to focus on the most relevant matches, it ultimately aggregates this local evidence to achieve classification. This method significantly improves robustness to image deformation, occlusion, and complex backgrounds, making it particularly suitable for fine-grained classification tasks, and its traceable decision-making process enhances interpretability.

[0007] Vision Transformer (ViT) is a revolutionary achievement at the intersection of computer vision and deep learning. Its core innovation lies in successfully introducing the Transformer architecture from natural language processing into image recognition research. This model first segments the input image into a sequence of image patches and converts it into a vector representation. Then, it combines positional encoding with learnable classification labels to form the standard input format of the Transformer. Subsequently, it achieves global feature interaction through the self-attention mechanism of a multi-layer Transformer encoder, and finally uses the classification labels to complete the image classification task. Compared with the traditional Transformer, ViT inherits its powerful sequence modeling capabilities while making key adaptations: in input processing, image patches are treated as "visual lexical units" instead of the original word embedding sequence; positional encoding uses learnable 1D encoding instead of sine and cosine encoding; and in terms of computational characteristics, it possesses the ability to cover the entire receptive field from the beginning. Based on these characteristics, ViT can efficiently complete various visual intelligence tasks such as image classification, object detection, semantic segmentation, multimodal learning, and image generation. Its significance lies in breaking through the inductive bias limitation of traditional convolutional neural networks, demonstrating excellent global modeling capabilities and scalability in multiple vision research fields, and providing a unified architectural foundation for vision-language multimodal fusion research.

[0008] Few-shot image classification involves classifying unlabeled query images based on a small number of labeled support samples. This process typically involves comparing the query image with support samples from different categories and classifying it based on the degree of similarity. In real-world scenarios, the differences between two images of an object are often significant, and methods using convolutional neural networks to extract image features cannot directly handle these differences. For example, two birds of the same category may have completely different sizes, orientations, poses, and positions in different images. Few-shot image classification methods based on global feature measurement do not consider these factors between different images, leading to visual feature misalignment during measurement and thus affecting classification accuracy. To alleviate this visual feature misalignment problem, few-shot image classification methods based on local feature semantic alignment align or match local features of the images, measuring features with similar semantics and classifying them accordingly. However, these methods based on local feature semantic alignment often indiscriminately use all local features during alignment, i.e., using the weights of all local features in one image to match a single feature in another image. This introduces irrelevant or background features during alignment, affecting classification performance.

[0009] In summary, compared with large-sample image classification, the performance of existing small-sample image classification is still unsatisfactory, which greatly limits the practical application of small-sample image classification technology, and it still faces the following problems that urgently need to be solved: (1) The problem of misaligned local features. In few-shot classification tasks, the lack of feature alignment is a crucial but often overlooked defect. The problem of misaligned local features severely restricts the performance of few-shot image classification. When the target object has huge appearance differences in different images, the features extracted by the convolutional neural network cannot maintain the consistency of local semantic information. For example, in bird image classification, a bird in one picture may be standing to the left, and its head features are encoded in the front part of the feature vector; while in another picture of the same bird, it may be flying to the right, and its head features are mapped to the middle and back parts of the feature vector due to the change in spatial position. When directly calculating the similarity between these two global features, the model is actually comparing the "head" feature of the first image with the "wing" or "background" feature of the second image. This semantic mismatch inevitably leads to distortion in the similarity calculation. It is this spatial mismatch of local features that makes it difficult for the model to capture the essential features of the category, ultimately resulting in a decrease in classification accuracy.

[0010] (2) The problem of excessive dimensionality. The complex computational cost brought about by high-dimensional feature data is a typical "curse of dimensionality" problem in machine learning. Its essence lies in the fact that the expansion of feature dimensions will cause a triple challenge to computational efficiency, statistical effectiveness and information quality. For example, in a small sample image classification task, although a 2048-dimensional deep feature vector contains rich information, it will lead to a sharp increase in the time consumption of similarity calculation; at the same time, under limited samples, the data is too sparse in high-dimensional space, which is very easy to cause the model to overfit; in addition, the redundant dimensions and noise interference mixed in the feature vector will dilute the key discrimination information. Therefore, the core purpose of using the dimensionality reduction mapping module is to improve computational efficiency, suppress the risk of overfitting and purify effective information by projecting features into low dimensions, thereby significantly improving the practicality and robustness of the algorithm while ensuring model performance. Suppose that the model uses 1000-dimensional features to distinguish between "cat" and "dog", but only a few dimensions are really related to the animal itself (such as the shape of the ears), while a large number of other dimensions record irrelevant background information (such as carpet patterns and curtain colors). Now, consider a query image of a cat on a red carpet. Because its high-dimensional features, particularly the dimensions of "red" and "carpet texture," highly match an image of a dog on a similar red carpet in the support set, the massive background noise can completely mask the subtle differences between "cat" and "dog" in crucial dimensions. Ultimately, the model is likely to misclassify the cat as a dog based on this erroneous background clue. This demonstrates that a large amount of noise in high-dimensional features can make a model extremely unreliable. Summary of the Invention

[0011] The purpose of this invention is to provide a feature dimensionality reduction method for few-sample classification tasks, thereby addressing the problems existing in current technologies. This invention views the local feature alignment problem as solving for an orthogonal alignment matrix—orthogonal... ProcrustesThe problem is that the orthogonal alignment matrix obtained can achieve alignment using only the best-matching feature, thereby eliminating the interference of irrelevant or background features on the alignment. In solving the orthogonal... Procrustes When dealing with high-dimensional feature data, the computational cost becomes complex. To address this, this invention employs a feature dimensionality reduction module to effectively reduce the feature dimension, significantly improving the computational efficiency of model training and inference while reducing storage overhead. Furthermore, to address the issue that the features extracted by convolutional neural networks often do not precisely correspond to the positional relationships in the image, this invention utilizes pre-trained visual [databases] in the feature extraction stage. Transformer ( ViT This is used to extract local features of the image, ensuring that the alignment at the feature level is consistent with the alignment at the image level.

[0012] The technical solution adopted by this invention to solve the technical problem is as follows: This invention provides a feature dimensionality reduction method for few-sample classification tasks, comprising the following steps: Step 1: Divide the image data into training and testing sets, and construct a few-sample image classification model based on class-related feature orthogonal alignment, consisting of an embedding module, a feature dimensionality reduction module, a feature orthogonal alignment module, and a distance metric module. Step 2: Use the small sample image classification model to extract sample features, reduce the dimensionality of sample features, and orthogonally align sample features to the input image. At the same time, calculate sample similarity and classification loss and optimize the model to output the optimal category-related feature reconstruction model. Step 3: Classify the test images using the optimal model.

[0013] Furthermore, the embedding module employs pre-trained vision. Transformer ( ViT The first module is used to extract features from the input image data; the second module uses a convolutional neural network to reduce the feature dimension while retaining the key information of the original data, thereby reducing the number of feature variables; the third module uses filtered category-related features to align the query sample features; and the fourth module calculates the cosine distance between the orthogonally aligned sample features and the query sample features, and classifies the query sample according to the proximity of the cosine distance.

[0014] Furthermore, in step one, the image data includes the training set. test set , and These are the categories for the training set and the test set, respectively. The total number of samples in the training set. The total number of samples in the test set. For image samples, The height of the original image, The width of the original image. For the category of the sample, This is the index of the sample.

[0015] Furthermore, in step one, the image data is organized into base class data and new class data as follows: , Classification task: From Randomly selected from There are 10 categories, and each category is randomly selected. One sample, One sample as supporting samples , One sample was used as the query sample. , and To constitute a task , For task indexing, The total number of tasks for upsampling the base class data; for There is a task , , The total number of tasks for upsampling the new class of data; the number of tasks for the base class of data. , , , For the first The class of One supporting sample, For the first One query sample, , , , , For the first The class of One supporting sample Label, For the first One query sample Label, For tags The Middle The value of each position; the A tag is The vector, if the sample belongs to the first... Class, then the first The value in one position is 1, and the value in the other positions is 0.

[0016] Furthermore, in step two, the method for extracting sample features is as follows: (1) Input image Divided into indivual Image blocks of size, each image block flattened to dimensional vector Then through a learnable projection matrix Linear mapping is 3D embedding vector , This forms a block embedding sequence; (2) Add a learnable classification label before the embedded sequence in this block. get And add position encoding Construct the final input sequence ; (3) Process the final input sequence layer Encoder Processing Output Features Other features As local features of an image: supporting sample features and query sample features , The dimension of the feature.

[0017] Furthermore, in step two, the method for reducing the sample feature dimension is as follows: The obtained support sample features and query sample features The input feature dimensionality reduction module processes the data and outputs supporting sample features. and query sample features For each category Pool the feature maps of all supporting images to output the features of the supporting samples. , The new dimension of the feature after dimensional reduction.

[0018] Furthermore, in step two, the method for orthogonally aligning the sample features is as follows: The feature orthogonal alignment module aligns the support samples using a closed-form solution alignment matrix, solves an orthogonal transformation matrix, aligns a feature set to the position most aligned with another feature set, and aligns the support samples according to the query samples; the obtained local features are input into the feature orthogonal alignment module to orthogonally align the query sample features, thus obtaining the query sample features.

[0019] Furthermore, given a , Supporting image set in the task and its category labels, to predict query images Category tags For each category Stack the features of all supporting images into supporting sample features. And by reshaping the features of the query samples That is, solving the matrix Make , This indicates the use of a weight matrix. Support set features Perform a linear transformation. Represents the optimal query sample features; the optimal solution is obtained through the following orthogonal... Problem obtained:

[0020]

[0021] Suppose that... conduct Decomposition This leads to the optimal solution and optimal features:

[0022] in, For identity matrix, superscript Indicates transpose. and They are all orthogonal matrices.

[0023] Furthermore, in step two, the sample similarity is calculated using the cosine distance formula: Calculate query sample features using the cosine distance formula. Alignment of query sample features Cosine similarity between them:

[0024] in, Indicates the first The query sample and the first Cosine similarity of classes.

[0025] Furthermore, in step two, the method for calculating the classification loss and optimizing the model is as follows: pass softmax Function to calculate class probability Using class probabilities Cosine similarity Query the real labels of the samples Calculate the cross-entropy loss and optimize the embedding module using an optimization algorithm. and feature dimension reduction module parameters and Update task count Resampling task in base class data Execute step two until During the iteration process, the model with the minimum classification loss is selected as the optimal model, and the optimal parameter result is obtained. , .

[0026] The beneficial effects of this invention are: This invention achieves deep coupling between the dimensionality reduction process and the classification task by constructing a learnable projection matrix guided by classification loss, enabling efficient dimensionality reduction while preserving discriminative information to the maximum extent. Simultaneously, this invention employs an end-to-end gradient optimization mechanism, allowing the dimensionality reduction process to directly serve the classification objective, avoiding information loss caused by inconsistent objectives in traditional dimensionality reduction methods. Furthermore, the entire dimensionality reduction process requires no complex preprocessing steps; the feature space can be optimized and compressed through a single linear transformation. This not only significantly alleviates the curse of dimensionality in few-shot learning but also greatly improves the compactness and discriminativeness of feature representations, ultimately enabling the classification model to achieve better generalization performance.

[0027] This invention introduces orthogonality Procrustes The orthogonal matrix obtained by solving the problem achieves optimal alignment between query samples and support samples in the local feature space, maintaining the geometric integrity of the features and ensuring orthogonality during feature transformation. This learnable orthogonal matrix can adaptively adjust according to different tasks, significantly improving the accuracy and stability of cross-task feature alignment. Furthermore, the entire alignment process does not require complex preprocessing steps; consistent mapping of the feature space can be achieved through matrix optimization under orthogonal constraints. This not only effectively solves the feature distribution mismatch problem in few-sample learning but also greatly improves the accuracy and robustness of cross-domain classification. Attached Figure Description

[0028] Figure 1 The flowchart of a feature dimensionality reduction method for small sample classification tasks provided by this invention is shown.

[0029] Figure 2 This is a block diagram illustrating the structural components of a few-sample image classification model based on orthogonal alignment of category-related features, constructed according to the present invention.

[0030] Figure 3 The flowchart illustrates a few-sample image classification model based on orthogonal alignment of category-related features, constructed according to this invention. Detailed Implementation

[0031] The present invention will be further described in detail below with reference to the accompanying drawings.

[0032] See Figure 1 The present invention provides a feature dimensionality reduction method for small sample classification tasks, which mainly includes the following steps:

[0033] S101: Prepare image data, which mainly includes training and testing sets.

[0034] In this invention, using Use it as base class data to train the model. As a new type of data evaluation model, the small sample image classification performance is evaluated by dividing the image data into training sets. and test set Two parts, of which, and These are the categories of the training set and the test set, respectively, and the category spaces of these two parts are mutually exclusive. , The total number of samples in the training set. The total number of samples in the test set. For image samples, The height of the original image, The width of the original image. For the category of the sample, This is the index of the sample.

[0035] Further organize the base class data and the new class data into , The classification task. Specifically, the model is first trained from the base class data. Randomly selected from There are 10 categories, and each category is randomly selected. 1 sample, of which One sample as supporting samples , One sample was used as the query sample. , and To constitute a task ,in For task indexing, This represents the total number of tasks used for upsampling the base class data. Similarly, the performance of the model in small-sample image classification is evaluated for the new class data. There is a task ,in , The total number of tasks for upsampling the new class of data. For a single task of the base class data... ,in , ; Indicates the first The class of One supporting sample; Indicates the first One query sample, , , , ; Indicates the first The class of One supporting sample Label, Indicates the first One query sample Label, For tags The Middle The value at each position. A tag is The vector, if the sample belongs to the first... Class, then the first The value in one position is 1, and the value in the other positions is 0.

[0036] S102: Construct a few-sample image classification model based on orthogonal alignment of class-related features. (See below) Figure 2 The model mainly consists of four parts: an embedded module. Feature Dimension Reduction Module The module consists of a feature orthogonal alignment module and a distance metric module.

[0037] Specifically, embedded modules Used to extract features from input image data. For learnable parameters, including , as well as The parameters in The projection matrix is ​​learnable. For learnable classification labels.

[0038] Specifically, the feature dimension reduction module This method aims to reduce the number of feature variables by reducing the dimensionality, while preserving as much of the key information in the original data as possible. These are learnable parameters.

[0039] Specifically, the feature orthogonal alignment module uses filtered category-related features to align the query sample features. Generally speaking, support samples and query samples belonging to the same class have more common features, so category-related support features are more likely to orthogonally align with query sample features of the same class.

[0040] Specifically, the distance metric module is used to calculate the cosine distance between the orthogonally aligned sample features and the query sample features, and to classify the query sample based on the magnitude of the cosine distance.

[0041] The optimal model parameters are obtained by training the few-sample image classification model based on orthogonal alignment of category-related features using base class data. See also Figure 3 The specific operating procedure is as follows:

[0042] The support samples and query samples are respectively sent to the embedding module. Feature extraction. Embedding module. Adopting standard visual Transformer ( ViT ) is used to extract features from image patches. The specific process is as follows: First, input image Divided into indivual Image blocks of size, each image block flattened to dimensional vector Then through a learnable projection matrix Linear mapping is 3D embedding vector , This forms a block embedding sequence. Then, a learnable classification label is added before this block embedding sequence. ,get And add position encoding Construct the final input sequence The final input sequence is processed... layer Transformer Encoder processing, final output features The remaining features As local features of the image. For query samples and support samples, the process is described as: obtaining support sample features. and query sample features ,in, It is the dimension of the feature. (This refers to a specific feature or dimension.) A vector of dimension 1 is called a local feature, therefore each sample has 1000 local features. Local features.

[0043] This invention maps high-dimensional features to a low-dimensional space by constructing a learnable linear projection matrix. The parameter optimization process of the learnable projection matrix is ​​directly guided by the classification loss, learning the optimal projection direction through gradient descent to ensure that the reduced features retain the discriminative information of the original features to the greatest extent possible. This method is computationally efficient, requires no complex preprocessing steps, effectively alleviates the curse of dimensionality in few-shot learning, and improves the generalization performance of classification models.

[0044] Feature Dimension Reduction Module It employs a commonly used convolutional neural network, specifically containing one convolutional block. Each convolutional block includes the following components: an output dimension of... A convolutional layer with a convolutional kernel, stride of 1, and input padding of 1; a batch normalization layer (BatchNorm) and a non-linear activation function. The supporting sample features obtained in step S201 are... and query sample features Input feature dimensionality reduction module After passing through this feature dimension reduction module After processing, the output supports the sample features. and query sample features For each category Pool the feature maps of all supporting images to output the features of the supporting samples. , The new dimension of the feature after dimensional reduction.

[0045] The feature orthogonal alignment module aligns support samples using a closed-form alignment matrix. It solves for an orthogonal transformation matrix to align one feature set to its closest alignment with another feature set, aligning support samples based on the query sample. This invention preserves the complete grid feature map, eliminating the need to convert it into a single vector. Instead, it retains the spatial structure of the grid-like feature map, aggregating the feature maps of each support image class into a support feature pool. Then, it creates a query feature map using a closed-form ridge regression solution, ultimately achieving superior performance and efficiency in fine-grained, general, and cross-domain few-shot classification tasks.

[0046] The local features obtained in step S202 are input into the feature orthogonal alignment module to orthogonally align the query sample features, thus obtaining the query sample features. Specifically, given a... , Supporting image set in the task and its category labels, to predict query images Category tags For each category Stack the features of all supporting images into supporting sample features. And by reshaping the features of the query samples That is, solving the matrix Make , This indicates the use of a weight matrix. Support set features Perform a linear transformation. This represents the optimal query sample features. Optimal solution. Through the following orthogonal Procrustes Problem obtained:

[0047]

[0048] in, It is an identity matrix.

[0049] Suppose that... conduct Decomposition This leads to the optimal solution and optimal features:

[0050] Among them, superscript Indicates transpose. and Since they are all orthogonal matrices, the supporting features and query features are optimally aligned.

[0051] The core of this invention lies in the design of a learnable orthogonal matrix, which is obtained by solving for orthogonality. Procrustes The problem was solved by mapping the local features of the query sample to the feature space of the supporting sample, which significantly improved the feature alignment effect and classification accuracy across tasks.

[0052] The features of the query sample obtained in step S201 are calculated using the cosine distance formula. Aligned query sample features with those obtained in step S203 The cosine similarity between them is calculated using the following formula:

[0053] in, Indicates the first The query sample and the first Cosine similarity of classes.

[0054] Alternatively, other distance functions, such as Euclidean distance, Mahalanobis distance, and parameterized metric modules, can be used to replace the cosine distance function.

[0055] pass The function calculates the class probability, and the specific formula is as follows:

[0056] in, Indicates the first The query sample and the first Cosine similarity of classes.

[0057] Use the cosine similarity obtained in step S204 and the true labels of the query samples. The specific formula for calculating cross-entropy loss (CELoss) is as follows: in, CELoss Let cross-entropy be the loss function. For tags The Middle The value at each position.

[0058] The embedding module was optimized using the SGD optimization algorithm. and feature dimension reduction module parameters and The specific calculation formula for the SGD optimization algorithm is as follows: ,in The learning rate is initially set to 0.01. For parameters and gradient, , This is the optimized result.

[0059] Next, update the number of tasks. Resampling task in base class data Repeat steps S201-S205 until... .

[0060] In the process of training and optimizing the model, this invention calculates the loss value by performing a cosine metric on the support samples, which is then used to optimize the model parameters. The optimization method employed here is the SGD (Signal-Growth Digitization) algorithm, a commonly used optimization algorithm widely applied in model training in machine learning and deep learning. Algorithms such as Adam and AdaGrad can also be used instead of SGD.

[0061] In the iteration of step S205, the classification loss is... loss The model with the smallest value is taken as the optimal model, and the optimal result for the parameters is obtained. , .

[0062] Unlike CTX (CrossTransformers: Spatially-Aware Few-Shot Transfer), this invention does not require interaction with the query samples during reconstruction. Instead, it constrains the reconstructed features to be as close as possible to features of the same class in the final loss, thus ensuring the effectiveness of the reconstruction. Furthermore, this invention filters the support samples during reconstruction, removing interfering features irrelevant to the reconstructed category, unlike CTX which uses prototypes of the support samples for reconstruction.

[0063] This invention employs a metric-based learning method in two key stages: filtering irrelevant local features and measuring cosine similarity. Specifically, in the irrelevant local feature filtering stage, the importance of each local feature in the same type of support samples is evaluated, and less important local features are further eliminated. The importance is measured by calculating the cosine distance between each local feature and the local average of all local features, and the importance of the feature is determined based on the magnitude of this cosine distance. In the cosine similarity measurement stage, the similarity between the query sample features and the orthogonally aligned support features is calculated to measure their similarity, and the category to which the query sample belongs is determined accordingly.

[0064] A task for new types of data ,in , ; Indicates the first The class of One supporting sample; Indicates the first One query sample, , , , ; Indicates the first The class of One supporting sample Label, , A tag is The vector, if the sample belongs to the first... Class, then the first The value in one position is 1, and the value in the other positions is 0.

[0065] The supporting samples in step S301 and query samples After processing through steps S201-S204 in sequence, the first... For the query sample of the _th Distance between classes ; will the first One query sample and all The category corresponding to the maximum distance between the categories is taken as the predicted category of the query sample. For all All query samples They are all categorized.

[0066] Next, update the number of tasks. Repeat steps S301-S302 until... Complete all sampling tasks.

[0067] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A feature dimensionality reduction method for small-sample classification tasks, characterized in that, Includes the following steps: Step 1: Divide the image data into training and testing sets, and construct a few-sample image classification model based on class-related feature orthogonal alignment, consisting of an embedding module, a feature dimensionality reduction module, a feature orthogonal alignment module, and a distance metric module. Step 2: Use the small sample image classification model to extract sample features, reduce the dimensionality of sample features, and orthogonally align sample features to the input image. At the same time, calculate sample similarity and classification loss and optimize the model to output the optimal category-related feature reconstruction model. Step 3: Classify the test images using the optimal model.

2. The feature dimensionality reduction method for small sample classification tasks according to claim 1, characterized in that, The embedded module employs pre-trained vision. Used to extract features from input image data; the feature dimension reduction module uses a convolutional neural network to reduce the feature dimension and the number of feature variables while retaining the key information of the original data; The feature orthogonal alignment module uses filtered category-related features to align the features of the query samples; The distance metric module is used to calculate the cosine distance between the orthogonally aligned sample features and the query sample features, and to classify the query sample based on the proximity of the cosine distance.

3. The feature dimensionality reduction method for small sample classification tasks according to claim 1, characterized in that, In step one, the image data includes the training set. test set , and These are the categories for the training set and the test set, respectively. This represents the total number of samples in the training set. The total number of samples in the test set. For image samples, The height of the original image, The width of the original image. For the category of the sample, This is the index of the sample.

4. The feature dimensionality reduction method for small sample classification tasks according to claim 3, characterized in that, In step one, the image data is organized into base class data and new class data as follows: , Classification task: From Randomly selected from There are 10 categories, and each category is randomly selected. One sample, One sample as supporting samples , One sample was used as the query sample. , and Constitute a task , For task indexing, The total number of tasks for upsampling the base class data; for There is a task , , The total number of tasks for upsampling the new class of data; the number of tasks for the base class of data. , , , For the first The class of One supporting sample, For the first One query sample, , , , , For the first The class of One supporting sample Label, For the first One query sample Label, For tags The Middle The value of each position; the A tag is The vector, if the sample belongs to the first... Class, then the first The value in one position is 1, and the value in the other positions is 0.

5. The feature dimensionality reduction method for small sample classification tasks according to claim 1, characterized in that, In step two, the method for extracting sample features is as follows: (1) Input image Divided into indivual Image blocks of size, each image block flattened to dimensional vector Then through a learnable projection matrix Linear mapping is 3D embedding vector , This forms a block embedding sequence; (2) Add a learnable classification label before the embedded sequence in this block. get And add position encoding Construct the final input sequence ; (3) Process the final input sequence layer Encoder Processing Output Features Other features As local features of an image: supporting sample features and query sample features , The dimension of the feature.

6. The feature dimensionality reduction method for small sample classification tasks according to claim 5, characterized in that, In step two, the method for reducing the sample feature dimension is as follows: The obtained support sample features and query sample features The input feature dimensionality reduction module processes the data and outputs supporting sample features. and query sample features For each category Pool the feature maps of all supporting images to output the features of the supporting samples. , This is the new dimension of the feature after dimensional reduction.

7. The feature dimensionality reduction method for small sample classification tasks according to claim 1, characterized in that, In step two, the method for orthogonally aligning the sample features is as follows: The feature orthogonal alignment module aligns the support samples using a closed-form alignment matrix, solves an orthogonal transformation matrix, aligns a feature set to the position most aligned with another feature set, and aligns the support samples according to the query samples. The obtained local features are input into the feature orthogonal alignment module to orthogonally align the query sample features, thus obtaining the query sample features.

8. A feature dimensionality reduction method for small sample classification tasks according to claim 7, characterized in that, Given a , Supporting image set in the task and its category labels, to predict query images Category tags For each category Stack the features of all supporting images into supporting sample features. And by reshaping the features of the query samples That is, solving the matrix Make , This indicates the use of a weight matrix. Support set features Perform a linear transformation. Represents the optimal query sample features; the optimal solution is obtained through the following orthogonal... Problem obtained: , , Suppose that... conduct Decomposition This leads to the optimal solution and optimal features: , in, For identity matrix, superscript Indicates transpose. and They are all orthogonal matrices.

9. A feature dimensionality reduction method for small-sample classification tasks according to claim 1, characterized in that, In step two, the sample similarity is calculated using the cosine distance formula: Calculate query sample features using the cosine distance formula. Alignment of query sample features Cosine similarity between them: , in, Indicates the first The query sample and the first Cosine similarity of classes.

10. A feature dimensionality reduction method for small-sample classification tasks according to claim 9, characterized in that, In step two, the method for calculating the classification loss and optimizing the model is as follows: pass Function to calculate class probability Using class probabilities Cosine similarity Query the real labels of the samples Calculate the cross-entropy loss and optimize the embedding module using an optimization algorithm. and feature dimension reduction module parameters and Update task count Resampling task in base class data Execute step two until ; During the iteration process, the model with the minimum classification loss is selected as the optimal model, and the optimal parameter result is obtained. , .