Next Article in Journal
Satellite Monitoring of the Urban Expansion in the Pearl River–Xijiang Economic Belt and the Progress towards SDG11.3.1
Next Article in Special Issue
Hyperspectral Image Classification Using Spectral–Spatial Double-Branch Attention Mechanism
Previous Article in Journal
Constructing a Regional Ionospheric TEC Model in China with Empirical Orthogonal Function and Dense GNSS Observation
Previous Article in Special Issue
Unsupervised Nonlinear Hyperspectral Unmixing with Reduced Spectral Variability via Superpixel-Based Fisher Transformation
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Vision Transformer-Based Ensemble Learning for Hyperspectral Image Classification

1
School of Informatics, Hunan University of Chinese Medicine, Changsha 410208, China
2
College of Electrical and Information Engineering, Hunan University, Changsha 410082, China
*
Author to whom correspondence should be addressed.
Remote Sens. 2023, 15(21), 5208; https://doi.org/10.3390/rs15215208
Submission received: 7 September 2023 / Revised: 18 October 2023 / Accepted: 30 October 2023 / Published: 2 November 2023
(This article belongs to the Special Issue Advances in Hyperspectral Remote Sensing Image Processing)

Abstract

:
Hyperspectral image (HSI) classification, due to its characteristic combination of images and spectra, has important applications in various fields through pixel-level image classification. The fusion of spatial–spectral features is a topic of great interest in the context of hyperspectral image classification, which typically requires selecting a larger spatial neighborhood window, potentially leading to overlaps between training and testing samples. Vision Transformer (ViTs), with their powerful global modeling abilities, have had a significant impact in the field of computer vision through various variants. In this study, an ensemble learning framework for HSI classification is proposed by integrating multiple variants of ViTs, achieving high-precision pixel-level classification. Firstly, the spatial shuffle operation was introduced to preprocess the training samples for HSI classification. By randomly shuffling operations using smaller spatial neighborhood windows, a greater potential spatial distribution of pixels can be described. Then, the training samples were transformed from a 3D cube to a 2D image, and a learning framework was built by integrating seven ViT variants. Finally, a two-level ensemble strategy was employed to achieve pixel-level classification based on the results of multiple ViT variants. Our experimental results demonstrate that the proposed ensemble learning framework achieves stable and significantly high classification accuracy on multiple publicly available HSI datasets. The proposed method also shows notable classification performance with varying numbers of training samples. Moreover, herein, it is proven that the spatial shuffle operation plays a crucial role in improving classification accuracy. By introducing superior individual classifiers, the proposed ensemble framework is expected to achieve even better classification performance.

Graphical Abstract

1. Introduction

Remote sensing, with its advantages of wide observation ranges, short time cycles, and dynamic tracking, has become the primary means of Earth observation. Hyperspectral remote sensing technology, as an organic combination of spectral and imaging techniques, uses imaging spectrometers to measure radiation intensity within a wide spectral range for specific scenes, generating a data cube that combines one-dimensional spectral responses with two-dimensional spatial information. This enables the synchronous acquisition of geometric, radiometric, and spectral information pertaining to target objects. Compared to traditional remote sensing, hyperspectral remote sensing provides more abundant spectral–spatial information, greatly promoting the transition from qualitative analysis to quantitative analysis in remote sensing [1]. The spectral fusion characteristic of hyperspectral image (HSI) data gives it prominent advantages in the fine classification and identification of land cover, making it widely applied in fields such as geological survey [2], precision agriculture [3], forest inventory [4], environmental monitoring [5], biomedical research [6], and more.
HSI data has the advantage of high spectral resolution, allowing it to capture delicate spectral characteristics of the interested target. This has made land cover classification a popular research direction in the field of HSI analysis [7]. Considering the high-dimensional nature of HSI samples, researchers have applied various machine learning methods to HSI classification over the past few decades, including logistic regression [8], Support Vector Machines (SVM) [9], Sparse Representation [10], Random Forest (RF) [11], and Decision Trees [12]. However, due to the limited number of available training samples regarding HSI data, which often cannot satisfy the requirements of the spectral dimension, these classifiers still exhibit inadequate classification performance on the original data [13]. Additionally, the high-spectral-resolution HSI data inevitably contain a certain amount of redundant information between adjacent spectral bands [14], and the original spectral features are often not the most effective representation for distinguishing the target of interest.
To address the aforementioned problems, HSI feature extraction methods have emerged. The purpose of these methods is to explore discriminative information of different objects in order to enable more accurate category prediction in the feature space via the use of classifiers. Early feature extraction methods include singular spectrum analysis (SSA) [15], principal component analysis (PCA) [16], linear discriminant analysis (LDA) [17], and independent component analysis (ICA) [18], which primarily extract features by learning linear combinations of independent pixels. However, these methods often lack the consideration of spatial contextual information, leading to issues such as outliers and pixel-level misclassification in the resulting classification maps, seriously affecting the reliability of the results. As a result, more research studies have focused on how to extract effective spatial information and integrate it with spectral information for classification tasks [19]. Ref. [20] leverages the advantages of edge-preserving filters (EPF) in extracting image spatial structures by adjusting the parameters of the filters to obtain hyperspectral image spatial information at different scales. In [21], HSI data were treated as a complete tensor, and a three-dimensional discrete wavelet transform was designed to decompose the data into geometric and statistical spatial structures.
The deep learning techniques in HSI classification have received widespread attention in recent years. Researchers have proposed deep learning-based multiscale spatial–spectral classification methods. Compared to traditional methods, deep neural networks have the advantage of extracting high-level nonlinear features from images [22]. In a study by Liang et al., the VGG16 network was used to extract spatial information at different levels of HSI as spatial features at different scales [23]. Wang et. al designed multiscale feature extraction sub-networks for the spectral and spatial information of HSI data. They proposed an adaptive spectral and spatial feature combination method, achieving the collaborative classification of spectral information [24]. A model combining a Convolutional Neural Network (CNN) and Recurrent Neural Network (RNN) was proposed to enhance the discriminative ability of spectral features in [25]. A deep 1D CNN model, which takes pixel vectors as input data and performs classification on hyperspectral data only in the spectral dimension, achieved outstanding accuracy surpassing traditional SVM classifiers [26]. Wan et al. introduced a Graph Convolutional Network (GCN) to overcome the issue of traditional CNN models’ inability to adapt to the distribution and geometric shapes of different objects. They constructed multiple input graphs with different neighborhood scales to achieve multiscale classification [27].
The Vision Transformer (ViT) [28] is the first transformer network for the visual domain. The network treats image patches as inputs and maps them into features that are integrated into the ViT model. Following the emergence of ViTs, many studies have aimed to incorporate transformers such as IPT [29], PVT [30], and the Swin Transformer [31] into image processing. Wang et al. combined K-nearest neighbor attention to utilize the local features of image patches and suppressed redundant information by only considering a subset of attention weights with the highest similarity [32]. Mou et al. designed a spectral attention module that applies different attention weights to guide the network to focus on discriminative spectral information through a gating mechanism [33]. Refiner explored the potential of attention expansion in high-dimensional space and enhanced the local structural characteristics of attention maps using convolutional operations [34]. Zhu et al. studied the attention mechanism in spectral and spatial information and proposed the Residual Spectral–Spatial Attention (RSSAN) mechanism [35], which selectively captures useful features in the spectral and spatial dimensions to improve hyperspectral classification. He et al. introduced a bidirectional encoder representation from a transformer (BERT) model [36], and a new feature channel-based attention calculation method which improves the processing efficiency of high-resolution images compared to existing token-based attention calculation methods was also proposed [37]. Hong et al. proposed SpectralFormer [38], which captures local spectral sequence knowledge from neighboring spectral bands through pixel- or patch-wise inputs. Zhong et al. introduced a spectral-spatial transformer network, which includes a spatial attention module and a spectral correlation module [39]. Some new transformer-based architectures [40,41,42,43,44,45,46] were employed in HSI classification fields and achieved good performance.
In all supervised learning algorithms, the ultimate goal is to train a model that performs well in all aspects and remains stable. However, achieving such ideal results is often challenging. In many cases, only multiple models that excel in certain aspects can be trained (known as weakly supervised models). Ensemble learning aims to combine these weakly supervised models to create a more robust and accurate strongly supervised model. The fundamental idea behind ensemble learning is that by fusing predictions from diverse weak classifiers, errors made by one classifier can be corrected by others, ultimately improving overall performance. Typically, we test new data using a well-converged network to achieve good prediction results. However, in the case of HSI classification, when training samples are limited, a single classification network may perform poorly. Continuously improving the model structure and introducing more feature extraction modules can enhance the network’s feature extraction ability, which can theoretically continuously improve classification accuracy. However, this approach requires more data and greater algorithm requirements, meaning that it is more costly. The advantage of ensemble learning lies in its fewer requirements for each participating algorithm. By designing different ensemble strategies, it often achieves unexpectedly good classification accuracy, so it has a wide range of practical applications. Therefore, this paper adopts an ensemble learning approach using a two-level ensemble strategy to combine the outcomes of several single-classification networks based on ViT. Due to their different architectural designs, each ViT model has different feature extraction capabilities and can extract features for classification from multiple different aspects, which ensures that each basic ViT classifier has a large degree of diversity. Hence, the proposed approach yields stable and high-performing classification maps for HSI classification.
The main contributions of this paper are as follows:
  • Proposed an ensemble learning framework based on ViT that combines the classification performance of multiple ViT models using two levels of ensemble strategies. The two ensemble strategies consistently achieve higher classification accuracy compared to individual ViT methods.
  • Introduced the spatial shuffle pre-processing technique, which converts the three-dimensional cubic data into two-dimensional images for processing, making it more suitable for the ViT architecture.
  • With the two-level ensemble strategies, there is no need to divide a validation set to maximize the utilization of all precious and limited training data. Instead, the models from each training epoch can be directly used for predictions on the test data. The predictions are then ensemble, eliminating the impact of model fitting parameters and achieving more stable and higher classification accuracy.
The following sections of this manuscript are structured as follows. Seven ViT-based methods are described in Section 2, as well as the spatial shuffle preprocessing operation and the ensemble strategy used in this study. Section 3 and Section 4 present the comparative experiments and the corresponding discussions, respectively. Section 5 presents the concluding remarks of the study.

2. Proposed Method

2.1. ViT [28]

ViT is a model that utilizes the transformer architecture for image classification purposes. Its simplicity, excellent performance, and scalability have made ViT a significant milestone for the application of transformers in computer vision. While transformers have been widely used in natural language processing tasks, their application in computer vision still has certain limitations. Presently, in the domain of computer vision, attention mechanisms are either integrated with CNNs or employed to substitute specific components of CNNs while keeping the overall structure intact. However, ViT challenges this conventional reliance on CNNs by demonstrating that using pure transformers on sequences of image patches can effectively perform image classification tasks. Through the authors’ experiments, ViT has shown outstanding results while consuming fewer computational resources.
ViT divides the input image into 16 × 16 patches and converts them into fixed-length vectors. These vectors are then processed by a transformer for further computations. The subsequent encoder operations maintain the same principles as the original transformer model. However, for image classification purposes, a special token is included in the input sequence. The output corresponding to this token determines the predicted class of the image. The basic process is as follows: First, the input image is divided into patches, with each patch having a size of 16 × 16. Then, each patch is passed through an embedding layer known as the Linear Projection of Flattened Patches, which produces a series of vectors (tokens), with each patch corresponding to one vector. Additionally, a special token for classification is added before all the vectors, with the same dimension as the other vectors. Positional information is also incorporated. Next, all tokens are input into the transformer encoder, and the encoder is stacked L times. The output of the special token for classification is then fed into an MLP Head, resulting in the final classification result.

2.2. SimpleViT [47]

The main differences from ViT are as follows: the batch size is 1024 instead of 4096, it uses global average or max pooling without a class token, it incorporates fixed sin–cos positional embeddings, and it applies data augmentation techniques such as Randaugment and Mixup. This baseline model can further be optimized by adding regularization techniques like dropout or random depth, advanced optimization methods like SAM, additional data augmentation methods like Cutmix, high-resolution fine-tuning, and knowledge distillation for strong teacher supervision.

2.3. CaiT [48]

Based on previous experiences, increasing the depth of a model can allow the network to learn more complex representations. For example, models like ResNet have shown improved accuracy as the depth increases from 18 to 152 layers. However, in the case of transformers, expanding the architecture leads to difficulties in training, and instability in depth is one of the main challenges. To address this issue, CaiT proposes two improvements.
Firstly, after analyzing the interactions between different initialization methods, optimization techniques, and architectures, CaiT introduces a method called LayerScale. This method effectively enhances the training of deeper architectures. The technique known as LayerScale introduces a trainable diagonal matrix to the branches of each residual block in image transformers. This matrix is initialized near zero but not exactly zero. By incorporating this layer after each residual block, the dynamic training capabilities are enhanced, allowing for the training of deeper and higher-capacity image transformers. The LayerScale method greatly facilitates convergence and enhances the accuracy of image transformers with increased depth. Despite adding several thousand parameters to the network during training, while the overall weight count remains negligible, the LayerScale has a beneficial effect.
Another aspect of CaiT is the inclusion of class–attention layers, which effectively distinguish between the transformer layers responsible for processing patches and the class–attention layers. The primary purpose of these class–attention layers is to extract the information from processed patches into individual vectors, facilitating their use in a linear classifier. By explicitly separating these layers, CaiT prevents conflicting objectives that may arise when dealing with class embeddings. This architectural design is known as CaiT.

2.4. DeepViT [49]

Deep transformers exhibit increasingly similar attention maps as they get deeper, to the point of being nearly identical in certain layers. In essence, the feature maps in the upper layers of deep ViT models tend to exhibit similarity. This suggests that in deeper ViT models, the self-attention mechanism struggles to learn effective representations and hinders the expected performance improvement. Based on these observations, DeepViT introduces a straightforward and efficient technique known as Re-attention to enhance the variety of attention maps across various layers, all while incurring minimal computational costs and storage. By making minor adjustments to existing ViT models, this method enables the training of deeper ViT models, resulting in consistent performance enhancements. The idea behind Re-attention comes from observing that the similarity between attention maps from different heads in the same block is relatively low, even at higher layers. Therefore, a learnable transformation matrix is multiplied with the multi-head attention maps to generate new attention maps. The Re-attention layer enhances the diversity of attention across different layers. The improved ViT-32 achieves a 1.6% improvement on the ImageNet-1K dataset.

2.5. ViT with Patch Merger (ViTPM) [50]

Transformers are widely used in natural language understanding and computer vision tasks. While expanding these architectures can enhance performance, it often comes at the cost of higher computational expenses. To make large-scale models practical in real-world systems, it is necessary to reduce their computational costs. PatchMerger is a ViTs module that minimizes the number of tokens/patches fed into each transformer encoder block, preserving performance and reducing computational load. Utilizing a learnable weight matrix, it achieves this by applying a linear transformation to the input with shape N patches × D dimensions. The result is a tensor with shape M output patches × D dimensions. From this, M scores are generated and softmaxed individually. The resulting tensor, with shape M × N, is multiplied with the original input to yield an output of shape M × D. PatchMerger achieves significant acceleration across different model scales and matches the original performance in upstream and downstream tasks after fine-tuning.

2.6. Learnable Memory ViT (LMViT) [51]

Learnable memory ViT enhances visual transformer models by using learnable memory tokens. This method allows the model to adapt to new tasks with minimal parameters while selectively retaining its capabilities from previous tasks. At each layer, a set of learnable embedding vectors, known as “memory tokens”, are introduced to provide contextual information that is useful for specific datasets. Compared to traditional fine-tuning focused only on the heads, this approach enhances model accuracy by using a small number of tokens per layer, with performance being slightly below that of expensive full fine-tuning. This model proposes an attention masking method that can be extended to new downstream tasks and allows for computational reuse. In this setup, the model can execute new and old tasks as part of a single inference with a small incremental cost while achieving high parameter efficiency.

2.7. Adaptive Token Sampling ViT (ATSViT) [52]

Traditional visual transformer models have high computational costs and large parameter sizes, making them unsuitable for deployment on edge devices. While reducing the number of tokens in the network can decrease the GFLOPs, it is not possible to set the optimal tokens for different input images. During the classification process, not all image information is necessary, and depending on the image itself, some pixels in the image may be redundant or irrelevant. This model proposes the Adaptive Token Sampler (ATS) module based on self-attention matrices, which scores tokens to minimize information loss and remove redundant information from the input. This approach overcomes the limitations of introducing additional overhead in DynamicViT and achieves a reduction in computational costs and model parameters for visual transformers without the need for pre-training. The accuracy of the model is related to the number of input patches. Traditional CNNs use pooling operations, which gradually reduce the spatial resolution of the network and decrease model accuracy. Static sampling can lead to the neglect of important information or information redundancy. Therefore, this approach proposes a method for adaptively adjusting the number of tokens at different stages to achieve the goal of not ignoring important information while not wasting computational resources. The ATS module is integrated into the self-attention layer of the ViT block. It first scores the classification tokens using self-attention weights, then uses an inverse transformation to select a subset of tokens based on the scores, and finally performs soft token downsampling to remove redundant information from the output tokens with minimal information loss.

2.8. Spatial Shuffle Preprocessing

