A feature band selection method based on neural network model pruning
By using neural network model pruning techniques to filter hyperspectral data bands, the problem of insufficient discriminative power in hyperspectral classification models was solved, achieving a significant improvement in classification accuracy and a reduction in cost.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-10
- Publication Date
- 2026-03-17
AI Technical Summary
Existing hyperspectral classification models cannot effectively describe the discriminative nature of classification tasks, resulting in weak generalization performance. Furthermore, infrared lenses are expensive, making it difficult to promote hyperspectral analysis technology.
A feature band selection method based on neural network model pruning is adopted. By constructing a classification network model, the discriminator and generator are trained using the cross-entropy function and mini-batch stochastic gradient descent method. The discriminative hyperspectral data bands are selected, bands with insufficient information are pruned, and bands with stronger discriminative power for classification are retained.
It improves the generalization and accuracy of the classification model, reduces the cost of acquiring hyperspectral data, and enhances the analytical precision of the classification model.
Smart Images

Figure CN116342969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of hyperspectral nondestructive testing technology, and in particular to a feature band selection method based on neural network model pruning. Background Technology
[0002] Hyperspectral imaging can simultaneously image a specific area across dozens or hundreds of consecutive spectral bands, resulting in a hyperspectral image. A hyperspectral image consists of hundreds of consecutive bands, containing rich spectral information. This rich spectral information provides excellent conditions for land cover identification and target detection. Currently, hyperspectral data analysis techniques are widely used in applications such as food adulteration detection, drug category identification, and building material quality testing. Hyperspectral data classification is fundamental to hyperspectral image applications. Feature extraction algorithms extract spectral information for classification, and then a classifier divides the extracted features into different land cover categories. Commonly used hyperspectral classification algorithms include Partial Least Square Discriminant Analysis (PLSDA), Support Vector Machine (SVM), and Artificial Neural Network (ANN). However, many classification algorithms still rely on full-band hyperspectral information, and the high cost of infrared hyperspectral lenses hinders the widespread adoption of hyperspectral analysis technology.
[0003] Zhejiang University proposed a hyperspectral band selection method based on neural networks in its patent application, "A Hyperspectral Band Selection Method and Device Based on Transformer Network" (Patent Application No.: 202211210073.4, Publication No.: CN 115641503 A). This method uses a reconstruction model with an attention mechanism to obtain band masks and correlation matrices, and designs a scoring function to describe the representativeness and redundancy of bands, thereby selecting bands with high representativeness and low redundancy. However, the aforementioned method uses minimizing the reconstruction loss as the optimization function. The resulting band masks and correlation matrices cannot describe the discriminative power of the classification task, making it difficult for the classification model to detect the optimal classification surface for each category, resulting in weak generalization performance of the classification model on the prediction set. Summary of the Invention
[0004] In view of the above-mentioned shortcomings of the prior art, the present invention provides a feature band selection method based on neural network model pruning, which effectively solves the problem that classification models cannot describe the discriminativeness of classification tasks, resulting in weak generalization performance.
[0005] This invention provides a feature band selection method based on neural network model pruning, comprising the following steps:
[0006] S1. Obtain the hyperspectral dataset;
[0007] S2. Divide the dataset into a training set, a validation set, and a prediction set;
[0008] S3. Construct a classification network model based on the dataset;
[0009] S4. Construct a loss function for training the classification network model;
[0010] S5. Input the training set and validation set into the classification network model for training, prune the feature bands, and select the discriminative hyperspectral data bands.
[0011] S6. Classify the prediction set using the trained classification network model and the selected feature bands to obtain the classification result.
[0012] Preferably, the prediction set in step S2 is used to evaluate the model accuracy corresponding to the selected bands.
[0013] Preferably, the classifier network model constructed in step S3 consists of a fully connected layer, a batch processing layer, a nonlinear operation layer, and an output layer.
[0014] Preferably, the loss function of the classifier network in step S4 is the cross-entropy function, which is:
[0015]
[0016] Where N is the total number of data samples, C is the total number of data categories, and y i,t Binary label of category t, p i,t It is the probability of the i-th data sample with respect to category t.
[0017] Preferably, the p i,t Calculated using the Softmax function:
[0018]
[0019] Where, f(x) i ) t It is the predicted value of the i-th data sample with respect to category t.
[0020] Preferably, step S5 includes:
[0021] S51. Initialize the classification network model and save the initial weights;
[0022] S52. The discriminator and generator are trained using mini-batch stochastic gradient descent. The Adam optimizer is used as the optimizer with a learning rate of 0.0001.
[0023] S53. Randomly collect a subset of samples from the training set to optimize the loss function until the number of training steps reaches a first set threshold.
[0024] S54. Randomly collect a subset of samples from the validation set to optimize the loss function until the number of training steps reaches the second set threshold.
[0025] S55. Summing the learning weight directions of the input layer of the classification network model with respect to the training set and the gradient directions on the validation set for each band, measuring the information content of each candidate band, and deleting the hyperspectral band with the least information content.
[0026] S56. Determine whether the selected bands have reached the set number of bands. If the set number of bands has been reached, proceed to step S6. Otherwise, reset the classification network model to the initialization state and remove the unselected bands, and proceed to steps S52-S56 again.
[0027] Preferably, step S54 further includes:
[0028] The loss function is optimized by randomly collecting a subset of samples from the validation set until the cross-entropy between the predicted value and the label value in the quantitative analysis of the validation set converges to less than a third set threshold.
[0029] The present invention provides a feature band selection method based on neural network model pruning. By using neural network model pruning technology, the required bands are reduced while ensuring the accuracy of the analysis technology. This method can retain hyperspectral data bands with stronger discriminative power for classification, thereby significantly improving the classification accuracy, enhancing the generalization of the classification model, and reducing the cost of acquiring hyperspectral data in industrial settings. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 A flowchart of a feature band selection method based on neural network model pruning provided in an embodiment of the present invention;
[0032] Figure 2 This is a flowchart of the method for training a classification network model in an embodiment of the present invention;
[0033] Figure 3 This is a graph showing the relationship between the band deletion ratio in the visible-near-infrared shortwave band and the model classification accuracy in an embodiment of the present invention.
[0034] Figure 4 This is a graph showing the relationship between the band deletion ratio of the near-infrared shortwave to near-infrared longwave bands and the model classification accuracy in an embodiment of the present invention.
[0035] Figure 5 This is a graph showing the relationship between the band deletion ratio in the visible-near-infrared long-wave band and the model classification accuracy in an embodiment of the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be further described clearly and completely below with reference to the accompanying drawings of the embodiments of this invention. It should be noted that the described embodiments are merely some embodiments of this invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0037] In the embodiments of this application, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0038] The terms "first" and "second" used in the embodiments of this application are for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a system, product, or device that includes a series of components or units is not limited to the listed components or units, but may optionally include unlisted components or units, or may optionally include other components or units inherent to such products or devices. In the description of this application, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0039] like Figure 1 The diagram shown is a flowchart of a feature band selection method based on neural network model pruning according to the present invention, which includes the following steps:
[0040] S1. Obtain the hyperspectral dataset;
[0041] S2. Divide the dataset into a training set, a validation set, and a prediction set;
[0042] Different samples are randomly selected from the dataset as the training set, validation set, and prediction set, where the prediction set is used to evaluate the model accuracy corresponding to the selected band.
[0043] S3. Construct a classification network model based on the dataset;
[0044] A classifier network consisting of a fully connected layer, a batch processing layer, a nonlinear operation layer, and an output layer is constructed for the hyperspectral data to be processed. This network has the function of distinguishing multiple data categories.
[0045] S4. Construct a loss function for training the classification network model;
[0046] The loss function of the classifier network is the cross-entropy function, which is:
[0047]
[0048] Where N is the total number of data samples, C is the total number of data categories, and y i,t Binary label of category t, p i,t It is the probability of the i-th data sample with respect to category t.
[0049] p i,t Calculated using the Softmax function:
[0050]
[0051] Where, f(x) i ) t It is the predicted value of the i-th data sample with respect to category t.
[0052] S5. Input the training set and validation set into the classification network model for training, prune the feature bands, and select the discriminative hyperspectral data bands.
[0053] like Figure 2 The diagram shown is a flowchart of the method for training a classification network model in an embodiment of the present invention, which specifically includes the following steps:
[0054] S51. Initialize the classification network model and save the initial weights;
[0055] S52. The discriminator and generator are trained using mini-batch stochastic gradient descent. The Adam optimizer is used as the optimizer with a learning rate of 0.0001.
[0056] S53. Randomly collect a subset of samples from the training set to optimize the loss function until the number of training steps reaches a first set threshold.
[0057] S54. Randomly collect a subset of samples from the validation set to optimize the loss function until the number of training steps reaches the second set threshold, or until the cross-entropy between the predicted value and the label value of the validation set converges to less than the third set threshold.
[0058] S55. Summing the learning weight directions of the input layer of the classification network model with respect to the training set and the gradient directions on the validation set for each band, measuring the information content of each candidate band, and deleting the hyperspectral band with the least information content.
[0059] S56. Determine whether the selected bands have reached the set number of bands. If the set number of bands has been reached, proceed to step S6. Otherwise, reset the classification network model to the initialization state and remove the unselected bands, and proceed to steps S52-S56 again.
[0060] S6. Classify the prediction set using the trained classification network model and the selected bands to obtain the classification results.
[0061] The effects of the present invention will be further explained below with reference to specific application examples. In this embodiment, hyperspectral imaging is used to identify and classify wild kudzu varieties. The specific method and steps are as follows:
[0062] Step 1: Measured hyperspectral data of 1897 kudzu roots and vines, including 1008 vine data and 889 root data. The hyperspectral bands were 410-990nm (visible-near-infrared short-wave lens) and 950-2500nm (near-infrared short-wave-near-infrared long-wave lens). The two types of lenses were used separately or simultaneously for data analysis.
[0063] Step 2: Randomly select 1213 samples as the training set D tr 304 samples were used as the validation set D val The remaining 380 unlabeled samples are used as the prediction set D. te It is used to evaluate the accuracy of the model corresponding to the selected band.
[0064] Step 3: Construct a classification network model based on hyperspectral data: Construct a classifier network for hyperspectral data consisting of a fully connected layer, a batch processing layer, a nonlinear operation layer, and an output layer. This network has the function of distinguishing multiple data categories.
[0065] Step 4: Construct the loss function for training the classification network model;
[0066] The loss function of the classifier network is the cross-entropy function, which is:
[0067]
[0068] Where N is the total number of hyperspectral data samples, C is the total number of hyperspectral data categories, and y i,t Binary label of category t, p i,t It is the probability of the i-th hyperspectral data sample with respect to category t.
[0069] p i,t Calculated using the Softmax function:
[0070]
[0071] Where, f(x) i ) t It is the predicted value of the i-th hyperspectral data sample with respect to category t.
[0072] Step 5: Train the classification network model using the training set and validation set, and select the discriminative hyperspectral data bands;
[0073] The classification network model is initialized and the initial weights are saved. The discriminator and generator are trained using mini-batch stochastic gradient descent. The Adam optimizer is used as the optimizer with a learning rate of 0.0001.
[0074] From training set D tr Randomly sample a subset of samples to optimize the loss function until the training steps reach 45,000; then use the validation set D. val Randomly collect a subset of samples to optimize the loss function until the number of training steps reaches a certain set value or until the cross-entropy between the predicted value and the label value in the quantitative analysis of the validation set converges to less than a certain set value.
[0075] The input layer of the classification network model is summed with respect to the gradient directions on the training set and the validation set for each band to measure the information content of each candidate band, and the hyperspectral bands with the least information are removed. It is then determined whether the selected bands have reached the set number. If so, the trained classification network model and the selected bands are used to classify the prediction set to obtain the classification result. Otherwise, the classification network model is reset to its initial state for retraining, and unselected bands are removed until the set number of selected bands is reached.
[0076] To further verify the application effect of this invention, five random cross-validations were performed on the training, validation, and prediction sets of visible-near-infrared shortwave (410-950nm), near-infrared shortwave-near-infrared longwave (950-2500nm), and visible-near-infrared longwave lenses (410-2500nm). A band selection algorithm based on partial least squares discriminant analysis was used as a comparison method. The classification performance comparison results of the two band selection methods on the neural network are shown in the table below:
[0077]
[0078] As shown in the table above, in the near-infrared short-wave to near-infrared long-wave band lens (950-2500nm) dataset, the results of five calculations using the partial least squares method (PLS) with 90% reduction are as follows: the classification accuracy for the training set is 91.46%, the classification accuracy for the validation set is 87.42%, and the classification accuracy for the prediction set is 86.26%; while the classification accuracy for the training set obtained by the method of this invention is 99.98%, the classification accuracy for the validation set is 98.61%, and the classification accuracy for the prediction set is 98.58%.
[0079] Figure 3 A graph showing the relationship between the band deletion ratio in the visible-near-infrared shortwave band and the model classification accuracy. Figure 4 A graph showing the relationship between the band deletion ratio in the near-infrared shortwave to near-infrared longwave bands and the model classification accuracy. Figure 5 The graph shows the relationship between the band deletion ratio in the visible-near-infrared long-wave band and the model classification accuracy. As can be seen from the graph, partial least squares-based methods all show a decreasing trend in classification accuracy when the band deletion ratio exceeds 30%; however, the method of this invention, due to its band deletion method using model pruning, only shows a decreasing trend in accuracy when the band deletion ratio exceeds 60%. This means that the method of this invention can retain bands with stronger discriminative power for classification, thus significantly improving classification accuracy.
[0080] In summary, the feature band selection method based on neural network model pruning provided by this invention reduces the required bands while ensuring the accuracy of the analysis technology through neural network model pruning. It can retain hyperspectral data bands with stronger discriminative power for classification, thereby significantly improving the classification accuracy, enhancing the generalization of the classification model, and reducing the cost of acquiring hyperspectral data in industrial settings.
[0081] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0082] The embodiments described above are merely illustrative of several implementations of the present invention, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and these modifications and improvements all fall within the scope of protection of the present invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
[0083] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A feature band selection method based on neural network model pruning, characterized in that, The method comprises the following steps: S1, obtaining a hyperspectral dataset; S2, dividing the dataset into a training set, a validation set and a prediction set; S3, constructing a classification network model according to the dataset; S4, constructing a loss function for training the classification network model; S5, inputting the training set and the validation set into the classification network model for training, pruning for characteristic wave bands, and screening out discriminative hyperspectral data wave bands; S6, classifying the prediction set by using the trained classification network model and the screened characteristic wave bands, and obtaining a classification result; The step S5 comprises: S51, initializing the classification network model and saving the initialized weights; S52, training the discriminator and the generator by using a small batch random gradient descent method, using an Adam optimizer as the optimizer, and setting the learning rate to 0.0001; S53, randomly collecting a sample subset from the training set to optimize the loss function, and stopping until the training step number reaches a first set threshold; S54, randomly collecting a sample subset from the validation set to optimize the loss function, and stopping until the training step number reaches a second set threshold; S55, summing the training set learning weight direction corresponding to each wave band and the gradient direction on the validation set for the input layer of the classification network model, measuring the information amount of each candidate wave band, and deleting the hyperspectral wave band with the most insufficient information amount; S56, judging whether the screened wave bands reach a set wave band number, if yes, performing the step S6, otherwise, resetting the classification network model to the initialized state, removing the unselected wave bands, and performing the steps S52-S56 again.
2. The feature band selection method based on neural network model pruning according to claim 1, characterized in that, The prediction set in the step S2 is used for evaluating the model precision corresponding to the screened wave bands.
3. The method of claim 1, wherein the method is based on a neural network model pruning. The classifier network model constructed in the step S3 comprises a full connection layer, a batch processing layer, a nonlinear operation layer and an output layer.
4. The method of claim 1, wherein the method is based on a neural network model pruning. The loss function of the classifier network in the step S4 adopts a cross-entropy function, and the cross-entropy function is: where N is the total number of data samples, C is the total number of data classes, y i,t a binary label for class t, p i,t is the probability of the ith data sample with respect to class t.
5. The feature band selection method based on neural network model pruning according to claim 4, characterized in that, The p i,t By the Softmax function calculation: where f(x i ) t is the predicted value of the ith data sample with respect to class t.
6. The method of claim 1, wherein the method is based on a neural network model pruning. The step S54 further comprises: Randomly collecting a sample subset from the validation set to optimize the loss function, and stopping until the cross-entropy of the quantitative analysis prediction value and the label value of the validation set converges to less than a third set threshold.
Citation Information
Patent Citations
Hyperspectral band selection method and device based on Transform network
CN115641503A
Hyperspectral band selection method based on separable convolution and hard threshold function
CN109344698A