# Domain-Invariant Few-Shot Contrastive Learning for Hyperspectral Image Classification
###### Abstract
Although these FSL methods have made significant progress in improving classification accuracy, they often overlook the similarities and differences between samples of different classes in source and target domains. However, during domain distribution alignment, feature distributions of different categories may become uniform, causing feature confusion between different classes. This can lead to decreased model classification performance, especially when inter-class differences are smaller than inter-domain differences. This represents a negative transfer problem induced by domain distribution alignment [18]. For example, in HSI, different vegetation types may inherently have similar spectra, and domain adaptation might further reduce these differences, making it hard for the model to distinguish between these categories. This approach focuses more on \"macro-level\" data distribution balance while neglecting \"micro-level\" category feature preservation and discrimination. Therefore, a challenge in domain adaptation methods is maintaining intra-class feature discriminability while pursuing similar feature distributions between source and target domains. In HSI classification, HSI data typically exhibit high inter-class similarity and significant intra-class variability. Inter-class similarity refers to the spectral similarity between objects of different classes, and intra-class variability refers to differences between samples within the same category [19]. This situation can lead to insufficient discriminability in the features extracted by the model, affecting classification performance. It is important to emphasize that in FSL, particularly in prototype network-based FSL methods, learning discriminative features through the feature extraction module is key to model performance [20]. In this paper, we introduce an innovative Domain-Invariant Few-Shot Contrastive Learning (DIFSCL) method to tackle these issues. Specifically, under few-shot learning conditions, we create a new architecture that combines conditional domain discriminators and supervised contrastive learning. First, when calculating supervised contrastive learning, we use a cropping method as a data augmentation technique for the target domain and calculate the contrastive loss after passing the features obtained from the feature extraction network through a projection head. Moreover, our iterations simultaneously perform few-shot learning on both source and target domains. Under these conditions, we use conditional domain discriminators to align features from source and target domains. We use this method to promote domain invariant feature learning while preventing confusion of features from different categories. Building on this, to enable the few-shot learning method to learn more generalizable features, we designed a network specific to HSI feature extraction--the Multi-Scale Adaptive Attention Network (MSAAN). To extract spectral features of HSI data and retain key spectral information, we first apply 3D convolutional layers to the input hyperspectral data, then input the data into the Multi-Scale Adaptive Attention (MSAA) module, aiming to further extract and fuse spatial features of the image through attention mechanism and multi-scale convolutional layers. Through these two points, we maintain separation between different category data in feature space while keeping data of the same category close in feature space during domain alignment, effectively solving the problem of feature confusion between different categories produced by domain alignment methods. Our main contributions are as follows:  
1. We propose a novel domain-invariant few-shot contrastive learning architecture that optimizes model training by combining domain adaptation and supervised contrastive learning. Specifically, while employing a conditional domain discriminator for domain alignment, we introduce crop as a new data augmentation method and utilize a projection head to map features before computing contrastive loss.