Fusing spatial and spectral features is a research hotspot in hyperspectral image classification. By processing the pixel information in the N × N neighborhood surrounding the current pixel, spatial features can be extracted and combined with spectral features to achieve high-accuracy classification. In the study of HSI classification, it is crucial to choose a specific number of labeled training sample pixels and capture the pixels within a designated neighborhood window surrounding these samples. This process involves two issues. The first issue is determining the number of training sample pixels to select. Choosing more training sample pixels can improve accuracy, but it may be challenging to obtain a large number of training sample pixels in practical applications, which reduces usability. Selecting fewer training sample pixels increases the difficulty of classification and may lead to the overfitting of deep learning models. Current research primarily focuses on how to improve classification accuracy in low-training sample scenarios. The second issue is determining the size of the neighborhood window. Using a larger neighborhood window can improve accuracy but might lead to increased dependency between training and testing samples. To mitigate this concern, a smaller neighborhood window is selected to minimize the correlation between the training and testing samples. However, this choice also reduces the number of spatial features and can potentially result in decreased accuracy.
In order to address the aforementioned issues, Wang et.al [53] proposes a strategy called “spatial shuffle”. After obtaining the neighboring pixels of each training sample, this strategy involves randomly shuffling the positions of the pixels within the neighborhood, excluding the center pixel. Each shuffle generates a new neighborhood sample, which simulates potential pixel distribution patterns in the real world. For a 5 × 5 neighborhood, theoretically, it can produce 24! = 6.2 × 1023 unique samples. This approach effectively alleviates the overfitting problem caused by a limited number of training samples in deep learning. Additionally, by increasing the training sample size, more diverse spatial features can be extracted, thereby improving classification accuracy.
Based on the principle of spatial shuffle and considering the requirements of the ViT for input data, the following preprocessing steps, which are the same as Ref. [53], are performed for HSI training samples:
  • For a given dataset, a training sample proportion is set, such as selecting 10% of samples from each class. Then, the N × N neighborhood of each training sample is obtained, resulting in a three-dimensional data cube with dimensions of N × N × B, where B represents the number of spectral bands.
  • The position of the center pixel is fixed, while the other pixels within the neighborhood are randomly shuffled. Each shuffle transforms the N × N × B data cube into a two-dimensional image with a height of N × N and a width of B.
  • The aforementioned shuffle operation is performed 100,000/M times for each training sample from every class, where M is the number of training samples selected from that class. Consequently, each class ends up with 100,000 training samples.
  • After applying the shuffle operation to all training samples, a new dataset consisting of C × 100,000 training samples is formed, where C represents the total number of classes in the dataset.
  • Based on this new training sample dataset, various ViT models can be trained.

2.9. Ensemble Strategy

The proposed HSI classification scheme based on ensembled ViT is illustrated in Figure 1.
The ensemble strategy described in this paper consists of two levels:
At the individual model level, due to the limited number of labels in each HSI dataset, the paper only divides the dataset into training and testing sets, without creating a separate validation set. Instead, a strategy based on majority voting is used for ensemble. Specifically, after each training epoch, the trained model is used to predict the labels for all the test samples, resulting in a predicted classification map. As the training progresses, multiple predicted classification maps are generated. After several training epochs, a pixel-level majority vote is conducted on all the generated predicted classification maps. This involves counting the occurrences of each class for each pixel across the different predicted maps and selecting the class with the highest count as the final classification result for that pixel. By employing this approach, the prediction for all the test samples can be completed. This voting-based ensemble strategy takes into account the prediction results from multiple training epochs to improve classification accuracy.
At the multiple model level, two ensemble voting strategies are employed. The first strategy (Ens1) involves conducting majority voting on the predicted classification maps from all epochs of each individual method. For instance, if there are N methods and each method undergoes M epochs of training, resulting in N × M predicted classification maps, the strategy involves performing a majority vote for each pixel of the test samples among the N × M predicted results and selecting the class with the highest number of votes as the label for that pixel. The second strategy (Ens2) starts with conducting a majority vote for each individual method, resulting in predicted classification maps for the N methods. Then, another round of majority voting is performed on the predicted classification maps of each method to obtain the final predicted classification map. The distinction between these two strategies lies in the treatment of weights for each method. Since each method may have different classification performance, the number of votes obtained through majority voting may vary for each method. For example, assuming 100 epochs of training for three methods, the highest votes obtained for each test pixel might be 90, 70, and 50 for the respective methods. In the first strategy, the weights for the three methods would be calculated as follows: 90/(90 + 70 + 50) = 9/21, 70/(90 + 70 + 50) = 7/21, and 50/(90 + 70 + 50) = 5/21. However, in the second strategy, the weights for the three methods would be equal: 1/3, 1/3, and 1/3. Therefore, there could be slight differences in the final classification accuracy values of these two strategies.

3. Experiments and Results

3.1. Parameter Settings

To validate the effectiveness of the algorithm proposed in this paper, four publicly available HSI datasets were utilized, including Indian Pines (IP), Salinas Valley (SV), University of Pavia (UP), and Kennedy Space Center (KSC). Four traditional machine learning algorithms, namely multinomial logistic regression (MLR) [54], SVM [9], extreme learning machines (ELM) [55], and RF [11], were employed. Additionally, two convolutional neural network models—CNN2D [56] and PPF [57]—were utilized. Moreover, seven ViT-based algorithms, namely ViT, SimpleViT, CaiT, deepViT, ViT with Patch Merger, Learnable Memory ViT, Adaptive token sampling, and the recently proposed SpectralFormer with both pixel-wise and patch-wise models, were employed. For the seven ViT algorithms, single-level ensemble strategy and two multi-level ensemble strategies were employed to obtain classification images to facilitate a comparison in terms of algorithm performance.
The experimental system platform used in the study was Ubuntu 16.04.1 LTS, with the deep learning library being Pytorch 1.0 and Python version 3.6. The GPU hardware used was NVIDIA TITAN XP with 12 GB of VRAM.
The parameter settings for each algorithm were as follows:
-
MLR, SVM, and RF were implemented using the scikit-learn machine learning library in Python (with default parameters).
-
ELM was implemented using the scikit-elm library in Python (also with default parameters).
-
CNN2D utilized a patch size of 5 × 5. Its network structure, following the original paper’s design, consisted of two convolutional layers (3 × 3), followed by a BN (Batch Normalization) layer and ReLU activation. A fully connected layer was then employed for pixel-level classification.
-
PPF, similar to CNN2D, used a patch size of 5 × 5. The network structure was based on the original paper’s design.
The seven ViT-based algorithms share the same backbone network hyperparameters. The dimension (dim) is set to 512, the number of transformer modules (depth) is 6, the number of heads in the multi-head attention is 16, the number of neurons in the hidden layers of the multi-layer perceptron (mlp_dim) is 1024. The dropout rate for both the regular dropout and the embedding dropout is set to 0.1. The patch size is 12, and the number of input image channels (channels) is 1. The input is a 25 × B image after spatial shuffling with a 5 × 5 patch size, where B is the total number of original bands in the dataset. In the original ViT paper, a patch size of 14 or 16 is recommended. Considering that the input image of 25 × B should be evenly divided into patch size × patch size small blocks, a patch size of 12 is chosen. The input image is then resampled to 25 × 96, discarding the last row, resulting in a final input image of 24 × 96. This slightly sacrifices some input information, but since the University of Pavia dataset used in the experiment has only 103 bands while other datasets have more than 103 bands, the input image is resampled to 96 bands for the sake of using the same network architecture and maximizing the utilization of dataset. This setting can be adjusted according to the specific use case. Every one of the seven ViT variant algorithms also has specific hyperparameters. For example, in CaiT, the depth of cross-attention of CLS tokens to patch (cls_depth) is set to 2, and the layer dropout is set to 0.05. In ViT with Patch Merger, the patch_merge_layer and patch_merge_num_tokens are set to 6 and 8, respectively. In ATS, max_tokens_per_depth, which denotes the maximum number of tokens any given layer should have, is set to (256, 128, 64, 32, 16, 8). If a layer exceeds this number, it will undergo adaptive token sampling. In SpectralFormer, for the patch-wise mode, the patch size is set to 7. The results for a patch size of 5 are also provided to ensure alignment with the original paper.

3.2. IP Dataset

