Non-negative representation classification method based on positive and negative neighbor double flexible constraints
Through the non-negative representation classification method with double flexible constraints of positive and negative neighbors, the alternating direction multiplier method is used to optimize the objective function. Combining positive and negative neighbor sets with flexible factors, the problem of insufficient utilization of data location and identification information in existing methods is solved, and the accuracy and robustness of image classification are improved.
Patent Information
- Application Number
- CN202510472830.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-15
- Publication Date
- 2025-09-09
AI Technical Summary
Existing image classification methods based on sparse representation have deficiencies in utilizing the location and identification information of the data, resulting in a decrease in classification performance, especially when there is a large similarity between classes in remote sensing images, which can easily lead to classification confusion.
A non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints is adopted. By obtaining test samples and training sample sets, the alternating direction multiplier method is used to solve the objective function of the positive and negative nearest neighbor dual flexible non-negative representation classifier, and the residual is calculated and classified. The flexible factor and positive and negative nearest neighbor sets are introduced to enhance the representativeness of the correct category and weaken the influence of the wrong category.
The effective use of sample position information improves the accuracy and discrimination of image classification, enhances the ability to distinguish between categories, and shows better classification performance and robustness.
Smart Images

Figure CN120612508A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and in particular to a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints. Background Art
[0002] Image classification, as a key research area in pattern recognition, has received extensive attention and development in recent years. Among the numerous image classification algorithms, representation-based methods are a major category. These methods first represent test samples as linear combinations of given training samples and then assign them to corresponding categories using methods such as minimum distance or approximate residuals.
[0003] The pioneering work in this field is the sparse representation based classifier (SRC), which enforces l1 norm sparsity on the encoding coefficients of all test samples to improve the recognition ability of test samples. Since the proposal of SRC, a large number of sparse representation algorithms have emerged.
[0004] Existing algorithms based on sparse representations have achieved success in image classification tasks, but questions have been raised about whether it is indeed the l1-norm sparsity that makes SRC effective. To this end, researchers introduced a collaborative representation classifier (CRC) to the task of pattern classification. Unlike SRC, CRC uses l2-norm regularization to replace the l1-norm constraint in the corresponding sparse representation model, revealing that representation-based pattern classification is driven by the collaborative nature of the l2-norm.
[0005] In recent years, many improvements to CRC have been proposed, demonstrating impressive performance in pattern recognition. However, they face a critical challenge: the inability to effectively avoid negative coding coefficients generated during complex optimization processes. To address this issue, researchers have drawn inspiration from non-negative matrix factorization (NMF) and proposed a non-negative representation classifier (NRC). To further expand the application of NRC, researchers have also proposed a dual-discriminant constrained affine non-negative representation (DCANR), effectively addressing the problem of high inter-class similarity in remote sensing imagery, which can easily lead to classification confusion.
[0006] Although the above-mentioned NRC and its variants have achieved good performance in different application scenarios, most of them cannot fully or simultaneously consider the location and identification information of the data, which may degrade the classification performance of representation-based methods. Summary of the Invention
[0007] In order to solve the above technical problems, the present invention provides a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, comprising the following steps:
[0008] S1. Obtain a test sample and a training sample set of K categories and n samples;
[0009] S2, perform l2 norm normalization on the samples in the training sample set;
[0010] S3. Using the alternating direction multiplier method, the representation coefficient of the test sample on the training sample set is obtained by solving the objective function of the positive and negative nearest neighbor double flexible non-negative representation classifier;
[0011] S4, calculating the residual of the test sample in each category of the training sample set;
[0012] S5. Classification is performed based on the residuals, and the test sample is identified as the category corresponding to the minimum residual.
[0013] The technical solution further defined in the present invention is:
[0014] Furthermore, in step S1, the training sample set is expressed as:
[0015]
[0016] in, For nth i is the number of training samples of class i, K is the total number of sample categories, n is the total number of training samples, x is the feature vector of each sample, and d is the number of pixels of each sample.
[0017] As described above, in the non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S3, the objective function of the positive and negative nearest neighbor dual flexible non-negative representation classifier is:
[0018]
[0019] Where y is the test sample, α represents the coefficient vector of the test sample y on the training sample matrix X; define the positive neighbor set N p (y) and negative neighbor set N n (y), x + represents the training samples from the positive neighbor set, and x - Represents training samples from the negative neighbor set; introduces the flexibility factor f + and f - , acting on the samples in the positive and negative neighbor sets respectively; λ1 and λ2 are regularization parameters used to balance the sizes of each term in the above formula. When λ1=λ2=0, the positive and negative neighbor dual flexible non-negative representation model will be simplified to a non-negative representation classification model.
[0020] As described above, in the non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S3, the positive and negative nearest neighbor dual flexible non-negative representation is a non-negative least squares problem, and the coefficient vector α is solved by the variable splitting method. By introducing the auxiliary variable z, the objective function of the positive and negative nearest neighbor dual flexible non-negative representation classifier is reformulated as follows:
[0021]
[0022] Convert the above formula into Lagrangian function and use the alternating direction multiplier method to deduce and optimize it; the Lagrangian function is constructed as shown below:
[0023]
[0024] Where δ is the Lagrange multiplier vector, μ>0 is the penalty parameter, and <δ,z-α> is the inner product of vector α and vector z-α.
[0025] As described above, a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints is used. In step S3, the Lagrangian function is solved by iterating α and z; and the relevant variables are initialized and set: α0 = f + 0 = f - 0=z0=δ0=0, μ>0; use α t 、f + t 、f - t 、z t and δ t represents the optimization variables and Lagrange multipliers when the iteration is t (t = 0, 1, 2, ..., T), T is the preset threshold; the variable optimization strategy is used to update the variables one by one; the solution process of the Lagrangian function is decomposed into the variables α, f + 、f - The five sub-problems of , z and δ include the following steps:
[0026] S3.1. Update the variable α and obtain the analytical solution of α;
[0027] S3.2. Update variable f + , we get f + The analytical solution of
[0028] S3.3. Update variable f - , we get f - The analytical solution of
[0029] S3.4. Update the variable z and obtain the analytical solution of z;
[0030] S3.5, updated augmented Lagrange multiplier δ;
[0031] S3.6. Repeat iterative steps S3.1 to S3.5 until the convergence condition is met or the number of iterations exceeds a preset threshold T.
[0032] As described above, a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S3.1, fixed f+ 、f - , z and δ, simplify the Lagrangian function into the following objective function:
[0033]
[0034] To calculate the derivative of vector α, let
[0035] The derivative of F1 with respect to α is calculated as:
[0036]
[0037] The derivative of F2 with respect to α is calculated as:
[0038]
[0039] The derivative of F3 with respect to α is calculated as:
[0040]
[0041] Finally, let the sum of these derivatives be zero:
[0042]
[0043] Therefore, the analytical solution of α is:
[0044]
[0045] in,
[0046] As described above, a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S3.2, fixed α, f - , z and δ, simplify the Lagrangian function into the following objective function:
[0047]
[0048] The objective function of this problem is f + Taking the partial derivative and setting it to zero, we get:
[0049]
[0050] After finishing, we can get:
[0051]
[0052] Therefore, we get f + The analytical solution is:
[0053]
[0054] In step S3.3, fix α and f + , z and δ, simplify the Lagrangian function into the following objective function:
[0055]
[0056] The objective function of this problem is f - Taking the partial derivative and setting it to zero, we get:
[0057]
[0058] After finishing, we can get:
[0059]
[0060] Therefore, we get f - The analytical solution is:
[0061]
[0062] As described above, a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S3.4, fixed α, f + 、f - and δ, simplifying the Lagrangian function into the following objective function:
[0063]
[0064] The analytical solution of z is:
[0065]
[0066] As described above, in a non-negative representation classification method with positive and negative neighbor dual flexible constraints, in step S3.5, the augmented Lagrange multiplier δ is updated by the following formula:
[0067] δ t+1 =δ t +μ(z t+1 -α t+1 )
[0068] In step S3.6, the convergence condition is: satisfying ||α t -z t ||2≤η,||α t+1 -α t |2≤η and ||z t+1 -z t ||2≤η, where η is a preset threshold.
[0069] As described above, in a non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, in step S4, the residual of the test sample on each category of the training sample set is calculated as:
[0070]
[0071] Among them, X j is the j-th class training sample, α j is the coefficient vector corresponding to the j-th class training sample;
[0072] In step S5, classification is performed based on the residuals, and the test sample is identified as the category corresponding to the minimum residual:
[0073]
[0074] The beneficial effects of the present invention are:
[0075] (1) In the present invention, the location information of the sample is fully utilized, and the K-nearest neighbor algorithm is used to obtain the k nearest neighbors of the test sample to form a positive neighbor set. At the same time, in order to enhance the distinction between categories, the present invention additionally introduces a negative neighbor set to reduce the interference effect of the wrong category;
[0076] (2) In this paper, the concept of flexible factor is proposed, and a weighted flexible constraint strategy based on positive neighbor sets and negative neighbor sets is designed, which further expands the representation capacity of the correct class in the positive and negative neighbor sets and flexibly weakens the representation weight of the wrong class;
[0077] (3) In this invention, a large number of experiments are conducted on different pattern classification datasets, and the results show the competitiveness of the positive and negative nearest neighbor dual flexible non-negative representation classification method. BRIEF DESCRIPTION OF THE DRAWINGS
[0078] Figure 1 PN in the embodiment of the present invention 2 Schematic diagram of the DFNR model;
[0079] Figure 2 It is a schematic diagram of the overall process of the present invention. DETAILED DESCRIPTION
[0080] This embodiment provides a positive and negative neighbor dual-flexible non-negative representation (Positive and Negative Neighbor Dual-Flexible Non-negative Representation, PN 2 DFNR) classification method, such as Figure 1 As shown in FIG, a schematic diagram of a non-negative representation classification model with positive and negative neighbor dual flexible constraints.
[0081] For representation-based pattern classification tasks, the key issue is to obtain the discriminant representation coefficient on the training samples. This coefficient can use the training samples to approximately represent the test samples. Then, by calculating the approximate residual, the test sample is identified as the category corresponding to the minimum residual. Let the test sample be y and the training sample matrix be X. Although the NRC classifier can ensure that the discriminant representation coefficient of y on X is positive for training samples of the same class and zero for training samples of different classes through non-negative constraints, NRC does not fully utilize the position and identification information of the training samples and ignores the correlation between samples, which affects the classification performance of the representation method.
[0082] The PN of this embodiment 2 DFNR uses the positive and negative neighbor sets of the test samples to consider the location information of the data. The positive neighbor set ensures that the sample estimate remains close to the neighboring samples by emphasizing spatial consistency; while the negative neighbor set provides an inverse constraint to balance the interference between classes. At the same time, a flexible factor is introduced to design a weighted flexible constraint strategy to enhance the representativeness of the correct class and flexibly weaken the representation weight of the wrong class. The results show that the method of this embodiment has better classification effectiveness and discriminability.
[0083] This embodiment provides a non-negative representation classification method with positive and negative neighbor dual flexible constraints, such as Figure 2 As shown, the following steps are included:
[0084] S1. Obtain a test sample and a training sample set of K categories and n samples; the training sample set is expressed as:
[0085]
[0086] in, For nth i is the number of training samples of class i, K is the total number of sample categories, n is the total number of training samples, x is the feature vector of each sample, and d is the number of pixels of each sample.
[0087] S2. Perform l2 norm normalization on the samples in the training sample set.
[0088] S3, using the alternating direction multiplier method, by solving PN 2 The objective function of DFNR is used to obtain the representation coefficient of the test sample on the training sample set; PN 2 The objective function of DFNR is:
[0089]
[0090] Where y is the test sample, α represents the coefficient vector of the test sample y on the training sample matrix X; define the positive neighbor set N p (y) and negative neighbor set N n(y), x + represents the training samples from the positive neighbor set, and x - Represents the training samples from the negative nearest neighbor set; in order to enhance the flexibility of the model, the flexible factor f is introduced + and f - , they act on the samples in the positive and negative neighbor sets respectively; λ1 and λ2 are regularization parameters, which are used to balance the sizes of the terms in the above formula. When λ1=λ2=0, PN 2 The DFNR model can be simplified to the traditional NRC model. Therefore, NRC can be considered as PN 2 A special case of DFNR under specific parameter settings.
[0091] Because PN 2 DFNR is a non-negative least squares problem that does not have a closed form solution. In order to solve this problem, the variable splitting method is used to solve the coefficient vector α; by introducing auxiliary variables z, PN 2 DFNR can be restated as follows:
[0092]
[0093] The above formula is converted into an augmented Lagrange function (ALF) and optimized using the alternating direction method of multipliers (ADMM).
[0094] The Lagrangian function is constructed as follows:
[0095]
[0096] Where δ is the Lagrange multiplier vector, μ>0 is the penalty parameter, and <δ,z-α> is the inner product of vector α and vector z-α.
[0097] Solve the Lagrangian function by iterating α and z; and initialize the relevant variables: α0 = f + 0 = f - 0=z0=δ0=0,μ>0 and selected appropriately; use α t 、f + t 、f - t 、z t and δ t represents the optimization variable and Lagrange multiplier when the iteration is t (t=0, 1, 2, ..., T), and T is a preset threshold.
[0098] Adopt the strategy of variable optimization to update variables one by one; decompose the solution process of Lagrangian function into two steps about variables α, f + 、f- The five sub-problems of , z and δ include the following steps:
[0099] S3.1、Fix f + 、f - , z and δ update α, simplifying the Lagrangian function into the following objective function:
[0100]
[0101] The above formula is a standard least squares problem, and it is easy to get the analytical solution of α.
[0102] In order to clearly calculate the derivative of the vector α, let
[0103] The derivative of F1 with respect to α is calculated as:
[0104]
[0105] The derivative of F2 with respect to α is calculated as:
[0106]
[0107] The derivative of F3 with respect to α is calculated as:
[0108]
[0109] Finally, let the sum of these derivatives be zero:
[0110] Therefore, the analytical solution of α is:
[0111]
[0112] in, S3.2, Fixed α, f - , z and δ update f + , simplifying the Lagrangian function into the following objective function:
[0113] The objective function of this problem is f + Taking the partial derivative and setting it to zero, we get:
[0114]
[0115] After finishing, we can get:
[0116]
[0117] Therefore, we get f + The analytical solution is:
[0118]
[0119] S3.3, Fixed α, f + , z and δ update f - , simplifying the Lagrangian function into the following objective function:
[0120] The objective function of this problem is f - Taking the partial derivative and setting it to zero, we get:
[0121]
[0122] After finishing, we can get:
[0123]
[0124] Therefore, we get f - The analytical solution is:
[0125]
[0126] S3.4. Fixed α, f + 、f - Update z with δ, simplifying the Lagrangian function into the following objective function:
[0127]
[0128] The analytical solution of z is:
[0129]
[0130] S3.5, Fixed α, f + 、f - Update δ with z and update the augmented Lagrange multiplier δ by:
[0131] δ t+1 =δ t +μ(z t+1 -α t+1 ).
[0132] S3.6, repeat iterative steps S3.1 to S3.5 until the convergence condition is met or the number of iterations exceeds the preset threshold T; PN 2 The convergence condition of DFNR is: satisfying ||α at the same time t -z t ||2≤η,||α t+1 -α t ||2≤η and ||z t+1 -z t ||2≤η, where η is a preset threshold.
[0133] S4. Calculate the residual of the test sample in each category of the training sample set:
[0134]
[0135] Among them, X j is the j-th class training sample, α j is the coefficient vector corresponding to the j-th class training sample.
[0136] S5. Classify based on the residuals. The test sample is identified as the category corresponding to the minimum residual:
[0137]
[0138] Example 1:
[0139] The Extended Yale B dataset is a benchmark dataset commonly used in face recognition research. It contains 38 individuals, each captured under approximately 64 different lighting conditions, totaling 2414 images. The original image resolution is 192×168 pixels. To unify data processing, this example resizes the images to 54×48 pixels and normalizes them to meet the unit 2 norm requirement.
[0140] Table 1
[0141]
[0142] Table 1 shows the classification accuracy (%) of different methods in the Extended Yale B dataset. As can be seen from Table 1, when the dimension d=84, PN 2 The classification accuracy of the DFNR method reaches 98.5%, which is 1.6% and 1.9% higher than that of LDNR and DCANR respectively. When the dimension is increased to d=150, PN 2 The recognition accuracy of DFNR is further improved to 98.8%, which is significantly better than 97.0% of LDNR and 96.3% of DRC. 2 DFNR still performs the best with an accuracy of 99.1%, while NRC, DRC, DCANR, and LDNR perform relatively close with accuracy ranging from 98.0% to 98.4%.
[0143] Example 2:
[0144] The AR Face Dataset contains over 4,000 face images collected from over 100 participants under various shooting conditions. These images cover different facial expressions, lighting conditions, and occlusions (such as glasses, scarves, etc.). In the experimental setup of this example, a subset focusing on lighting and expression changes was selected, including 50 male and 50 female subjects. For each subject, seven images were randomly selected for training and another seven images were used for testing.
[0145] Table 2
[0146]
[0147] Table 2 shows the classification accuracy (%) of different methods in the AR face dataset. From Table 2, we can see that in the case of dimension d=54, the PN method has the highest accuracy. 2 DFNR, reaches 87.1%, followed by LDNR and DCANR, with accuracy rates of 85.8% and 85.4% respectively; when the dimension increases to d = 120, PN 2 DFNR still performs best with an accuracy of 91.6%. In this dimension, the performance of NRC, LDNR, DCANR and ProCRC is also relatively close, with an accuracy between 90.7% and 91.4%, while SRC performs relatively poorly with an accuracy of only 88.3%. In the case of the highest dimension d = 300, LDNR reaches 94.3%, becoming the best performing algorithm, while PN 2 DFNR follows closely behind with an accuracy of 93.6%, while DCANR and NRC also perform quite well with accuracy between 93.3% and 93.9%.
[0148] Example 3:
[0149] The USPS dataset is a classic handwritten digit recognition dataset that contains 10 digit categories from 0 to 9. The resolution of each image is 16×16 pixels. The dataset is divided into a training set and a test set, where the training set contains 7291 images and the test set contains 2007 images.
[0150] Table 3
[0151]
[0152] Table 3 above shows the classification accuracy (%) of different methods in the USPS dataset. It can be seen from Table 3 that PN 2 DFNR outperforms other representation methods in all experimental settings; when the number of training samples per class is 50, PN 2The classification accuracy of DFNR reaches 92.2%, slightly higher than 92.1% and 91.9% of LDNR and DCANR respectively. When the number of training samples increases to 100, PN 2 The classification accuracy of DFNR is improved to 98.5%, which is 0.4% and 1.0% higher than DCANR and NRC, while DRC has the worst classification accuracy of 89.3%.
[0153] Example 4:
[0154] The MNIST dataset contains a series of 28×28 pixel grayscale handwritten digit images, covering ten digit categories from 0 to 9; the dataset is divided into a training set and a test set, where the training set contains 60,000 images and the test set contains 10,000 images.
[0155] Table 4
[0156]
[0157] Table 4 shows the classification accuracy (%) of different methods in MNIST. It can be seen from Table 4 that among these algorithms, PN 2 DFNR performs the best with a classification accuracy of 90.7%, followed by LDNR and DCANR with 90.3% and 90.6% respectively. In comparison, SRC performs relatively poorly with an accuracy of only 82.4%.
[0158] Example 5:
[0159] The FGCV-Aircraft dataset is a fine-grained classification benchmark dataset focusing on aircraft categories. It contains 10,000 high-quality aircraft images, covering 100 different types of aircraft categories.
[0160] Table 5
[0161]
[0162] Table 5 shows the classification accuracy (%) of different methods in the FGCV-Aircraft dataset. It can be seen from Table 5 that PN 2 DFNR performed best, achieving a classification accuracy of 87.5%, compared to 86.9% and 86.5% for EfficientFormerV2 and MobileViT, 85.6% for VGG16, and 72.5% for Symbiotic.
[0163] Example 6:
[0164] The Stanford Cars dataset contains 16,185 high-resolution car images covering 196 different car model categories, which cover various sedans and SUVs produced between 1960 and 2012; the dataset is divided into 8,144 training images and 8,041 test images.
[0165] Table 6
[0166]
[0167] Table 6 shows the classification accuracy (%) of different methods in the Stanford Cars dataset. It can be seen from Table 6 that PN 2 DFNR achieves a state-of-the-art classification accuracy of 90.9%, which is 1.3% higher than EfficientFormerV2, 0.1% higher than ConvNeXt, 2% higher than MobileViT, and 2.2% higher than VGG16.
[0168] Example 7:
[0169] The Standford 40Actions dataset contains 9,352 images of 40 different human actions, with each action containing approximately 180 to 300 images, covering various daily life and professional activities such as "taking photos," "making phone calls," and "washing cars." This example divides the dataset into a training set and a test set, with 4,000 images used for model training and the remaining 5,532 images for testing to ensure the fairness and repeatability of the experiment.
[0170] Table 7
[0171]
[0172] Table 7 shows the classification accuracy (%) of different methods in the Standford 40Actions dataset. It can be seen from Table 7 that PN 2 DFNR outperformed other mainstream methods in classification on the Stanford 40Actions dataset, achieving a top accuracy of 81.0%. In comparison, VGG19 achieved an accuracy of 77.2%, which is relatively good but still lower than PN. 2 DFNR; MobileViT and ConvNeXt have an accuracy of 78.8% and 79.9% respectively, which is close to PN 2 Performance of DFNR.
[0173] Example 8:
[0174] The Oxford 102Flowers dataset contains 8,189 flower images, covering 102 different flower species. The number of images in each category ranges from 40 to 258. The images in this dataset are of high quality and have diverse shooting angles, lighting conditions, and backgrounds. They simulate the complexity and diversity of flowers in the real world and increase the challenge of the classification task.
[0175] Table 8
[0176]
[0177] Table 8 shows the classification accuracy (%) of different methods in the Oxford 102Flowers dataset. It can be seen from Table 8 that PN 2 DFNR performed best in the experiment, with a classification accuracy of 94.7%, followed by ConvNeXt with a classification accuracy of 94.6%. EfficientFormerV2, MobileViT, and VGG19 performed relatively close, with classification accuracy ranging from 93.1% to 94.1%.
[0178] Example 9:
[0179] To verify the PN 2 In order to show the excellent performance of the DFNR representation method, this example selected the Extended Yale B face dataset as the experimental benchmark and compared it with the classic benchmark models NRC and PN. 2 Several variants of DFNR are compared in depth.
[0180] Table 9
[0181]
[0182] Table 9 above is PN 2 The classification accuracy (%) of DFNR and its variants in the Extended Yale B dataset is shown in Table 9. As can be seen from Table 9, since the baseline model does not use any constraint information, the accuracy is the lowest. The recognition accuracy in 84-dimensional, 150-dimensional and 300-dimensional is only 96.6%, 97.3% and 97.9%, while PN 2 DFNR-DF and PN 2 DFNR-NN shows some improvement, but is still inferior to the complete PN 2 DFNR method; PN 2 DFNR achieves the highest accuracy in all dimensions by combining position constraints and flexibility factors, especially reaching 99.1% in 300 dimensions, which is 2.3% higher than the baseline model and 10.7% higher than the second-best method PN. 2 DFNR-NN also has a 0.3% improvement.
[0183] Example 10:
[0184] This example compares the running time of the PN2DFNR method with various representation methods. The experimental results are shown in Table 10 below.
[0185] Table 10
[0186]
[0187] As can be seen from Table 10, classic methods such as NSC and SVM have shorter runtimes of 0.09ms and 0.36ms, respectively, but their classification performance is generally lacking. Among the SRC and CRC series methods, the ProCRC method has the shortest runtime of only 0.07ms, while the SRC method has the longest runtime of 4.55ms. For the NRC series methods, since their model is a non-negative least squares (NNLS) problem, which lacks a closed-form solution and needs to be solved using the alternating direction method of multipliers (ADMM), their runtime is generally longer than that of the SRC and CRC series methods.
[0188] At the same time, since NRC itself does not contain any constraint information, its running time is the shortest among the NRC series methods, which is only 4.35ms. It is worth mentioning that the PN proposed in this embodiment 2 While combining positive and negative neighbor information and flexible constraints, the DFNR method still maintains a high operating efficiency, taking only 5.5 ms, which is much lower than LDNR and DCANR, and performs better in classification performance.
[0189] In summary, the non-negative representation (PN 2 The DFNR) classifier introduces the position information of the samples, making the true category have a greater contribution in the representation process, effectively improving the classification ability and robustness of the model. This method shows higher accuracy and stronger generalization ability in face recognition tasks.
[0190] In addition to the above embodiments, the present invention may also have other implementations. Any technical solution formed by equivalent replacement or equivalent transformation falls within the scope of protection required by the present invention.
Claims
1. A non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints, characterized by: The following steps are involved: S1. Obtain a test sample and a training sample set of K categories and n samples; S2, perform l2 norm normalization on the samples in the training sample set; S3. Using the alternating direction multiplier method, the representation coefficient of the test sample on the training sample set is obtained by solving the objective function of the positive and negative nearest neighbor double flexible non-negative representation classifier; S4, calculating the residual of the test sample in each category of the training sample set; S5. Classification is performed based on the residuals, and the test sample is identified as the category corresponding to the minimum residual.
2. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 1 is characterized by: In step S1, the training sample set is represented as: in, i=1,2,...,K is the nth i is the number of training samples of class i, K is the total number of sample categories, n is the total number of training samples, x is the feature vector of each sample, and d is the number of pixels of each sample.
3. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 1 is characterized by: In step S3, the objective function of the positive and negative neighbor dual flexible non-negative representation classifier is: Where y is the test sample, α represents the coefficient vector of the test sample y on the training sample matrix X; define the positive neighbor set N p (y) and negative neighbor set N n (y), x + represents the training samples from the positive neighbor set, and x - Represents training samples from the negative neighbor set; introduces the flexibility factor f + and f - , acting on the samples in the positive and negative neighbor sets respectively; λ1 and λ2 are regularization parameters used to balance the sizes of the terms in the above formula. When λ1=λ2=0, the positive and negative neighbor dual flexible non-negative representation model will be simplified to a non-negative representation classification model.
4. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 3 is characterized by: In step S3, the positive and negative nearest neighbor dual flexible non-negative representation is a non-negative least squares problem, and the coefficient vector α is solved by the variable splitting method. By introducing the auxiliary variable z, the objective function of the positive and negative nearest neighbor dual flexible non-negative representation classifier is reformulated as follows: Convert the above formula into Lagrangian function and use the alternating direction multiplier method to deduce and optimize it; the Lagrangian function is constructed as shown below: Where δ is the Lagrange multiplier vector, μ>0 is the penalty parameter, and <δ,z-α> is the inner product of vector α and vector z-α.
5. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 4 is characterized by: In step S3, the Lagrangian function is solved by iterating α and z; and the relevant variables are initialized and set: α0 = f + 0 = f - 0=z0=δ0=0, μ>0; use α t 、f + t 、f - t 、z t and δ t represents the optimization variable and Lagrange multiplier when the iteration is t (t = 0, 1, 2, ..., T), and T is the preset threshold; Adopt the strategy of variable optimization to update variables one by one; decompose the solution process of Lagrangian function into two steps about variables α, f + 、f - The five sub-problems of , z and δ include the following steps: S3.
1. Update the variable α and obtain the analytical solution of α; S3.
2. Update variable f + , we get f + The analytical solution of S3.
3. Update variable f - , we get f - The analytical solution of S3.
4. Update the variable z and obtain the analytical solution of z; S3.5, updated augmented Lagrange multiplier δ; S3.
6. Repeat iterative steps S3.1 to S3.5 until the convergence condition is met or the number of iterations exceeds a preset threshold T.
6. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 5, characterized in that: In step S3.1, fix f + 、f - , z and δ, simplify the Lagrangian function into the following objective function: To calculate the derivative of vector α, let The derivative of F1 with respect to α is calculated as: The derivative of F2 with respect to α is calculated as: The derivative of F3 with respect to α is calculated as: Finally, let the sum of these derivatives be zero: Therefore, the analytical solution of α is: in, 7. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 6, characterized in that: In step S3.2, fix α, f - , z and δ, simplify the Lagrangian function into the following objective function: The objective function of this problem is f + Taking the partial derivative and setting it to zero, we get: After finishing, we can get: Therefore, we get f + The analytical solution is: In step S3.3, fix α and f + , z and δ, simplify the Lagrangian function into the following objective function: The objective function of this problem is f - Taking the partial derivative and setting it to zero, we get: After finishing, we can get: Therefore, we get f - The analytical solution is:
8. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 7 is characterized by: In step S3.4, α and f are fixed. + 、f - and δ, simplifying the Lagrangian function into the following objective function: The analytical solution of z is:
9. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 8, characterized in that: In step S3.5, the augmented Lagrange multiplier δ is updated by the following formula: d t+1 =d t +μ(z t+1 -a t+1 ) In step S3.6, the convergence condition is: satisfying ||α t -z t ||2≤η,||α t+1 -α t ||2≤η and ||z t+1 -z t ||2≤η, where η is a preset threshold.
10. The non-negative representation classification method with positive and negative nearest neighbor dual flexible constraints according to claim 1, characterized in that: In step S4, the residual of the test sample in each category of the training sample set is calculated as: Among them, X j is the j-th class training sample, α j is the coefficient vector corresponding to the j-th class training sample; In step S5, classification is performed based on the residuals, and the test sample is identified as the category corresponding to the minimum residual: