A hyperspectral remote sensing image classification-oriented training sample selection method
By extracting features using the GSCVIT model and optimizing training with dynamic distribution balance loss, the high-cost annotation and class imbalance problems of hyperspectral remote sensing images are solved, improving the model's classification accuracy and minority class recognition ability. It is applicable to fields such as land classification, vegetation monitoring, and environmental assessment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2026-03-24
AI Technical Summary
The data annotation of hyperspectral remote sensing images is costly and class-imbalanced. Existing sample selection strategies are difficult to balance representativeness, discriminativeness, and class balance, resulting in low model recognition accuracy in a few classes and affecting the effectiveness of practical applications.
We use a pre-trained GSCVIT model to extract features, combine multi-head attention weights and spatial attention entropy, select core set samples using the K-Center greedy algorithm, and optimize training using Dynamic Distribution Balance Loss (DDB Loss). We dynamically adjust class weights to improve the model's classification performance in imbalanced scenarios.
It significantly improves the overall accuracy of hyperspectral remote sensing image classification and the ability to identify a few classes, effectively alleviates the class imbalance problem, and improves the decision-making accuracy and response efficiency of the model in practical applications.
Smart Images

Figure CN120388253B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image classification technology, and in particular to a method for selecting training samples for hyperspectral remote sensing image classification. Background Technology
[0002] Hyperspectral remote sensing (HRSI) images possess hundreds of continuous narrow bands and high spectral resolution, enabling detailed characterization of the spectral properties of ground features. They are widely used in land classification, vegetation monitoring, and environmental assessment, demonstrating significant practical value and economic potential. However, HRSI data annotation remains highly reliant on manual labor, leading to challenges such as low sample utilization efficiency and weak model generalization ability. In practical applications, the cost of hyperspectral image sample annotation is extremely high, relying on professional ground measurements and manual classification, resulting in a very limited number of available labeled samples. Therefore, selecting "which samples" for annotation and training becomes crucial—different selection strategies directly impact the model's learning effectiveness and final performance.
[0003] Furthermore, hyperspectral remote sensing often suffers from severe class imbalance, where the majority class samples far outnumber the minority class samples. This not only leads to model bias during training—performing well on the dominant class but poorly on the rarer class—but can also have serious consequences in real-world applications. For example, in ecological monitoring and disaster identification, the minority class often represents key targets (such as wetlands or fire zones), and misclassification of these classes directly impacts decision-making accuracy and response efficiency.
[0004] While current sampling techniques have proposed various sample selection strategies, including random sampling, hierarchical sampling, cluster sampling, active learning, and core set sampling, these methods still have many limitations when dealing with hyperspectral images characterized by high annotation costs, uneven class distribution, and complex feature representations. For example, while random sampling is simple, it cannot identify heterogeneous regions with discriminative value; clustering or core set methods emphasize representativeness but ignore the model's perception of the difficulty in discriminating samples; and existing imbalanced learning methods, such as FocalLoss or class-balanced loss, only apply static weighting at the loss level, making it difficult to dynamically adjust the training strategy based on the actual performance of the model.
[0005] Therefore, there is an urgent need for a novel sample selection and training optimization mechanism that balances sample representativeness, discriminative power, and class balance, in order to improve the model's recognition accuracy and generalization ability for various land features in hyperspectral images under limited labeled sample conditions. This need is widespread in many practical engineering fields such as forestry resource surveys, farmland management, environmental monitoring, geological exploration, and urban safety, and has extremely high application and promotion value. Summary of the Invention
[0006] The purpose of this invention is to provide a training sample selection method for hyperspectral remote sensing image classification. This method aims to effectively select representative and discriminative training samples in practical application scenarios where annotation costs are limited. This not only improves the overall classification accuracy but also significantly enhances the ability to identify minority and weak class targets, effectively alleviating the performance bottleneck caused by class imbalance.
[0007] To achieve the above objectives, this invention provides a method for selecting training samples for hyperspectral remote sensing image classification, comprising the following steps:
[0008] S1, Given an unlabeled dataset in This represents a hyperspectral image sample with spatial dimensions of H×W and spectral band number of B.
[0009] S2. Use the pre-trained GSCVIT model to extract features from the dataset to obtain classification features F and multi-head attention weights;
[0010] S3. Calculate the spatial attention entropy (SSAE) based on the attention weights described in step S2, and concatenate the classification features with the spatial attention entropy to generate enhanced features;
[0011] S4. Using the K-Center greedy algorithm, a core set of samples D is selected from the original dataset based on the enhanced features. c ;
[0012] S5. Use the group sampling loader to load training data and use Dynamic Distributed Balanced Loss (DDB Loss) to train the model to optimize classification performance in imbalanced class scenarios.
[0013] Preferably, in step S2, the input feature map size of the pre-trained GSCVIT model is C×8×8, where C is the number of spectral bands, the input image patch is normalized to the [0,1] interval, and data augmentation is performed by horizontal flipping, vertical flipping and random rotation.
[0014] Preferably, for each batch of data x b ∈D, obtain classification features through backpropagation using the GSCVIT model. and multi-head attention weight Where L is the number of layers, H is the number of heads, and P is the number of positions;
[0015] Softmax normalization is applied to the attention weights of the h-th head in the l-th layer:
[0016]
[0017] Calculate attention entropy:
[0018]
[0019] Preferably, in step S4, the K-Center greedy sampling step includes:
[0020] Initialize the core set S, and select initial samples based on the stratified sample distribution;
[0021] Iterative sample selection: for unselected sample x j ∈D / S, calculate the minimum Euclidean distance from its enhanced features to the core set.
[0022] Combining attention entropy SSAE j Calculate the score: S j =λ·d j +(1-λ)·SSAE j , where λ∈[0,1] is the balance parameter;
[0023] The sample with the highest score is selected and added to the core set until the core set size reaches the preset value N.
[0024] Preferably, in step S4, the training data is loaded using a group sampling loader, specifically including the following steps:
[0025] The order of samples within each category is randomly shuffled.
[0026] The shuffled samples are grouped into groups of size n, and the remaining samples are grouped separately.
[0027] The samples grouped into all categories are randomly shuffled a second time to generate training batches.
[0028] Preferably, in step S4, the construction steps of the dynamically distributed balanced loss (DDB) loss include:
[0029] Define recall and accuracy Among them, TP i 、FN i and FP i These represent the number of true positive, false negative, and false positive samples in the i-th category, respectively.
[0030] Initialize the class weight matrix C represents the number of categories;
[0031] The weights are dynamically updated based on the recall and precision of the validation set after each training round:
[0032] Recall weighting:
[0033] Accuracy weighting:
[0034] Recall i Let be the recall rate for class i, SF be the scaling factor, and Precision be the retrieval rate for class i. i Let be the accuracy of the i-th class;
[0035] The dynamic weights are normalized, and negative class sensitivity is introduced to construct the loss function, as follows:
[0036] Normalize after combining the recall and precision weights:
[0037] The dynamic distributed equilibrium loss is calculated as follows:
[0038]
[0039] in, It is the predicted score of the i-th class of the k-th sample. It is the true label of the i-th category of the k-th sample, and the true label is encoded using one-hot encoding;
[0040] C is the total number of categories, w i λ is the dynamic weight matrix, and λ is a hyperparameter used to adjust the negative class loss.
[0041] Therefore, the training sample selection method for hyperspectral remote sensing image classification using the above-described structure has the following beneficial effects:
[0042] The dynamic collaborative balanced sampling method proposed in this invention can effectively identify and prioritize key samples in hyperspectral remote sensing data in practical application scenarios where annotation costs are limited, while dynamically optimizing the category distribution, significantly improving the classification accuracy and stability of the model under imbalanced data.
[0043] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0044] Figure 1 This is a flowchart illustrating a training sample selection method for hyperspectral remote sensing image classification according to the present invention. Detailed Implementation
[0045] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0046] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0047] Example
[0048] like Figure 1 As shown, this invention provides a method for selecting training samples for hyperspectral remote sensing image classification, comprising the following steps:
[0049] S1, Given an unlabeled dataset in This represents a hyperspectral image sample with spatial dimensions of H×W and spectral band number of B.
[0050] S2. Use the pre-trained GSCVIT model to extract features from the dataset to obtain classification features F and multi-head attention weights;
[0051] S3. Calculate the spatial attention entropy (SSAE) based on the attention weights described in step S2, and concatenate the classification features with the spatial attention entropy to generate enhanced features;
[0052] S4. Using the K-Center greedy algorithm, a core set of samples D is selected from the original dataset based on the enhanced features. c ;
[0053] S5. Use the group sampling loader to load training data and use Dynamic Distributed Balanced Loss (DDB Loss) to train the model to optimize classification performance in imbalanced class scenarios.
[0054] The Dynamic Distribution Balance Loss (DDB Loss) employs a dual-metric dynamic weight adjustment strategy based on recall and precision to optimize the model's classification performance with a fixed training sample size. The specific process is as follows:
[0055] Indicator definition:
[0056] Recall measures a model's ability to identify positive samples; it represents the proportion of positive samples that are correctly identified. The formula is:
[0057]
[0058] Wherein, TP (True Positives) is the number of samples correctly predicted as positive by the model, and FN (False Negatives) is the number of samples incorrectly predicted as negative by the model but actually as positive.
[0059] Precision measures the proportion of samples that are actually positive out of all samples predicted as positive. Its mathematical expression is:
[0060]
[0061] Wherein, FP is the number of samples that the model incorrectly predicted as positive but were actually negative.
[0062] Dynamic category weight calculation:
[0063] Initialize the weight matrix: Construct a weight array based on the class distribution of the initial training data. (C represents the number of categories);
[0064] Dynamic update rule: After each training round, the weights are updated based on the current model's performance on the validation set.
[0065] Recall weighting:
[0066]
[0067] Precision weighting:
[0068]
[0069] Ri is the recall of class i, SF (Scaling Factor) is the scaling factor, and Pi is the precision of class i.
[0070] Weighted normalization: Normalizing the recall and precision weights after merging them.
[0071]
[0072] Loss function construction:
[0073] Dynamic Distribution Balanced Loss (DDB Loss) introduces dynamic class weights and negative class sensitivity into the loss calculation, enabling the model to better handle the balance problem between classes.
[0074] Dynamic class weights: By loading a dynamic class weight array w i The model can adjust the learning weights during training, increasing the proportion of weak classes learned.
[0075] Negative class sensitivity adjustment: The negative class loss is adjusted through hyperparameters. Its role is to control the impact of negative samples on the overall loss, prevent excessive penalty, and thus reduce the model's bias towards the negative class.
[0076] The dynamic distributed equilibrium loss is calculated as follows:
[0077]
[0078] in, It is the predicted score of the i-th class of the k-th sample. It is the true label of the i-th category of the k-th sample, and the true label is encoded using one-hot encoding;
[0079] C is the total number of categories, w i λ is the dynamic weight matrix, and λ is a hyperparameter used to adjust the negative class loss.
[0080] Attention entropy-enhanced core set sampling
[0081] (1) Feature and attention entropy extraction:
[0082] For each batch of data x b ∈D:
[0083] Backpropagation to obtain classification features:
[0084]
[0085] Extracting multi-head attention weights in Where H is the number of heads, P is the number of positions, L is the number of layers, and the normalized weight for the h-th head in the l-th layer at position p is:
[0086]
[0087] Calculate attention entropy:
[0088]
[0089] (2) Enhanced feature construction:
[0090] By concatenating categorical features with attention entropy, enhanced features are generated to simultaneously capture the semantic information and uncertainty of the samples:
[0091]
[0092] (3) K-Center Greedy Sampling
[0093] Based on enhanced features, an improved K-Center greedy algorithm is used to select the core set. The specific steps are as follows:
[0094] Initialization: Select sample x stratified according to sample distribution init join in
[0095] Iterative selection (for a = 2 to A):
[0096] For each unselected sample Calculate its minimum Euclidean distance to the core set:
[0097]
[0098] By combining the distance term and the attention entropy term, the weights are adjusted by balancing the parameter λ∈[0,1].
[0099] s j =λ·d j +(1-λ)·SSAE j ;
[0100] iii. Select N with the highest score a One sample is added to the core set:
[0101]
[0102] Termination: When At that time, output core set
[0103] Group sampling loader
[0104] By loading samples using a group sampling loader, the model can access a richer combination of samples in each iteration, thereby improving training stability and reducing the risk of overfitting. The detailed steps are as follows:
[0105] Shuffle by category: For each category c i The order of samples within the model is randomly shuffled to reduce the model's dependence on a fixed order and improve generalization ability.
[0106] Grouping: The shuffled samples are grouped according to their group size. If the number of samples is insufficient or not divisible, the remaining samples are grouped separately without resampling, ensuring a balanced distribution between groups.
[0107] Shuffling between groups: After all groups of categories are aggregated, they are randomly shuffled again to avoid the fixed order of mini-batch during training and to enhance training diversity.
[0108] This invention was conducted on a personal computer equipped with a 12th-generation Intel i9-12900H processor (2.50GHz), 16GB of RAM, and a Windows 10 operating system. The experimental environment was built using Python 3.8 and the PyTorch framework. The GSC-ViT model was used as the baseline model for training and testing. The input feature map size was initialized to C×8×8, where C represents the number of spectral bands. The input image patches were normalized to the [0,1] interval and expanded using data augmentation methods, including horizontal flipping, vertical flipping, and random rotations of 90°, 180°, and 270°. The model was trained using the AdamW optimizer with 200 training epochs, a learning rate of 0.001, a weight decay coefficient of 0.05, and a batch size of 128. To ensure the reliability of the experimental results, each experiment was repeated 10 times, and the average value was recorded as the final result.
[0109] Experimental verification:
[0110] To comprehensively evaluate the effectiveness of the proposed method, systematic experiments were conducted on four typical hyperspectral remote sensing datasets (Indian Pines, Salinas, Pavia University, and WHU-Hi-LongKou). On each dataset, a uniform finite labeled sample condition was set, and training was performed using 512 (Indian Pines), 270 (Salinas), 44 (Pavia University), and 102 (WHU-Hi-LongKou) samples, respectively. Based on this, the proposed Dynamic Class Boundary Sampling (DCBS) method was compared with commonly used sampling strategies such as random sampling, hierarchical sampling, entropy sampling, MC Dropout sampling, and Coreset sampling, systematically analyzing the differences in classification performance of each method in class-imbalanced scenarios. Furthermore, to verify the independent contribution of each module in the proposed method, ablation experiments were constructed based on the GSCViT model, progressively introducing a grouped sampling loader, entropy-guided coreset sampling, and Dynamic Distribution Balance Loss (DDB Loss), analyzing the gain effects of different modules on model performance. The experiment used overall accuracy (OA), average accuracy (AA), Kappa coefficient, and F1 score as the main evaluation indicators, and focused on analyzing the performance of each method under weak class and very small sample conditions.
[0111] This invention utilizes the Indian Pines dataset, Salinas dataset, Pavia University dataset, and WHU-Hi-LongKou dataset, as shown below:
[0112] 1. Indian Pines dataset (512 training samples):
[0113] In this dataset, random sampling resulted in significant class imbalance, particularly with classes 1, 7, and 9 having much lower accuracy than other classes, dragging down the overall mean accuracy (AA). The DCBS method, by dynamically balancing the inter-class weights, significantly improved the recognition performance of these weaker classes, increasing accuracy by 27.54%, 27.43%, and 56.1%, respectively. Overall AA and OA improved by 9.89% and 3.38%, respectively, making it the best performing sampling method and demonstrating its adaptability to small samples and difficult-to-classify classes.
[0114] 2. Salinas dataset (270 training samples):
[0115] In the Salinas dataset, which has a large number of categories and a complex distribution, random sampling performs poorly across multiple categories, while entropy sampling deteriorates due to its lack of effective inter-class guidance. In contrast, the DCBS method effectively improves the classification performance of classes 3, 8, and 11, with a significant improvement in average accuracy. It also outperforms all four metrics—OA, AA, Kappa, and F1—demonstrating its strong robustness to problems of sample scarcity and inter-class confusion.
[0116] 3. Pavia University dataset (44 training samples):
[0117] In the Pavia University dataset dominated by urban features, the overall performance of the various methods was similar, but DCBS still demonstrated accurate modeling capabilities for difficult-to-classify categories, especially for categories 6, 7, and 8, which performed poorly in other methods. The AA improved by 1.86%, and the OA reached 98.63%, achieving better performance at both the micro and macro levels, thus verifying its stable generalization ability.
[0118] 4. WHU-Hi-LongKou dataset (102 training samples):
[0119] This dataset presents challenging characteristics such as subtle differences in ground features and blurred boundaries, making it difficult to obtain representative samples through random sampling, resulting in an accuracy (AA) of only 89.19%. In this context, DCBS effectively guides the sample selection strategy, significantly improving the accuracy of Class 4 and Class 8 by 16.45% and 10.73% respectively, with an AA improvement of 8.55% and an OA reaching 98.75%, demonstrating its ability to construct a balanced training set in complex semantic scenarios.
[0120] The proposed dynamic cooperative balanced sampling method demonstrates significant advantages on four remote sensing datasets. On the Indian Pines dataset, it significantly improves the classification accuracy for classes 1, 7, and 9 compared to random sampling, with overall AA and OA improving by 9.89% and 3.38%, respectively. On the Salinas dataset, it effectively alleviates the classification difficulties for classes 3, 8, and 11, with AA reaching a maximum of 95.93%. On the Pavia University dataset, even with very few samples, it still achieves more stable identification of core classes, improving OA and AA by 1.37% and 1.43%, respectively, compared to the Coreset method. On the WHU-Hi-LongKou dataset, this method achieves the best performance in OA, AA, Kappa, and F1 scores, maintaining excellent classification consistency even with significant differences in class distribution. These results fully validate the effectiveness and robustness of the proposed method in scenarios with limited samples and imbalanced classes.
[0121] 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 preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A method for selecting training samples for hyperspectral remote sensing image classification, characterized in that: Includes the following steps: S1, Given an unlabeled dataset ,in The spatial dimension is The number of spectral bands is B Hyperspectral image samples; S2. Use the pre-trained GSCVIT model to extract features from the dataset to obtain classification features F and multi-head attention weights; S3. Calculate the spatial attention entropy (SSAE) based on the attention weights described in step S2, and concatenate the classification features with the spatial attention entropy to generate enhanced features; S4. Using the K-Center greedy algorithm, a core set of samples is selected from the original dataset based on the enhanced features. D c ; The K-Center greedy sampling steps include: Initialize the core set S, and select initial samples based on the stratified sample distribution; Iterative sample selection: for unselected samples Calculate the minimum Euclidean distance from its enhanced features to the core set. ; Combining attention entropy SSAE j Calculate the score: ,in For balance parameters; The highest-scoring samples are added to the core set until the core set size reaches the preset value. N ; S5. Use the group sampling loader to load training data and use Dynamic Distributed Balanced Loss (DDB Loss) to train the model to optimize classification performance in imbalanced class scenarios.
2. The training sample selection method for hyperspectral remote sensing image classification according to claim 1, characterized in that: In step S2, the input feature map size of the pre-trained GSCVIT model is C×8×8, where C is the number of spectral bands. The input image patch is normalized to the [0,1] interval and data augmentation is performed by horizontal flipping, vertical flipping and random rotation.
3. The method for selecting training samples for hyperspectral remote sensing image classification according to claim 1, characterized in that: For each batch of data Classification features are obtained through backpropagation of the GSCVIT model. and multi-head attention weight ,in L For the number of floors, H For the number of heads, P For the number of positions; For the l Layer h The attention weights of the head are normalized using softmax: ; Calculate attention entropy: 。 4. The method for selecting training samples for hyperspectral remote sensing image classification according to claim 1, characterized in that: In step S4, the training data is loaded using the group sampling loader, which specifically includes the following steps: The order of samples within each category is randomly shuffled. The shuffled samples were grouped by size. n Group the samples, and group the remaining samples separately. The samples grouped into all categories are randomly shuffled a second time to generate training batches.
5. The method for selecting training samples for hyperspectral remote sensing image classification according to claim 1, characterized in that: In step S4, the construction steps of the dynamically distributed balanced loss (DDB) loss include: Define recall and accuracy ;in, , and These represent the number of true positive, false negative, and false positive samples in the i-th category, respectively. Initialize the class weight matrix , C Number of categories; The weights are dynamically updated based on the recall and precision of the validation set after each training round: Recall weighting: ; Accuracy weighting: ; For the first i The recall rate of a class, where SF is a scaling factor. For the first i The precision of the class; The dynamic weights are normalized, and negative class sensitivity is introduced to construct the loss function, as follows: Normalize after combining the recall and precision weights: ; The dynamic distributed equilibrium loss is calculated as follows: ; in, It is the first k The first sample i Predicted scores for each category, It is the first k The first sample i Each category contains real labels, which are encoded using one-hot encoding. C is the total number of categories. It is a dynamic weight matrix. It is a hyperparameter used to adjust the negative class loss.
Citation Information
Patent Citations
Hyperspectral remote sensing image classification method
CN113705526A
General target detection method for adaptive attention guidance mechanism
WO2021139069A1