The IP dataset was obtained using the Airborne Visible Infrared Imaging Spectrometer (AVIRIS) sensor. It has a spectral range of 400–2500 nanometers, a spatial resolution of 20 m, and a size of 145 × 145 pixels. After excluding 24 bands with missing values or water vapor absorption, there are still 200 bands remaining. The labeled ground truth for this experiment consists of 16 land cover classes. Overall, 10% of the labeled samples were selected as training samples, while the remaining samples were used as testing samples. The specific land cover classes and sample quantities are shown in Table 1.
From the classification results shown in Figure 2 (below), it can be observed that all machine learning methods—CNN2D, PPF, and SF_pixel—have a significant degree of misclassification, as indicated by the prominent noise speckles across multiple classes. Patch-based SF and ViT-based methods using the spatial shuffle strategy have achieved significant visual improvements, with a noticeable reduction in noise speckles. The ViT-based approach has even achieved close to 100% accuracy on certain classes.
Table 2 and Table 3 provides the classification performance of each method on each class and the overall classification accuracy. It can be observed that the overall classification accuracy and Kappa coefficient of the machine learning methods are significantly lower compared to other methods. The PPF method even fails to correctly distinguish classes 1, 7, and 9 due to their small training sample sizes. CNN2D, SF_pixel, SF_Patch5, and SF_Patch7 also perform poorly on classes 1, 7, and 9 due to the same reason, but the Patch-based SF method performs noticeably better than the pixel-based SF method. The ViT-based method with spatial shuffle and the two ensemble strategies achieve significantly better classification accuracy compared to other methods and show clear advantages in classes with few training samples. On this dataset, the classification accuracy of the two ensemble strategies surpasses other ViT-based methods, demonstrating the stability of the ensemble strategies.

3.3. SV Dataset

The SV dataset was also acquired using the AVIRIS sensor, with an image size of 512 × 217 pixels. It includes 204 valid bands and has a spatial resolution of 3.7 m. There are 16 labeled land cover classes. Table 4 (below) displays the specific names of the 16 land cover classes, along with the quantities of the 10% training samples and 90% testing samples.
The classification results derived from using multiple methods on this dataset are shown in Figure 3 (below). It can be observed that the four machine learning methods and SF_pixel have a significant amount of misclassification in the 15th class, “Vinyard-untrained”, and they are often confused with the 8th class, “Grapes-untrained”. The main misclassification of the Patch-based SF method and the ViT-based method with spatial shuffle is that they misclassify the 8th class as the 15th class, but to a much lesser degree compared to the four machine learning methods and SF_pixel. CNN-based methods such as CNN2D and PPF perform better on these two classes compared to the machine learning methods. However, in other classes, the performance of all methods does not differ significantly, and the machine learning methods still exhibit a certain level of misclassification.
The objective evaluation results are shown in Table 5 and Table 6. The four machine learning methods and SF_pixel have much lower accuracy on the 15th class compared to other methods. The classification accuracy of the 8th class is relatively lower compared to other classes as well, which aligns with the results of subjective visual evaluation. In terms of the OA and Kappa coefficients, the ViT-based method with spatial shuffle performs the best among all methods, followed by CNN2D and PPF. The Patch-based Spectralformer also demonstrates better performance than the pixel-based Spectralformer. Among all ViT-based methods, the accuracy of the two ensemble strategies surpasses that of individual methods, demonstrating the superiority of the ensemble strategies.

3.4. UP Dataset

The UP dataset was acquired using the Reflective Optics System Imaging Spectrometer (ROSIS) sensor and is a part of the University of Pavia campus. It has an image size of 610 × 340 pixels and consists of 103 valid bands. The spatial resolution is 1.3 m, and the spectral range spans from 430 to 860 nanometers. The ground truth of the dataset includes nine land cover classes. Overall, 10% of the labeled samples were selected as training samples. The specific land cover classes and the quantities of samples are shown in Table 7.
From the thematic classification map shown in Figure 4, it can be observed that the misclassified categories are mainly concentrated in Class 6 and Class 7. Similar to the SV dataset, the four machine learning algorithms and SF_pixel exhibit severe misclassification in these two classes. On the other hand, methods based on CNN and ViT perform relatively well, especially the ViT-based methods with spatial shuffle. They have lower misclassification rates compared to the SpectralFormer-based methods, demonstrating a relatively stable advantage.
The objective evaluation metrics shown in Table 8 and Table 9 also reflect the results of the subjective evaluation mentioned above. The four machine learning algorithms and SF_pixel exhibit very low accuracy on Class 6, while they perform relatively better on Class 7. On the other hand, other methods show better performance on these two classes. For example, CNN2D and the ViT-based method with spatial shuffle, as well as their ensemble strategies, achieve accuracy rates exceeding 99%. The accuracy of the two ensemble strategies is also higher than all individual ViT-based methods, indicating the effectiveness of spatial shuffle and ensemble strategies.

3.5. KSC Dataset

The KSC dataset was captured using the AVIRIS sensor at Kennedy Space Center in Florida on 23 March 1996. The dataset consists of 224 bands, with 176 bands remaining after removing water vapor noise. The images are 614 × 512 pixels in size, and the spatial resolution is 18 m. There are a total of 13 land cover classes. Table 10 (below) displays the specific land cover class information and sample quantities.
Figure 5 (below) presents the performance of all methods on the KSC dataset, and Figure 6 is the enlarged sub-images in the red rectangle in the ground truth image. Due to the limited number of labeled ground truth samples and the even smaller number of samples used for training, there is a significant variation in accuracy among different methods across different classes.
From the objective evaluation metrics in Table 11 and Table 12 (below), it can be observed that all methods exhibit low accuracy on Class 5. SF_pixel and SF_patch5 even completely misclassify this class. The ViT-based method with spatial shuffle performs relatively better. On Classes 3, 4, 6, and 7, the performances of the four machine learning methods and SF_pixel are comparatively poor, with SF_pixel being the worst. On the other hand, the ViT-based method with spatial shuffle and its ensemble strategies demonstrate good performances across all classes, with overall accuracies (OA) exceeding 96%. The OAs of the two ensemble strategies are higher than other methods, indicating that ensemble strategies can consistently achieve higher classification accuracies.

4. Discussion

4.1. Effects of Training Sample Numbers

The number of training samples is one of the key factors that impact classification accuracy. Generally, with more training samples, the final classification accuracy tends to be higher. In the previous experiments, 10% of the labeled ground truth samples were randomly selected as training samples. In this section, based on the UP dataset, 1%, 2%, and 5% of the samples were randomly chosen as training samples. The experiments were conducted using the same parameters and testing procedures as the 10% sample scenario. The OA, AA, and Kappa coefficients were calculated for different training sample proportions. The results are illustrated in Figure 7.
From the above results, it can be observed that for each specific method, increasing the sample proportion leads to a significant improvement in classification accuracy. However, the magnitude of improvement decreases as the sample proportion increases. In other words, the improvement in classification accuracy from 10% training samples compared to 5% training samples is smaller than the improvement from 5% training samples compared to 2% training samples. This implies that when the proportion reaches a certain threshold, it becomes difficult to achieve further significant improvements in classification accuracy, or in other words, it may reach 100% classification accuracy. At a specific sample proportion, the ranking of classification accuracy among all methods remains relatively consistent, and the stability of the two ensemble strategies is also verified.

4.2. Effects of Spatial Shuffle

In the previous experiments, the ViT-based method with spatial shuffle and its ensemble strategies demonstrated significant classification performances and visual advantages. To demonstrate the effect of spatial shuffle, this section selects several ViT-based methods and compares the thematic maps obtained with and without spatial shuffle on different datasets. Figure 8 (below) illustrates the comparison.
From Figure 8, it can be observed that without spatial shuffle, there are significant differences in the thematic maps, especially for classes with larger training samples, making the contrast more pronounced. This demonstrates the significant improvement in performance achieved through spatial shuffle. Figure 9 presents the classification performance of various ViT-based methods with and without spatial shuffle on four datasets. It can be seen that after incorporating spatial shuffle, all methods show a significant increase in overall accuracy, with more pronounced improvements on the IP and KSC datasets. Without spatial shuffle, the performance of the two ensemble strategies is not always superior to individual methods. However, after incorporating spatial shuffle, the ensemble strategies consistently demonstrate advantages.

5. Conclusions

The fusion of spatial–spectral information in classification methods by combining spatial and spectral features can result in higher accuracy. This has become a topic of interest in hyperspectral image classification. Generally, larger neighborhood sizes for extracting spatial features lead to higher classification accuracy, but this also introduces the problem of overlap between the training and testing sets. ViT, by segmenting the image into independent patches, achieves a classification principle different from CNN and even surpasses CNN in terms of accuracy. This is also a current research hotspot. Combining the classification results of multiple models often yields higher accuracy than individual models. In this paper, to address the issue of spatial feature extraction, a preprocessing step called spatial shuffle is introduced. By randomly shuffling the spatial pixels, it not only simulates potential patterns in the real world but also increases the training sample size. Then, an ensemble learning framework based on various variants of ViT is constructed. Through two-level ensemble strategies, high-accuracy ensembles of multiple methods are achieved. Experimental results demonstrate that incorporating spatial shuffle as a preprocessing step effectively improves the classification accuracy of individual models, and the ensemble strategies also achieve stable high accuracy. Moreover, through ensemble strategies, valuable testing samples can be fully utilized without the need for a validation set. The proposed approach consistently achieves high classification accuracy across different training sample proportions. Compared to traditional machine learning, CNN architectures, and transformer models, the proposed ensemble strategy exhibits significant advantages on multiple datasets. According to the fundamental theory of ensemble learning, the more basic the used classifiers are, the higher the possible classification accuracy. For this paper, only seven ViT-based basic classifiers were used, and the ensemble strategy was a simple average. Therefore, using more advanced ensemble strategies may also lead to higher classification accuracy, but it may also bring higher training and inference costs. However, these costs can be greatly reduced through offline training. Our future research will focus on further optimizing ViT models and constructing more powerful individual models to enhance the fine classification capability of the ensemble framework.

