Small sample hyperspectral image classification method based on comparative learning and mahalanobis distance domain adaptation
The small-sample hyperspectral image classification method through contrastive learning and Mahalanobis distance domain adaptation solves the problems of scarcity of labeled samples and domain differentiation in hyperspectral image classification, and achieves high-precision cross-domain small-sample image classification in the target domain. , demonstrating strong generalization ability and practical value.
Patent Information
- Application Number
- CN202410615371.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-17
- Publication Date
- 2024-08-30
AI Technical Summary
Hyperspectral image classification in the existing technology has problems such as scarcity of labeled samples and domain heterogeneity, which makes model generalization difficult, and deep learning algorithms are prone to overfitting when samples are scarce, limiting the potential and application effects of the model.
A small-sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation is adopted. Through the feature extraction network and domain discriminator, the model is trained in the source domain data set using meta-learning and contrastive learning methods, and through the SPRM module and residual The SE attention module improves the feature extraction effect and achieves cross-domain small sample image classification.
When the target domain samples are limited, it achieves an accuracy that exceeds fully supervised classification, demonstrates strong generalization ability and practical value, effectively handles domain-level distribution differences, and improves classification performance.
Smart Images

Figure CN118570631A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of remote sensing image application, and in particular to a small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation. Background Art
[0002] Nowadays, with the development of remote sensing technology and deep learning technology, the accuracy of hyperspectral image classification has been greatly improved, but various problems and defects have also arisen. The current existing technology mainly has the following shortcomings:
[0003] 1. Limited labeled samples: Hyperspectral labeled samples need to be constructed manually, which is not only costly but also lacks professional labeling tools, making it difficult to obtain a large number of hyperspectral labeled samples; secondly, deep learning algorithms strictly rely on labeled samples when training parameters. For example, deep learning algorithms such as 3DCNN and SSRN are prone to overfitting problems if samples are scarce, which may seriously restrict the potential and practical application effect of the designed model.
[0004] 2. Domain quality heterogeneity, model generalization is difficult: Hyperspectral images taken in different regions or seasons often have significant differences in spatial spectral structure and data distribution, which makes it difficult for the trained model to achieve good generalization effects in different fields. For example, when the model is applied to a target domain that is significantly different from the source domain, the result may be unsatisfactory. This difference between domains seriously limits the breadth and depth of the application of hyperspectral image classification analysis.
[0005] Therefore, a small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation is needed to solve the above problems. Summary of the invention
[0006] The object of the present invention is to provide a small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation to solve the problems existing in the prior art mentioned in the above background technology.
[0007] To achieve the above object, the present invention provides the following technical solutions:
[0008] A small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation includes the following steps:
[0009] S1: Prepare two datasets, Chikusei and the University of Pavia (UP), select Chikusei as the source domain dataset and the University of Pavia (UP) as the target domain dataset;
[0010] S2: Input the source domain dataset and the target domain dataset into the mapping block with dimensions of 9x9xch1 and 9x9xch2, respectively, where ch1 and ch2 are the spectral bands of the hyperspectral dataset, and together they are transformed into Ms and Mt with dimensions of 9x9x100;
[0011] S3: The dimensions of the hyperspectral cube are converted into 9x9x100 and input into their respective SPRM modules. The dimensions of the HSI cube after the SPRM module remain unchanged, still 9x9x100, and the results are Ss and St respectively;
[0012] S4: Alternately input the source domain Ss and St into the feature extraction network F to obtain the source domain features Fs and Ft respectively;
[0013] S5: Perform category-level contrastive learning on the source domain features Fs and Ft, aiming to measure the contrast relationship between each patch in the embedding space in the input small sample task, following the supervised contrastive learning method to generate the contrastive loss function Lcon of the source domain or target domain;
[0014] S6: Use the MDDA module to process the source domain and the target domain to obtain the result of random multilinear mapping, and use the result as the input of the domain discriminator to predict whether the input is target domain data or source domain data, and finally realize the classification of cross-domain small sample hyperspectral images.
[0015] Preferably, the feature extraction network F consists of four three-dimensional residual blocks and one three-dimensional convolution, and each residual block is connected to a 3-D Max Pooling Layer.
[0016] Preferably, the MDDA module is divided into two parts: MDDAs and MDDAt, MDDAs is responsible for receiving the support set and query set features from the source domain, as well as the target domain features, and generating a small sample cross entropy loss Lsfsl of the source domain;
[0017] MDDAt is responsible for receiving the support set and query set features from the target domain, as well as the source domain features, and generating the small sample cross entropy loss Ltfsl of the target domain.
[0018] Preferably, the domain discriminator consists of five fully connected layers, and except for the last layer, each fully connected layer is followed by a ReLU nonlinear activation function and a dropout layer.
[0019] Preferably, the residual block is merged with SE attention.
[0020] Compared with the prior art, the present invention has the following beneficial effects:
[0021] 1. The present invention adopts a meta-learning episode training strategy to train the model in the source domain dataset, so that it can master certain learning capabilities and classification experience knowledge, and then effectively transfers the rich knowledge extracted from the source domain to the target domain classification task to solve the problem of scarce labeled samples in the target domain. This cross-domain small sample learning method can still achieve accuracy that exceeds that of fully supervised classification when the target domain samples are very limited, such as only dozens to hundreds of samples, demonstrating its strong generalization ability and practical value.
[0022] 2. The present invention utilizes a domain discriminator to process domain-level distribution differences, and utilizes a contrastive learning method to capture class-level sample relationships. It proposes an adversarial domain adaptation method driven by a Mahalanobis distance-based classifier that is directly deployed in the source domain and the target domain to learn the sample relationships at the respective set levels. In addition, the SPRM module and the residual SE attention module are introduced to improve the feature extraction effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 This is a diagram of the cross-domain small sample classification framework of the multi-layer relationship and residual attention of the present invention.
[0024] Figure 2 This is the structural diagram of the SPRM module of the present invention.
[0025] Figure 3 This is the residual attention block structure diagram of the present invention.
[0026] Figure 4 This is a structural diagram of the domain discriminator of the present invention.
[0027] Figure 5 This is a diagram of the parameter setting interface of the present invention.
[0028] Figure 6 (a) is a pseudo-color image of the Indian Pines dataset, and (b) is a true label image of the Indian Pines dataset.
[0029] Figure 7 (a) is a pseudo-color image of the Salinas dataset, and (b) is a true label image of the Salinas dataset. DETAILED DESCRIPTION
[0030] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below in conjunction with specific implementation methods.
[0031] See also Figure 1-7 , the present invention provides the following technical solutions:
[0032] A small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation includes the following steps:
[0033] S1: Prepare two datasets, Chikusei and the University of Pavia (UP), select Chikusei as the source domain dataset and the University of Pavia (UP) as the target domain dataset;
[0034] S2: Input the source domain dataset and the target domain dataset into the mapping block with dimensions of 9x9xch1 and 9x9xch2, respectively, where ch1 and ch2 are the spectral bands of the hyperspectral dataset, and together they are transformed into Ms and Mt with dimensions of 9x9x100;
[0035] S3: The dimensions of the HSI cube are changed to 9x9x100 and input into their respective SPRM modules. The SPRM module (spectral prior refinement module) can not only force the network to emphasize the band with the most information, but also suppress useless bands to alleviate the impact of domain drift between the basic category and the new category. The dimensions of the HSI cube after the SPRM module remain unchanged, still 9x9x100, and the results are Ss and St respectively.
[0036] S4: Alternately input the source domain Ss and St into the feature extraction network F to obtain the source domain features Fs and Ft respectively;
[0037] The feature extraction network F consists of four 3D residual blocks and one 3D convolution. The final dimensions of Fs and Ft are (9, 160). Each residual block is connected to a 3-D Max Pooling Layer to reduce calculation and aggregate features. The structure of each residual block is shown in Figure 3 As shown, residual blocks are merged with SE attention to improve the learning ability of our network. This is achieved by introducing shortcuts or skip connections, which enable the training process to bypass one or more layers, resulting in a residual learning framework. This feature simplifies the training of the network and helps to solve the problem of vanishing gradients.
[0038] S5: Perform category-level contrastive learning on the source domain features Fs and Ft, aiming to measure the contrast relationship between each patch in the embedding space in the input small sample task, following the supervised contrastive learning method to generate the contrastive loss function Lcon of the source domain or target domain;
[0039] In the MDDA module (Mahalanobis distance domain adaptation), this application proposes a non-parametric classifier based on Mahalanobis distance, which can be directly deployed in the source domain and the target domain, using two separate classifiers for the source domain and the target domain, effectively replacing the single fully connected network shared by the source domain and the target domain in the original technology, thereby driving adversarial domain adaptation. Through this method, we have achieved effective knowledge transfer between different domains, further enhancing the generalization ability and classification performance of the model. The distance metric function used is the Mahalanobis distance, not the Euclidean distance. The Mahalanobis distance will have a more flexible decision boundary than the Euclidean distance.
[0040] S6: Use the MDDA module to process the source domain and the target domain to obtain the result of random multilinear mapping, and use the result as the input of the domain discriminator to predict whether the input is target domain data or source domain data, and finally realize the classification of cross-domain small sample hyperspectral images.
[0041] The MDDA module is divided into two parts, MDDAs and MDDAt. MDDAs is responsible for receiving the support set and query set features from the source domain, as well as the target domain features, and generating the small sample cross entropy loss Lsfsl of the source domain; MDDAt is responsible for receiving the support set and query set features from the target domain, as well as the source domain features, and generating the small sample cross entropy loss Ltfsl of the target domain; wherein the MDDA module is inspired by a certain conditional domain adversarial network (CDAN), and will perform random multilinear mapping on the source domain dataset and the target domain dataset to distinguish from most adversarial domain adaptation methods that only consider feature alignment but not label alignment, and learn the domain adaptive feature embedding space to improve the classification accuracy of the target domain dataset in the testing phase.
[0042] The domain discriminator consists of five fully connected layers. Except for the last layer, each fully connected layer is followed by a ReLU nonlinear activation function and a dropout layer; the final activation function is softmax, and the domain identification loss Jd is a binary cross entropy loss with Logits.
[0043] The parameter setting interface of this method is as follows Figure 5 , the specific parameter categories are as follows:
[0044] feature_dim: the final feature dimension of the model output;
[0045] src_input_dim: the input dimension of the source domain dataset, that is, the number of spectral bands of Chikusei;
[0046] tar_input_dim: the input dimension of the target domain dataset. Here, the default target domain dataset is UP, and the number of spectral bands is 103;
[0047] n_dim: The uniform dimension of the dataset output after feature mapping;
[0048] class_num: the type of ground object in the target domain dataset;
[0049] shot_num_per_class: the number of samples per class in the supported set;
[0050] query_num_per_class: the number of samples per class in the query set;
[0051] Episode: number of training sessions;
[0052] learning_rate: basic value of learning rate;
[0053] test_class_num: the number of categories in the target dataset;
[0054] test_lsample_num_per_class: the number of samples for each class in the test set;
[0055] contrastive_weight: weight of contrastive learning loss;
[0056] fsl_weight: loss weight for small sample classification;
[0057] domain_weight: loss weight for domain adaptation;
[0058] contrasive_temperature: Temperature parameter in the contrast loss function.
[0059] The cross-domain small sample hyperspectral image classification framework of the present invention can be applied to other hyperspectral image classification tasks. For example, the source domain dataset still uses the Chikusei dataset, and the target domain dataset uses the Salinas and the Indian Pines. The frameworks in the study are used for classification respectively, and the results are as follows:
[0060] Target dataset OA AA Kappa the Salinas 90.59% 94.53% 89.55% the Indian Pines 69.44% 77.88% 65.06%
[0061] Taking the Chikusei source domain dataset and the Pavia University target domain dataset as examples, if supervised deep learning methods such as 3DCNN, HybridSN, and SSRN are used directly, all labeled samples in the target domain, including 42,776 pixels of objects, are needed to achieve better results. However, if the number of pixels of objects contained in the target domain dataset Pavia University is too small, continuing to use supervised deep learning methods will result in overfitting. At this time, the cross-domain small sample hyperspectral image classification mentioned in this method can be used. By adopting the meta-learning episode training strategy, the model is trained in the source domain dataset to enable it to master certain learning capabilities and classification experience knowledge. Subsequently, the rich knowledge extracted from the source domain is effectively transferred to the target domain classification task to solve the problem of scarce labeled samples in the target domain. This cross-domain small sample learning method can still achieve accuracy beyond the fully supervised classification when the target domain samples are very limited, such as only dozens to hundreds of samples, showing its strong generalization ability and practical value.
[0062] By using domain discriminators to handle domain-level distribution differences and using contrastive learning methods to capture class-level sample relationships, a Mahalanobis distance-based classifier is directly deployed in the source domain and target domain to drive adversarial domain adaptation methods, learning the sample relationships at the respective set levels; in addition, the SPRM module and residual SE attention module are introduced to improve the feature extraction effect. Taking the source domain dataset Chikusei and the target domain dataset Pavia University as examples, the support set in the source domain has 1 for each category, 19 samples are randomly selected for each category in the query set, and 5 samples are randomly selected for each category of the support set in the target domain. The query set has the same number as the source domain, achieving 87.52% OA, 83.80% AA, and 83.46% kappa accuracy.
[0063] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation, It is characterized in that The following steps are involved: S1: Prepare two datasets, Chikusei and the University of Pavia (UP), select Chikusei as the source domain dataset and the University of Pavia (UP) as the target domain dataset; S2: Input the source domain dataset and the target domain dataset into the mapping block with dimensions of 9x9xch1 and 9x9xch2, respectively, where ch1 and ch2 are the spectral bands of the hyperspectral dataset, and together they are transformed into Ms and Mt with dimensions of 9x9x100; S3: The dimensions of the hyperspectral cube are converted into 9x9x100 and input into their respective SPRM modules. The dimensions of the HSI cube after the SPRM module remain unchanged, still 9x9x100, and the results are Ss and St respectively; S4: Alternately input the source domain Ss and St into the feature extraction network F to obtain the source domain features Fs and Ft respectively; S5: Perform category-level contrastive learning on the source domain features Fs and Ft, aiming to measure the contrast relationship between each patch in the embedding space in the input small sample task, following the supervised contrastive learning method to generate the contrastive loss function Lcon of the source domain or target domain; S6: Use the MDDA module to process the source domain and the target domain to obtain the result of random multilinear mapping, and use the result as the input of the domain discriminator to predict whether the input is target domain data or source domain data, and finally realize the classification of cross-domain small sample hyperspectral images.
2. According to claim 1, a small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation, Features: The feature extraction network F consists of four 3D residual blocks and one 3D convolution, and each residual block is connected to a 3-D Max Pooling Layer.
3. According to the small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation as described in claim 1, Features: The MDDA module is divided into two parts: MDDAs and MDDAt. MDDAs is responsible for receiving the support set and query set features from the source domain, as well as the target domain features, and generating the small sample cross entropy loss Lsfsl of the source domain; MDDAt is responsible for receiving the support set and query set features from the target domain, as well as the source domain features, and generating the small sample cross entropy loss Ltfsl of the target domain.
4. The small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation according to claim 1, Features: The domain discriminator consists of five fully connected layers. Except for the last layer, each fully connected layer is followed by a ReLU nonlinear activation function and a dropout layer.
5. The small sample hyperspectral image classification method based on contrastive learning and Mahalanobis distance domain adaptation according to claim 2, Features: The residual block is merged with SE attention.
Citation Information
Patent Citations
Hyperspectral image classification method based on twin neural network
CN115496934A
Spectral cross-domain transfer super-resolution reconstruction method for multi-domain image
WO2024082796A1