Author Contributions

Methodology, J.L. and H.L.; software, H.G. and Y.H.; investigation, J.L, H.G., Y.H. and H.L.; writing—original draft preparation, J.L.; writing—review and editing, H.G., Y.H. and H.L. All authors have read and agreed to the published version of the manuscript.

Funding

This research article was supported in part by the National Natural Science Foundation of China under grant 62071175, the 2022 Doctoral Research Initiation Fund of Hunan University of Chinese Medicine under grant 0001036, and the Hunan Provincial Department of Education Scientific Research under grant 22B0376.

Data Availability Statement

The HSI datasets used in this paper are all public datasets.

Acknowledgments

All authors would like to thank the editors and reviewers for their detailed comments and suggestions.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Ahmad, M.; Shabbir, S.; Roy, S.K.; Hong, D.; Wu, X.; Yao, J.; Khan, A.M.; Mazzara, M.; Distefano, S.; Chanussot, J. Hyperspectral Image Classification—Traditional to Deep Models: A Survey for Future Prospects. IEEE J. Sel. Top. Appl. Earth Observ. Remote Sens. 2022, 15, 968–999. [Google Scholar] [CrossRef]
  2. Ramakrishnan, D.; Bharti, R. Hyperspectral Remote Sensing and Geological Applications. Curr. Sci. 2015, 108, 879–891. [Google Scholar]
  3. Erives, H.; Fitzgerald, G.J. Automated Registration of Hyperspectral Images for Precision Agriculture. Proc. SPIE Int. Soc. Opt. Eng. 2005, 5544, 328–335. [Google Scholar] [CrossRef]
  4. Ghiyamat, A.; Shafri, H.Z.M. A Review on Hyperspectral Remote Sensing for Homogeneous and Heterogeneous Forest Biodiversity Assessment. J. Remote Sens. 2010, 31, 1837–1856. [Google Scholar] [CrossRef]
  5. Govender, M.; Chetty, K.; Bulcock, H. A Review of Hyperspectral Remote Sensing and Its Application in Vegetation and Water Resource Studies. Water SA 2009, 33, 145–151. [Google Scholar] [CrossRef]
  6. Lu, G.; Fei, B. Medical Hyperspectral Imaging: A Review. J. Biomed. Opt. 2014, 19, 10901. [Google Scholar] [CrossRef]
  7. Zare, A.; Bolton, J.; Chanussot, J. Foreword to the Special Issue on Hyperspectral Image and Signal Processing. IEEE J. Sel. Top. Appl. Earth Observ. Remote Sens. 2014, 7, 1841–1843. [Google Scholar] [CrossRef]
  8. Ghamisi, P.; Plaza, J.; Chen, Y.; Li, J.; Plaza, A.J. Advanced Spectral Classifiers for Hyperspectral Images: A Review. IEEE Geosci. Remote Sens. Mag. 2017, 5, 8–32. [Google Scholar] [CrossRef]
  9. Melgani, F.; Bruzzone, L. Classification of Hyperspectral Remote Sensing Images with Support Vector Machines. IEEE Trans. Geosci. Remote Sens. 2004, 42, 1778–1790. [Google Scholar] [CrossRef]
  10. Chen, Y.; Nasrabadi, N.M.; Tran, T.D. Hyperspectral Image Classification Using Dictionary-based Sparse Representation. IEEE Trans. Geosci. Remote Sens. 2011, 49, 3973–3985. [Google Scholar] [CrossRef]
  11. Ham, J.; Chen, Y.; Crawford, M.M.; Ghosh, J. Investigation of the Random Forest Framework for Classification of Hyperspectral Data. IEEE Trans. Geosci. Remote Sens. 2005, 43, 492–501. [Google Scholar] [CrossRef]
  12. Bittencourt, H.R.; Oliveira Moraes, D.A.; Haertel, V. A Binary Decision Tree Classifier Implementing Logistic Regression as a Feature Selection and Classification Method and its Comparison with Maximum Likelihood. In Proceedings of the IEEE International Geoscience and Remote Symposium, Barcelona, Spain, 23–28 July 2007; pp. 1755–1758. [Google Scholar]
  13. Shahshahani, B.M.; Landgrebe, D.A. The Effect of Unlabeled Samples in Reducing the Small Sample Size Problem and Mitigating the Hughes Phenomenon. IEEE Trans. Geosci. Remote Sens. 1994, 32, 1087–1095. [Google Scholar] [CrossRef]
  14. Ren, J.; Zabalza, J.; Marshall, S.; Zheng, J. Effective Feature Extraction and Data Reduction in Remote Sensing Using Hyperspectral Imaging. IEEE Signal Process. Mag. 2014, 31, 149–154. [Google Scholar] [CrossRef]
  15. Zabalza, J.; Ren, J.; Wang, Z.; Marshall, S.; Wang, J. Singular Spectrum Analysis for Effective Feature Extraction in Hyperspectral Imaging. IEEE Geosci. Remote Sens. Lett. 2014, 11, 1886–1890. [Google Scholar] [CrossRef]
  16. Jolliffe, I.T. Principal Component Analysis. J. Mark. Res. 2002, 87, 513. [Google Scholar]
  17. Li, W.; Prasad, S.; Fowler, J.E.; Bruce, L.M. Locality-Preserving Dimensionality Reduction and Classification for Hyperspectral Image Analysis. IEEE Trans. Geosci. Remote Sens. 2012, 50, 1185–1198. [Google Scholar] [CrossRef]
  18. Wang, J.; Chang, C.-I. Independent Component Analysis-based Dimensionality Reduction with Applications in Hyperspectral Image Analysis. IEEE Trans. Geosci. Remote Sens. 2006, 44, 1586–1600. [Google Scholar] [CrossRef]
  19. Fauvel, M.; Tarabalka, Y.; Benediktsson, J.A.; Chanussot, J.; Tilton, J.C. Advances in Spectral-Spatial Classification of Hyperspectral Images. Proc. IEEE 2013, 101, 652–675. [Google Scholar] [CrossRef]
  20. Kang, X.; Xiang, X.; Li, S.; Benediktsson, J.A. PCA-based Edge-Preserving Features for Hyperspectral Image Classification. IEEE Trans. Geosci. Remote Sens. 2017, 55, 7140–7151. [Google Scholar] [CrossRef]
  21. Qian, Y.; Ye, M.; Zhou, J. Hyperspectral Image Classification based on Structured Sparse Logistic Regression and Three-Dimensional Wavelet Texture Features. IEEE Trans. Geosci. Remote Sens. 2013, 51, 2276–2291. [Google Scholar] [CrossRef]
  22. Cheng, G.; Li, Z.; Han, J.; Yao, X.; Guo, L. Exploring Hierarchical Convolutional Features for Hyperspectral Image Classification. IEEE Trans. Geosci. Remote Sens. 2018, 56, 6712–6722. [Google Scholar] [CrossRef]
  23. Liang, M.; Jiao, L.; Yang, S.; Liu, F.; Hou, B.; Chen, H. Deep Multiscale Spectral-Spatial Feature Fusion for Hyperspectral Images Classification. IEEE J. Sel. Top. Appl. Earth Observ. Remote Sens. 2018, 11, 2911–2924. [Google Scholar] [CrossRef]
  24. Wang, D.; Du, B.; Zhang, L.; Xu, Y. Adaptive Spectral-Spatial Multiscale Contextual Feature Extraction for Hyperspectral Image Classification. IEEE Trans. Geosci. Remote Sens. 2021, 59, 2461–2477. [Google Scholar] [CrossRef]
  25. Wu, H.; Saurabh, P. Convolutional Recurrent Neural Networks for Hyperspectral Data Classification. Remote Sens. 2017, 9, 298–318. [Google Scholar] [CrossRef]
  26. Hu, W.; Huang, Y.; Li, W.; Zhang, F.; Li, H. Deep Convolutional Neural Networks for Hyperspectral Image Classification. J. Sens. 2015, 2015, 258619. [Google Scholar] [CrossRef]
  27. Wan, S.; Gong, C.; Zhong, P.; Du, B.; Zhang, L.; Yang, J. Multiscale Dynamic Graph Convolutional Network for Hyperspectral Image Classification. IEEE Trans. Geosci. Remote Sens. 2020, 58, 3162–3177. [Google Scholar] [CrossRef]
  28. Dosovitskiy, A.; Beyer, L.; Kolesnikov, A.; Weissenborn, D.; Zhai, X.; Unterthiner, T.; Dehghani, M.; Minderer, M.; Heigold, G.; Gelly, S.; et al. An Image is Worth 16×16 Words: Transformers for Image Recognition at Scale. In Proceedings of the International Conference on Learning Representations (ICLR), Vienna, Austria, 4 May 2021. [Google Scholar]
  29. Chen, H.; Wang, Y.; Guo, T.; Xu, C.; Deng, Y.; Liu, Z.; Ma, S.; Xu, C.; Xu, C.; Gao, W. Pre-trained image processing transformer. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), Virtual Event, 19–25 June 2021; pp. 12299–12310. [Google Scholar]
  30. Wang, W.; Xie, E.; Li, X.; Fan, D.-P.; Song, K.; Liang, D.; Lu, T.; Luo, P.; Shao, L. Pyramid vision transformer: A versatile backbone for dense prediction without convolutions. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Virtual Event, 10 March 2021; pp. 568–578. [Google Scholar]
  31. Liu, Z.; Lin, Y.; Cao, Y.; Hu, H.; Wei, Y.; Zhang, Z.; Lin, S.; Guo, B. Swin Transformer: Hierarchical Vision Transformer Using Shifted Windows. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Virtual Event, 10 March 2021; pp. 10012–10022. [Google Scholar]
  32. Wang, P.; Wang, X.; Wang, F.; Lin, M.; Chang, S.; Li, H.; Jin, R. Kvt: K-nn attention for boosting vision transformers. In Proceedings of the Computer Vision–ECCV 2022: 17th European Conference (ECCV), Tel Aviv, Israel, 23–27 October 2022; pp. 285–302. [Google Scholar]
  33. Mou, L.; Zhu, X.X. Learning to pay attention on spectral domain: A spectral attention module-based convolutional network for hyperspectral image classification. IEEE Trans. Geosci. Remote Sens. 2019, 58, 110–122. [Google Scholar] [CrossRef]
  34. Zhou, D.; Shi, Y.; Kang, B.; Yu, W.; Jiang, Z.; Li, Y.; Jin, X.; Hou, Q.; Feng, J. Refiner: Refining self-attention for vision transformers. arXiv 2021, arXiv:2106.03714. [Google Scholar]
  35. Zhu, M.; Jiao, L.; Liu, F.; Yang, S.; Wang, J. Residual spectral–spatial attention network for hyperspectral image classification. IEEE Trans. Geosci. Remote Sens. 2020, 59, 449–462. [Google Scholar] [CrossRef]
  36. He, J.; Zhao, L.; Yang, H.; Zhang, M.; Li, W. HSI-BERT: Hyperspectral image classification using the bidirectional encoder representation from transformers. IEEE Trans. Geosci. Remote Sens. 2019, 58, 165–178. [Google Scholar] [CrossRef]
  37. Ali, A.; Touvron, H.; Caron, M.; Bojanowski, P.; Douze, M.; Joulin, A.; Laptev, I.; Neverova, N.; Synnaeve, G.; Verbeek, J.; et al. Xcit: Cross-covariance image transformers. In Proceedings of the Advances in Neural Information Processing Systems (NIPS), Virtual Event, 6–14 December 2021; Volume 34, pp. 20014–20027. [Google Scholar]
  38. Hong, D.; Han, Z.; Yao, J.; Bojanowski, P.; Douze, M.; Joulin, A.; Laptev, I.; Neverova, N.; Synnaeve, G.; Verbeek, J.; et al. SpectralFormer: Rethinking hyperspectral image classification with transformers. IEEE Trans. Geosci. Remote Sens. 2021, 60, 1–15. [Google Scholar] [CrossRef]
  39. Zhong, Z.; Li, Y.; Ma, L.; Li, J.; Zheng, W.-S. Spectral–spatial transformer network for hyperspectral image classification: A factorized architecture search framework. IEEE Trans. Geosci. Remote Sens. 2021, 60, 5514715. [Google Scholar] [CrossRef]
  40. Zhang, M.; Gao, F.; Zhang, T.; Gan, Y.; Dong, J.; Yu, H. Attention Fusion of Transformer-Based and Scale-Based Method for Hyperspectral and LiDAR Joint Classification. Remote Sens. 2023, 15, 650. [Google Scholar] [CrossRef]
  41. Dang, L.; Weng, L.; Hou, Y.; Liu, Y. Double-branch feature fusion transformer for hyperspectral image classification. Sci. Rep. 2023, 13, 272. [Google Scholar] [CrossRef]
  42. Dang, L.; Weng, L.; Hou, Y.; Zuo, X.; Liu, Y. DSS-TRM: Deep spatial–spectral transformer for hyperspectral image classification. Eur. J. Remote Sens. 2022, 55, 103–114. [Google Scholar]
  43. Li, Y.; Shi, X.; Yang, L.; Pu, C.; Tan, Q.; Yang, Z.; Huang, H. MC-GAT: Multi-layer collaborative generative adversarial transformer for cholangiocarcinoma classification from hyperspectral pathological images. Biomed. Opt. Express 2022, 13, 5794–5812. [Google Scholar] [CrossRef]
  44. Zhang, T.; Wang, W.; Wang, J.; Cai, Y.; Yang, Z.; Yang, Z.; Li, J. Hyper-LGNet: Coupling Local and Global Features for Hyperspectral Image Classification. Remote Sens. 2022, 14, 5251. [Google Scholar] [CrossRef]
  45. Bin, L.; Er, O.; Hu, W.; Zhang, G.; Zhao, L.; Wu, J. Multi-granularity vision transformer via semantic token for hyperspectral image classification. Int. J. Remote Sens. 2022, 43, 6538–6560. [Google Scholar]
  46. Wang, W.; Liu, L.; Zhang, T.; Shen, J.; Wang, J.; Li, J. Hyper-ES2T: Efficient Spatial–Spectral Transformer for the classification of hyperspectral remote sensing images. Int. J. Appl. Earth Obs. Geoinf. 2022, 113, 103005. [Google Scholar] [CrossRef]
  47. Beyer, L.; Zhai, X.; Kolesnikov, A. Better plain ViT baselines for ImageNet-1k. arXiv 2022, arXiv:2205.01580. [Google Scholar]
  48. Touvron, H.; Cord, M.; Sablayrolles, A.; Synnaeve, G.; Jégou, H. Going deeper with image transformers. In Proceedings of the IEEE/CVF International Conference on Computer Vision (ICCV), Virtual Event, 10 March 2021; pp. 32–42. [Google Scholar]
  49. Zhou, D.; Kang, B.; Jin, X.; Yang, L.; Lian, X.; Jiang, Z.; Hou, Q.; Feng, J. Deepvit: Towards deeper vision transformer. arXiv 2021, arXiv:2103.11886. [Google Scholar]
  50. Renggli, C.; Pinto, A.S.; Houlsby, N.; Mustafa, B.; Puigcerver, J. Carlos Riquelme. Learning to merge tokens in vision transformers. arXiv 2022, arXiv:2202.12015. [Google Scholar]
  51. Sandler, M.; Zhmoginov, A.; Vladymyrov, M.; Jackson, A. Fine-tuning image transformers using learnable memory. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), New Orleans, LA, USA, 19 June 2022; pp. 12155–12164. [Google Scholar]
  52. Fayyaz, M.; Koohpayegani, S.A.; Jafari, F.R.; Sengupta, S.; Joze, H.R.V.; Sommerlade, E.; Pirsiavash, P.H.; Gall, G. Adaptive token sampling for efficient vision transformers. In Proceedings of the European Conference on Computer Vision (ECCV), Tel Aviv, Israel, 23–27 October 2022; pp. 396–414. [Google Scholar]
  53. Wang, Z.H.; Cao, B.S.; Liu, J. Hyperspectral Image Classification via Spatial Shuffle-Based Convolutional Neural Network. Remote Sens. 2023, 15, 3960. [Google Scholar] [CrossRef]
  54. Haut, J.; Paoletti, M.; Paz-Gallardo, A.; Plaza, J.; Plaza, A. Cloud implementation of logistic regression for hyperspectral image classification. In Proceedings of the 17th International Conference on Computational and Mathematical Methods in Science and Engineering, CMMSE, Costa Ballena, Cádiz, Spain, 4–8 July 2017; pp. 1063–2321. [Google Scholar]
  55. Li, J.; Zhao, X.; Li, Y.; Du, Q.; Xi, B.; Hu, J. Classification of hyperspectral imagery using a new fully convolutional neural network. IEEE Geosci. Remote Sens. Lett. 2018, 15, 292–296. [Google Scholar] [CrossRef]
  56. Paoletti, M.E.; Haut, J.M.; Plaza, J.; Plaza, A. Deep learning classifiers for hyperspectral imaging: A review. ISPRS J. Photogramm. Remote Sens. 2019, 158, 279–317. [Google Scholar] [CrossRef]
  57. Li, W.; Wu, G.; Zhang, F.; Du, Q. Hyperspectral Image Classification Using Deep Pixel-Pair Features. IEEE Trans. Geosci. Remote Sens. 2017, 55, 844–853. [Google Scholar] [CrossRef]
Figure 1. Overall flowchart of the proposed method.
Figure 1. Overall flowchart of the proposed method.
Remotesensing 15 05208 g001
Figure 2. Classification results on IP dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Figure 2. Classification results on IP dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Remotesensing 15 05208 g002aRemotesensing 15 05208 g002b
Figure 3. Classification results on SV dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Figure 3. Classification results on SV dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Remotesensing 15 05208 g003aRemotesensing 15 05208 g003bRemotesensing 15 05208 g003c
Figure 4. Classification results on UP dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Figure 4. Classification results on UP dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Remotesensing 15 05208 g004aRemotesensing 15 05208 g004bRemotesensing 15 05208 g004c
Figure 5. Classification results on KSC dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Figure 5. Classification results on KSC dataset. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Remotesensing 15 05208 g005aRemotesensing 15 05208 g005b
Figure 6. Classification results on KSC dataset in the enlarged area. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Figure 6. Classification results on KSC dataset in the enlarged area. (a) original HSI; (b) ground truth; (c) MLR; (d) SVM; (e) RF; (f) ELM; (g) CNN2D; (h) PPF; (i) SF_pixel; (j) SF_patch5; (k) SF_patch7; (l) ViT; (m) SimpleViT; (n) CaiT; (o) DeepViT; (p) ViTPM; (q) LMViT; (r) ATSViT; (s) Ens1; (t) Ens2.
Remotesensing 15 05208 g006
Figure 7. Effects of sample numbers on UP dataset. (a) OA; (b) AA; (c) Kappa.
Figure 7. Effects of sample numbers on UP dataset. (a) OA; (b) AA; (c) Kappa.
Remotesensing 15 05208 g007aRemotesensing 15 05208 g007b
Figure 8. Classification results with and without spatial shuffle on IP, SVm and UP datasets. (a) ViT without spatial shuffle; (b) ViT with spatial shuffle; (c) SimpleViT without spatial shuffle; (d) SimpleViT with spatial shuffle; (e) CaiT without spatial shuffle; (f) CaiT with spatial shuffle; (g) LMViT without spatial shuffle; (h) LMViT with spatial shuffle; (i) ATSViT without spatial shuffle; (j) ATSViT with spatial shuffle; (k) Ens1 without spatial shuffle; (l) Ens1 with spatial shuffle.
Figure 8. Classification results with and without spatial shuffle on IP, SVm and UP datasets. (a) ViT without spatial shuffle; (b) ViT with spatial shuffle; (c) SimpleViT without spatial shuffle; (d) SimpleViT with spatial shuffle; (e) CaiT without spatial shuffle; (f) CaiT with spatial shuffle; (g) LMViT without spatial shuffle; (h) LMViT with spatial shuffle; (i) ATSViT without spatial shuffle; (j) ATSViT with spatial shuffle; (k) Ens1 without spatial shuffle; (l) Ens1 with spatial shuffle.
Remotesensing 15 05208 g008aRemotesensing 15 05208 g008b
Figure 9. Effects of spatial shuffle preprocessing on different datasets. (a) IP; (b) SV; (c) UP; (d) KSC.
Figure 9. Effects of spatial shuffle preprocessing on different datasets. (a) IP; (b) SV; (c) UP; (d) KSC.
Remotesensing 15 05208 g009aRemotesensing 15 05208 g009b
Table 1. Land cover classes and sample quantities of IP dataset.
Table 1. Land cover classes and sample quantities of IP dataset.
NoClass NameTraining NumTesting Num
1Alfalfa541
2Corn-notill1431285
3Corn-min83747
4Corn24213
5Grass/Pasture48435
6Grass/Trees73657
7Grass/pasture-mowed325
8Hay-windrowed48430
9Oats218
10Soybeans-notill97875
11Soybeans-min2462209
12Soybean-clean59534
13Wheat21184
14Woods1271138
15Bldg-Grass-Tree-Drives39347
16Stone-steel towers984
Total10279222
Table 2. Objective evaluation of methods on IP dataset.
Table 2. Objective evaluation of methods on IP dataset.
MLRSVMRFELMCNN2DPPFSF_PixelSF_Patch5SF_Patch7
114.290.000.002.389.520.004.7616.6742.86
274.1860.1966.7275.8978.3085.0770.6885.3886.70
345.8232.5653.8951.3084.5871.6156.0585.5991.07
440.1924.3026.6426.1756.0764.4962.6271.5069.16
588.3390.9585.9585.2490.9592.3884.2988.1089.76
693.7694.9893.1594.9899.5498.4894.9898.6398.63
723.0815.380.007.697.690.0053.8523.0826.92
898.3899.3099.3097.45100.0099.5499.30100.00100.00
922.220.0011.115.5644.440.0022.2244.4450.00
1061.6160.9258.2861.9585.0672.7672.0782.8784.71
1180.9088.6591.2476.7592.4494.8389.3996.4596.40
1245.8826.9742.7062.5579.9675.4750.1974.3482.77
1394.0590.8190.8197.8498.9298.3897.3084.8688.11
1495.4395.8793.5097.0198.3398.8695.7997.1997.54
1556.6748.3343.3357.6774.6772.6732.6768.0080.67
1678.5780.9580.9559.5275.0054.7684.5285.7177.38
OA75.1872.3375.3975.4387.7486.6578.6488.9390.81
AA63.3456.8958.6060.0073.4767.4666.9275.1878.92
Kappa71.3067.7071.4271.6685.9284.6075.3587.2889.47
Table 3. Objective evaluation of methods on IP dataset.
Table 3. Objective evaluation of methods on IP dataset.
ViTSimpleViTCaiTDeepViTViTPMLMViTATSViTEns1Ens2
190.4897.62100.0085.7180.9580.9590.4890.4888.10
292.6990.6793.2391.1493.0092.4692.2293.6293.62
396.1193.0895.6893.2395.6895.1096.5496.9796.40
492.5286.9287.8590.6588.3290.6590.1991.5991.59
594.5294.5295.4894.5295.0094.5294.2994.7694.29
699.2499.0999.5499.3999.3998.9399.3999.3999.39
7100.00100.0069.2357.6996.15100.0088.46100.00100.00
898.3899.5498.3897.2298.3898.8499.0798.8498.84
9100.0077.78100.00100.00100.0094.44100.00100.00100.00
1091.8491.3891.4990.2391.3892.9992.0792.1892.41
1196.3195.9995.7694.6095.7195.7696.3196.4096.22
1291.3991.7695.6986.3391.7691.2092.3292.3292.70
1395.6898.9295.1495.1492.4398.3897.8496.7696.22
1496.7596.8498.0796.9396.8497.2896.8497.1997.28
1594.6793.6795.3395.3395.0097.6795.6796.3396.00
1697.6298.8197.6298.8189.2998.8196.4398.8197.62
OA95.1994.5395.4193.7094.7995.1895.2695.6795.57
AA95.5194.1694.2891.6893.7094.8794.8895.9895.67
Kappa94.5193.7694.7692.8294.0694.5094.5995.0594.94
Table 4. Land cover classes and sample quantities of SV dataset.
Table 4. Land cover classes and sample quantities of SV dataset.
NoClass NameTraining NumTesting Num
1Brocoli-gree-weeds-12011808
2Brocoli-gree-weeds-23733353
3Fallow1981778
4Fallow-rough-plow1391255
5Fallow-smooth2682410
6Stubble3963563
7Celery3583221
8Grapes-untrained112710,144
9Soil-vinyard-develop6205583
10Corn-senesced-green-weeds3282950
11Lettuce-romaine-4wk107961
12Lettuce-romaine-5wk1931734
13Lettuce-romaine-6wk92824
14Lettuce-romaine-7wk107963
15Vinyard-untrained7276541
16Vinyard-vertical-trellis1811626
Total541548,714
Table 5. Objective evaluation of methods on SV dataset.
Table 5. Objective evaluation of methods on SV dataset.
MLRSVMRFELMCNN2DPPFSF_PixelSF_Patch5SF_Patch7
196.9699.4399.6099.7199.83100.0099.4399.2099.71
299.0599.9499.9499.7399.97100.0095.23100.0099.91
373.4799.2198.6591.7498.8299.8997.1399.9499.94
498.6599.6099.3698.8899.7699.9299.6099.8499.68
598.4299.0098.2299.1799.2998.8498.4799.5099.92
699.7599.9499.7799.8699.97100.0099.97100.00100.00
799.3899.8499.3199.7599.44100.0099.4799.7899.41
890.2190.8485.2089.9095.5794.8884.4790.2593.22
998.9299.9199.2899.9899.98100.0099.73100.00100.00
1083.4195.2792.8895.4099.4897.6890.8197.5899.14
1144.2196.2896.1794.6998.4199.2693.3099.68100.00
1299.88100.0099.5399.94100.00100.0099.71100.00100.00
1398.8998.1597.5398.5299.8898.1597.65100.0099.88
1490.8998.2093.9693.4399.3699.1593.7598.8399.47
1543.7166.2464.6163.6090.9491.2556.5384.6683.84
1689.6398.5797.8998.5098.9199.2597.2098.5098.98
OA86.4493.0291.1692.0697.6397.4889.4595.6496.28
AA87.8496.2895.1295.1898.7398.6493.9097.9998.32
Kappa84.8192.2090.1591.1497.3697.2088.2395.1495.85
Table 6. Objective evaluation of methods on SV dataset.
Table 6. Objective evaluation of methods on SV dataset.
ViTSimpleViTCaiTDeepViTViTPMLMViTATSViTEns1Ens2
1100.00100.00100.00100.0099.83100.00100.00100.00100.00
2100.00100.00100.00100.00100.00100.00100.00100.00100.00
399.6699.4999.4998.8299.7299.6199.7899.6699.66
499.6899.3699.9299.2899.6899.6099.8499.7699.76
599.6799.5499.6399.6399.5999.5499.6399.6799.67
6100.00100.00100.00100.00100.00100.00100.00100.00100.00
799.94100.00100.0099.8499.9499.9799.9799.9799.97
894.9294.6794.6693.0094.2594.4295.2095.2695.21
9100.0099.98100.0099.98100.00100.00100.00100.00100.00
1098.8999.0799.5598.1098.8998.5898.8999.2199.10
1199.3699.8999.8997.8798.7298.1999.6899.2699.57
12100.00100.00100.00100.00100.00100.00100.00100.00100.00
1398.2799.2698.0298.7799.0198.0298.1598.6498.52
1499.7999.6899.8999.89100.0099.7999.7999.7999.89
1596.2196.5197.4395.5596.2695.9396.8397.2497.21
1699.8699.7399.8698.9899.8699.9399.8099.9399.93
OA98.2898.2898.4397.6498.1498.0898.4398.5298.50
AA99.1499.2099.2798.7399.1198.9799.2299.2799.28
Kappa98.0898.0898.2697.3897.9397.8798.2598.3598.33
Table 7. Land cover classes and sample quantities of UP dataset.
Table 7. Land cover classes and sample quantities of UP dataset.
NoClass NameTraining NumTesting Num
1Asphalt6635968
2Meadows186516,784
3Gravel2101889
4Trees3062758
5Painted metal sheets1351210
6Bare Soil5034526
7Bitumen1331197
8Self-Blocking Bricks3683314
9Shadows95852
Total427838,498
Table 8. Objective evaluation of methods on UP dataset.
Table 8. Objective evaluation of methods on UP dataset.
MLRSVMRFELMCNN2DPPFSF_PixelSF_Patch5SF_Patch7
192.5694.1891.5097.3499.4997.1388.2997.1797.71
296.3897.5797.8199.3799.8398.2199.0499.7999.86
340.9579.0164.0052.9193.6477.7162.9193.4294.83
477.1794.6690.4987.5698.5094.8886.0696.3098.57
598.2799.0197.9498.0299.9299.6798.7699.92100.00
652.0290.8373.5660.0299.9893.8444.2994.8894.76
70.5888.3970.591.9298.6688.4783.7185.2188.30
890.5689.0889.2981.6595.6289.9287.3694.5496.89
999.77100.00100.0099.41100.0099.88100.0099.5399.53
OA82.9094.1790.1586.4798.9995.3186.5597.3097.94
AA72.0392.5286.1375.3698.4093.3083.3895.6496.72
Kappa76.8392.3286.8981.6598.6893.8381.7996.4397.28
Table 9. Objective evaluation of methods on UP dataset.
Table 9. Objective evaluation of methods on UP dataset.
ViTSimpleViTCaiTDeepViTViTPMLMViTATSViTEns1Ens2
198.8799.1899.1897.6698.8299.1098.9499.2599.13
299.8399.8699.9199.8699.8499.7899.8499.8799.86
396.4193.5895.9895.4996.1496.1495.2196.6896.52
497.5197.5198.0297.2697.5997.9597.2697.8097.73
5100.00100.00100.00100.00100.00100.00100.00100.00100.00
699.5499.4999.6299.4999.6599.8299.7199.8799.80
799.3398.7599.7599.5099.5099.0099.3399.5899.50
897.8997.1697.8396.2997.8997.8098.4998.5298.58
999.8899.7799.8899.7799.8899.8899.8899.8899.88
OA99.1398.9699.2498.7499.1499.1899.1499.3499.30
AA98.8198.3798.9198.3798.8198.8398.7499.0599.00
Kappa98.8598.6399.0198.3598.8698.9298.8799.1499.08
Table 10. Land cover classes and sample quantities of KSC dataset.
Table 10. Land cover classes and sample quantities of KSC dataset.
NoClass NameTraining NumTesting Num
1Scrub33728
2Willow swamp23220
3CP hammock24232
4Slash pine24228
5Oak/Broadleaf15146
6Hardwood22207
7Swamp996
8Graminoid marsh38393
9Spartina marsh51469
10Cattail marsh39365
11Salt marsh41378
12Mud flats49454
13Water91836
Total4595752
Table 11. Objective evaluation of methods on KSC dataset.
Table 11. Objective evaluation of methods on KSC dataset.
MLRSVMRFELMCNN2DPPFSF_PixelSF_Patch5SF_Patch7
196.3396.6295.1597.5099.2798.5393.9898.68100.00
290.8786.7688.5899.0995.8992.2437.4481.2879.00
371.8661.0483.5585.2894.8184.420.0084.8587.01
452.8644.9358.5940.0963.0037.890.0019.3832.60
535.1740.0055.1744.8366.2135.170.000.003.45
617.3929.4744.9325.1274.403.380.0071.0190.82
723.1675.7989.4720.0096.840.000.0092.63100.00
858.5971.3579.9588.0291.9378.918.0776.0488.02
988.2595.5196.7987.39100.0089.3276.7180.7781.41
1081.5984.6282.9795.3377.2093.9648.9091.2197.25
1197.0995.7795.5093.1299.7498.1593.39100.0097.62
1273.9581.4684.9988.5273.7388.7480.5790.0793.60
1399.52100.0099.8899.1694.8599.88100.00100.00100.00
OA79.3382.7286.7984.9289.5082.8260.6684.2387.86
AA68.2074.1081.1974.1186.7669.2741.4775.8480.83
Kappa76.8480.6685.2883.1288.3280.6555.1782.4286.48
Table 12. Objective evaluation of methods on KSC dataset.
Table 12. Objective evaluation of methods on KSC dataset.
ViTSimpleViTCaiTDeepViTViTPMLMViTATSViTEns1Ens2
199.4198.68100.0099.7199.12100.0099.7199.85100.00
298.6399.5499.54100.0098.6398.6396.8099.0999.09
394.3792.6491.7793.0793.5194.3793.9495.2494.81
491.6381.5094.7188.1188.9988.9990.7593.8392.95
573.1068.2870.3475.1775.1772.4171.0372.4172.41
699.0389.86100.0099.5297.5899.0399.03100.00100.00
798.9598.95100.0098.9598.95100.0098.9598.9598.95
897.6696.8898.9699.4897.6698.4496.6198.4497.92
997.4497.0197.4498.9396.5898.0897.8698.0897.86
10100.00100.00100.00100.00100.00100.00100.00100.00100.00
11100.00100.00100.0099.21100.00100.00100.00100.00100.00
12100.0099.12100.00100.0098.45100.00100.00100.00100.00
13100.00100.00100.00100.00100.00100.00100.00100.00100.00
OA97.8296.4498.0698.0297.3897.9197.6198.2198.10
AA96.1794.0396.3796.3295.7496.1595.7596.6196.46
Kappa97.5896.0397.8497.7997.0897.6797.3498.0097.89
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Liu, J.; Guo, H.; He, Y.; Li, H. Vision Transformer-Based Ensemble Learning for Hyperspectral Image Classification. Remote Sens. 2023, 15, 5208. https://doi.org/10.3390/rs15215208

AMA Style

Liu J, Guo H, He Y, Li H. Vision Transformer-Based Ensemble Learning for Hyperspectral Image Classification. Remote Sensing. 2023; 15(21):5208. https://doi.org/10.3390/rs15215208

Chicago/Turabian Style

Liu, Jun, Haoran Guo, Yile He, and Huali Li. 2023. "Vision Transformer-Based Ensemble Learning for Hyperspectral Image Classification" Remote Sensing 15, no. 21: 5208. https://doi.org/10.3390/rs15215208

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop