Manuscript Offprint
arXiv:2611.02364Spectral-spatial vision test-time training for hyperspectral image classification
Xiang Zhao
College of Mathematical Sciences, Harbin Engineering University, 145 Nantong Street, Nangang District, Harbin 150001, China
Abstract. Hyperspectral image (HSI) classification requires the representation of contiguous spectral signatures and spatial context under limited labeled supervision. Vision test-time training (TTT) offers an alternative to fixed-weight token mixing by performing self-supervised inner-model updates on the input sequence, but its application to center-pixel HSI classification remains insufficiently characterized. We present ViTTT-HSI, a spectral–spatial adaptation of the vision test-time training (ViT ) architecture. A spectral-aware embedding stem extracts ordered-band information using spectral convolution and forms spatial tokens without reducing their spatial resolution. Two ViT -based TTT encoder blocks perform patch-conditioned token mixing, followed by the fusion of center-pixel and neighborhood-average features for classification. We evaluate the framework on Indian Pines, Pavia University, Salinas, and Houston 2013 using ten random seeds and dataset-specific training fractions of 1% or 5%. The mean overall accuracies are 97.6390%, 98.8753%, 99.3292%, and 98.4283%, respectively. Ablations reveal a substantial contribution from the TTT inner update on Indian Pines and a smaller positive contribution on Pavia University, while the relative benefits of the spectral stem and feature fusion depend on the dataset. The results demonstrate the feasibility of using patch-conditioned vision TTT for spectral–spatial HSI classification and highlight the role of the inner adaptation mechanism.
Keywords: hyperspectral image classification, test-time training, spectral–spatial representation, center-pixel classification, remote sensing.
*Corresponding author: Xiang Zhao,
1 Introduction
Hyperspectral images (HSIs) record a dense sequence of spectral measurements for each spatial location, providing discriminative signatures for identifying vegetation, built surfaces, and other land-cover materials. Their classification is a fundamental step in remote sensing applications such as agricultural monitoring, environmental assessment, and urban mapping. Compared with conventional three-channel images, HSI cubes contain substantially more spectral channels and often exhibit pronounced correlations between neighboring bands. At the same time, reliable pixel annotations can be costly to obtain, making accurate classification under limited supervision a persistent research challenge.
A classifier based solely on the spectrum of a target pixel may be sensitive to local spectral variation and similarities between distinct materials. Incorporating neighboring pixels provides complementary spatial evidence, but also requires the model to accommodate boundaries and heterogeneous patches. Deep convolutional networks have addressed this issue by learning local spectral and spatial features through 3-D and 2-D operators. More recently, Transformers have offered flexible sequence-level interactions for spectral and spatial feature learning, as illustrated by SpectralFormer and the spectral–spatial feature tokenization Transformer (SSFTT). Selective state-space models have also been used for hyperspectral representation learning, with S Mamba combining spatial and spectral sequence processing.
These advances offer increasingly expressive spectral–spatial encoders. A complementary question is whether the token-mixing operation itself can adapt to the particular neighborhood being classified. Test-time training (TTT) addresses sequence modeling through temporary, input-dependent inner-model updates: features from the current sequence form key-value training pairs, the inner model is updated by an unlabeled objective, and the adapted model then processes query features.⁸ In vision, Han et al. developed ViT³ and studied how inner-training objectives, optimization settings, gated units, and depthwise convolutional inner models affect visual token mixing.⁹ This approach provides a patch-conditioned representation without requiring class labels at inference.
Applying a visual TTT architecture to HSI center-pixel recognition requires changes at the input and prediction interfaces. First, the spectral axis carries a meaningful band ordering that is absent from standard red, green, and blue (RGB) patch embeddings. Second, the target is the label of the center pixel rather than a single label for the entire image. Third, spatial positions should remain explicitly associated with their original neighborhoods so that center information can be recovered after token interaction. These requirements motivate a spectral-aware embedding and a center-oriented prediction head around a ViT³-based spatial encoder.
In this work, we construct ViTTT-HSI, a spectral–spatial adaptation of vision TTT for HSI center-pixel classification. A spectral convolutional stem first extracts ordered-band responses and creates one token per spatial position. Two encoder blocks then apply patch-conditioned TTT mixing while retaining the complete spatial token grid. Finally, the normalized center token is combined with an average representation of the neighborhood for the class prediction. The TTT inner models and their update rules follow ViT³,⁹ the hyperspectral embedding, token organization, and center–global prediction pathway form the task-specific adaptation studied here.
The main contributions are summarized as follows. (1) We establish a vision TTT-based spectral–spatial framework for HSI center-pixel classification, maintaining spatial correspondence throughout the token-processing stages. (2) We introduce a spectral-aware embedding pathway that exploits local spectral continuity while generating spatially aligned features suitable for ViT³ mixing. (3) We evaluate the framework across four public HSI datasets and ten random seeds, and examine the roles of the TTT inner update, input embedding, center–global feature aggregation, spatial context size, and spatially separated sampling. The controlled inner-update comparisons provide a direct assessment of the patch-conditioned learning mechanism.
2.1 Spectral–spatial feature learning in hyperspectral classification
HSI classification methods must combine rich spectral descriptions with spatial relationships. Earlier deep spectral–spatial architectures typically encode a neighborhood centered at the target pixel and assign the resulting feature vector to the center label. The spectral–spatial residual network (SSRN) uses consecutive spectral and spatial residual blocks in a 3-D convolutional architecture.³ HybridSN subsequently couples 3-D convolutional feature extraction with 2-D convolution to learn joint representations at different stages.⁴ These methods demonstrate the utility of treating local spectral structure and image-space context as complementary sources of information.
A local convolutional receptive field, however, is not the only means of representing dependencies across an HSI patch. Motivated by attention-based sequence modeling,¹⁰ SpectralFormer represents spectral signatures as grouped embeddings and incorporates spectral information flow across its Transformer layers.⁵ SSFTT employs spectral–spatial feature tokenization before Transformer encoding, thereby constructing compact tokens from convolutional spatial–spectral features.⁶ More recently, the dual selective fusion Transformer network (DSFormer) has used selective fusion of spatial–spectral features and contextual tokens to capture information across different receptive fields.¹¹ HyperTransXNet has explored local–global dynamics through hybrid spectral–spatial processing and dynamic token interactions.¹² The corresponding design space encompasses both the representation of spectral bands and the organization of spatial neighborhoods.
2.2 State-space and alternative token mixers
Attention-based methods have encouraged parallel work on sequence-processing operators with different computational trade-offs. The selective state-space model Mamba provides an input-dependent state transition mechanism for sequential representations.¹³ In the HSI domain, S²Mamba constructs complementary spatial and spectral processing pathways and combines their outputs through a spatial–spectral mixture gate.⁷ Spatial-frequency joint learning Mamba (SFMamba) further explores spatial and frequency-domain information in hyperspectral classification.¹⁴ These approaches, together with Transformer and hybrid convolutional neural network (CNN) architectures, constitute relevant baselines for evaluating another form of token interaction.
A central distinction of TTT-based mixing is that the current input sequence is used to construct temporary inner-model parameters rather than only to produce activations through a fixed mixing operator. Thus, TTT permits the model state used for query processing to depend on the content of the observed patch. In this work, the practical benefit of this mechanism is examined through comparisons with both a removed-mixer variant and a frozen-inner-model variant.
2.3 Test-time training versus test-time adaptation
In conventional test-time adaptation (TTA), a trained classifier can update selected model parameters using unlabeled target-domain observations, often to address corruption or distribution shift. HyperTTA, for example, studies hyperspectral classification under several forms of image degradation and adapts normalization parameters using confidence-aware entropy minimization.¹⁵ Its purpose is to improve performance when test inputs depart from the source-domain distribution.
Test-time training in the sense of Sun et al.⁸ and ViT³⁹ serves a different architectural role. An unlabeled inner objective is evaluated on key–value representations of the present sequence; the resulting fast weights process queries, while shared outer parameters remain unchanged during inference. In ViTTT-HSI, fast weights are reinitialized from their learned initial values for every patch. There is no persistent adaptation across patches, and no target class annotation participates in the inner update. The present study therefore focuses on TTT as an input-conditioned spatial token mixer for center-pixel classification rather than as a mechanism for adapting to external domain shifts.
3 Methodology
3.1 Problem formulation and framework overview
Let represent an HSI cube, where is the number of spectral bands. For a labeled center coordinate , an odd-sized neighborhood is extracted. The goal is to predict the center label without using ground-truth labels from other pixels in the patch during inner adaptation. Figure 1 summarizes the architecture. For a batch of patches, the embedding stage produces , where and . The spatial tokens pass through encoder blocks, are normalized, and then feed a center–global classifier.

B: batch size C: spectral bands K: classes LN: LayerNorm CPE: convolutional positional encoding
Fig 1 Overall architecture of ViTTT-HSI. (a) A centered hyperspectral patch is encoded without spatial downsampling, processed by two TTT encoder blocks, and classified using a center–global feature head. (b) Each encoder block uses residual convolutional positional encoding (CPE), a pre-normalized TTT mixer inherited from ViT and a pre-normalized feed-forward network. (c) The center token and spatial average are concatenated for center-pixel prediction. , and denote spectral bands, token dimension, token count, and classes.
3.2 Spectral-aware feature embedding
Because the spectral axis has an intrinsic ordering, the embedding stem applies a convolution along spectral bands, without convolving over spatial coordinates in its first stage. A batch is reshaped to . An eight-channel 3-D convolution with kernel , stride , and spectral padding 3 is followed by a Gaussian error linear unit (GELU) and adaptive average pooling to 16 spectral bins. This operation yields .
Folding the channel and pooled spectral axes produces 128 channels at each spatial position. A pointwise convolution maps these features to channels, followed by batch normal-ization and GELU. A spatial depthwise convolution and another GELU further refine local spatial context. The resulting is flattened only along its spatial axes:
The superscript in Eq. (1) indicates the channel-to-feature-axis permutation, not a transposition of the full batch tensor. No spatial token is discarded and no class token is introduced. The linear-stem ablation replaces spectral convolution and pooling with a direct channel projection while retaining the remaining spatial embedding pathway.
3.3 TTT-based spatial encoder
Each encoder block first introduces a residual convolutional positional encoding, . The subsequent pre-normalized token mixer and feed-forward sublayer are residual:
Here, DWConv denotes depthwise convolution, LN denotes layer normalization, and FFN denotes a feed-forward network. The feed-forward network uses two linear transformations with dimensions , GELU, and dropout with probability 0.1.
The TTT mixer is the original ViT dual-branch construction. A joint projection produces distinct query (Q), key (K), and value (V) views for a simplified SwiGLU branch and a depthwise convolution branch. Four gated heads each have dimension , while the convolution branch has 16 channels. Their projected output dimensions are 64 and 16, respectively, and a final linear projection maps the 80 concatenated features to 64 dimensions.
For each gated head, denote the learnable inner initialization by . The inner network is
Here, SiLU denotes the sigmoid linear unit. For spatial tokens, a compact expression for the negative dot-product inner objective is
The convolution inner model uses the corresponding spatial dot-product objective with a depthwise kernel. In the implementation, gradients are computed analytically without explicitly materializing the scalar objective, and each parameter gradient is rescaled by its norm along the implementation-defined axes:
Equation (6) represents the one-step update for the current patch p. The gated and convolutional gradients are computed separately and normalized over their respective tensor axes. This operation

-----→ Fast-weight update
Fresh learned initialization for every patch and forward pass.
Batch axis omitted. Inner updates use K and V without class labels.
Fig 2 Implementation details of the spectral-aware stem and ViT³-based TTT mixer. (a) Spectral convolution, pooling, channel folding, and spatial depthwise convolution produce 64-dimensional spatial tokens. (b) Four 16-dimensional simplified swish-gated linear unit (SwiGLU) heads and a separate 16-channel depthwise convolution branch each perform a one-step, unlabeled key–value inner update and then evaluate query features using the patch-specific fast weights. Both branch designs and their analytical update mechanism follow ViT³.⁹ Fast weights do not persist between patches.
is repeated independently for each inner branch and each input patch. The resulting temporary weights produce query outputs, ; the outer-network initializations remain shared across patches and are not overwritten at inference. Crucially, this inner update uses no center-pixel labels or test-set annotations.
3.4 Center-global head and outer optimization
After two encoder blocks, a final layer normalization produces . Let be the center-token index under zero-based indexing. We define
The global average includes the center token. The classifier receives 128 features and produces K class logits. Outer-network parameters, including the initial inner weights, are optimized end-to-end using standard supervised cross-entropy on training center-pixel labels.
4 Experimental setup
4.1 Datasets and sampling protocol
Four widely used HSI benchmarks are considered: Indian Pines (16 classes), Pavia University (9 classes), Salinas (16 classes), and Houston 2013 (15 classes). For each class, a seed-controlled random partition of labeled center pixels is used. Indian Pines and Houston 2013 each allocate 5% of labeled pixels to training and another 5% to validation; the rest is reserved for testing. Pavia University and Salinas each allocate 1% to training and 1% to validation. Dataset-specific rounding and a minimum of one sample per class are implemented where applicable. The ten seeds are 3405–3414. These experiments use random pixel splits rather than the official Houston 2013 fixed training/test division. Training-pixel spectra alone determine the per-band normalization statistics.
The input patch sizes are 29 for Indian Pines, Pavia University, and Houston 2013, and 27 for Salinas. All sampling protocols are applied to labeled center pixels, with disjoint training, validation, and test center-pixel sets. A separate spatial-block experiment further examines classification with spatially separated samples.
4.2 Implementation and checkpoint selection
The model has embedding dimension 64, encoder depth 2, four gated TTT heads and one convolution TTT branch, a feed-forward expansion factor of 2, 16 pooled spectral bins, and dropout 0.1. Training uses PyTorch 2.2.0, a single NVIDIA RTX 3090, AdamW with initial learning rate and weight decay 0.01, cosine annealing, batch size 32, and gradient-norm clipping at 1.0. A maximum of 300 epochs is allowed, with early-stopping patience 50.
The primary checkpoint criterion is the highest validation overall accuracy (OA). When multiple epochs attain the same maximum number of correct validation predictions, the model with the lower validation cross-entropy is retained. Early-stopping patience resets only when validation
OA strictly increases. Test labels are not used for checkpoint selection or hyperparameter updates. Reported results are the mean and sample standard deviation across ten seeds, unless stated otherwise.
4.3 Evaluation criteria and baselines
We report overall accuracy (OA), average accuracy (AA, the mean per-class recall), Cohen's kappa, macro-F1, weighted-F1, and per-class recall. The comparison methods are SFMamba, HyperTransXNet, S Mamba, DSFormer, and SSFTT. All methods follow the same class-stratified random-sampling protocol, using seeds 3405–3414 and the training and validation fractions specified in Sec. 4. Each competing method uses the best-performing hyperparameter configuration specified in its original paper or official open-source implementation. Results are summarized over ten runs as the mean and standard deviation.
5 Results and discussion
5.1 Overall and class-wise classification performance
Tables 1–4 present class-wise recall, overall accuracy (OA), average accuracy (AA), Cohen's kappa, macro-F1, and weighted-F1 for the five comparison methods and ViTTT-HSI. Each entry reports the mean and standard deviation over ten random seeds. The mean OA values of ViTTT-HSI are 97.6390% on Indian Pines, 98.8753% on Pavia University, 99.3292% on Salinas, and 98.4283% on Houston 2013.
On Indian Pines, ViTTT-HSI exceeds the strongest comparison method, DSFormer, by 1.8470 percentage points in mean OA. The corresponding improvements over the highest competing mean OA are 0.3315 percentage points on Pavia University, 0.3636 on Salinas, and 0.2728 on Houston 2013. The class-wise results further characterize performance across land-cover categories. For example, on Indian Pines, ViTTT-HSI achieves recalls of 85.38% and 72.78% for classes 7 and 9, respectively, while other methods show lower mean recall on these challenging classes. On Pavia University, the method achieves 99.23% recall for class 7 and 99.56% for class 9. Salinas and Houston 2013 also show strong recall across most classes. The detailed per-class comparison allows the OA and AA differences to be interpreted alongside class-specific performance.
Table 1 Class-wise recall and overall performance on Indian Pines (%), ten-seed mean ± standard deviation). All metrics, including kappa, are expressed as percentages. Class IDs follow the reference labels; bold marks the highest mean in each row.
| Metric | SFMamba | HyperTransXNet | S²Mamba | DSFormer | SSFTT | ViTTT-HSI |
|---|---|---|---|---|---|---|
| Class 01 | 71.19 ± 25.21 | 67.86 ± 20.05 | 0.48 ± 1.00 | 79.05 ± 18.87 | 59.05 ± 28.14 | 96.43 ± 2.31 |
| Class 02 | 91.73 ± 3.88 | 93.68 ± 2.91 | 93.17 ± 2.57 | 92.65 ± 1.91 | 91.76 ± 2.50 | 96.01 ± 2.21 |
| Class 03 | 92.44 ± 3.46 | 93.14 ± 2.97 | 93.14 ± 3.55 | 96.88 ± 2.33 | 94.50 ± 2.23 | 96.74 ± 1.48 |
| Class 04 | 93.00 ± 5.47 | 95.16 ± 4.01 | 91.74 ± 6.72 | 93.80 ± 4.07 | 93.94 ± 7.06 | 98.22 ± 1.71 |
| Class 05 | 92.48 ± 4.78 | 93.52 ± 3.04 | 91.68 ± 3.52 | 93.82 ± 2.58 | 93.36 ± 3.01 | 93.93 ± 3.32 |
| Class 06 | 98.34 ± 1.15 | 97.07 ± 2.22 | 99.59 ± 0.28 | 98.86 ± 1.05 | 98.63 ± 0.96 | 99.60 ± 0.28 |
| Class 07 | 48.85 ± 35.44 | 30.00 ± 25.37 | 0.77 ± 1.62 | 73.08 ± 18.13 | 32.69 ± 31.47 | 85.38 ± 15.89 |
| Class 08 | 100.00 ± 0.00 | 99.93 ± 0.16 | 100.00 ± 0.00 | 99.81 ± 0.59 | 98.14 ± 1.65 | 100.00 ± 0.00 |
| Class 09 | 42.78 ± 18.71 | 49.44 ± 23.49 | 0.00 ± 0.00 | 54.44 ± 19.39 | 31.67 ± 24.85 | 72.78 ± 25.32 |
| Class 10 | 89.67 ± 3.51 | 89.79 ± 2.99 | 91.67 ± 3.62 | 90.50 ± 3.42 | 91.51 ± 2.72 | 94.77 ± 2.70 |
| Class 11 | 96.23 ± 1.73 | 96.89 ± 1.90 | 97.22 ± 1.59 | 97.49 ± 1.48 | 95.96 ± 2.28 | 98.89 ± 1.12 |
| Class 12 | 88.14 ± 3.44 | 90.00 ± 4.01 | 95.98 ± 2.60 | 93.81 ± 2.13 | 85.40 ± 7.02 | 96.04 ± 1.81 |
| Class 13 | 97.89 ± 2.55 | 95.35 ± 6.01 | 99.46 ± 0.92 | 98.97 ± 0.86 | 99.08 ± 1.51 | 99.78 ± 0.38 |
| Class 14 | 98.01 ± 1.41 | 96.98 ± 2.14 | 98.13 ± 1.25 | 98.67 ± 0.84 | 97.88 ± 1.74 | 99.95 ± 0.09 |
| Class 15 | 94.17 ± 3.35 | 90.23 ± 4.40 | 89.08 ± 6.39 | 98.51 ± 1.38 | 93.99 ± 4.47 | 99.20 ± 2.06 |
| Class 16 | 95.30 ± 6.36 | 83.73 ± 9.82 | 92.17 ± 7.32 | 95.06 ± 3.91 | 89.28 ± 10.93 | 95.18 ± 5.90 |
| OA | 94.10 ± 1.06 | 94.22 ± 0.81 | 94.54 ± 0.65 | 95.79 ± 0.64 | 94.04 ± 0.90 | 97.64 ± 0.58 |
| AA | 86.89 ± 3.01 | 85.17 ± 2.11 | 77.14 ± 0.98 | 90.96 ± 1.36 | 84.18 ± 3.68 | 95.18 ± 1.83 |
| Kappa | 93.27 ± 1.21 | 93.41 ± 0.92 | 93.77 ± 0.74 | 95.20 ± 0.73 | 93.20 ± 1.02 | 97.31 ± 0.66 |
| Macro-F1 | 87.90 ± 2.92 | 86.85 ± 2.62 | 77.07 ± 0.81 | 92.47 ± 1.48 | 84.74 ± 3.64 | 95.47 ± 1.69 |
| Weighted-F1 | 94.01 ± 1.08 | 94.13 ± 0.80 | 94.09 ± 0.66 | 95.75 ± 0.64 | 93.91 ± 0.91 | 97.63 ± 0.59 |
Table 2 Class-wise recall and overall performance on Pavia University (%), ten-seed mean ± standard deviation). All metrics, including kappa, are expressed as percentages. Class IDs follow the reference labels; bold marks the highest mean in each row.
| Metric | SFMamba | HyperTransXNet | S²Mamba | DSFormer | SSFTT | ViTTT-HSI |
|---|---|---|---|---|---|---|
| Class 01 | 97.05 ± 1.44 | 97.41 ± 1.53 | 98.67 ± 0.94 | 97.79 ± 1.22 | 97.09 ± 1.46 | 98.30 ± 0.94 |
| Class 02 | 99.78 ± 0.14 | 99.50 ± 0.43 | 99.82 ± 0.16 | 99.82 ± 0.11 | 99.79 ± 0.20 | 99.73 ± 0.29 |
| Class 03 | 94.16 ± 1.65 | 91.44 ± 5.70 | 94.21 ± 3.46 | 94.53 ± 2.76 | 90.11 ± 4.10 | 95.11 ± 5.75 |
| Class 04 | 95.59 ± 1.52 | 92.32 ± 3.10 | 96.86 ± 1.07 | 96.56 ± 1.21 | 94.90 ± 2.78 | 98.06 ± 0.95 |
| Class 05 | 99.79 ± 0.18 | 99.24 ± 0.80 | 99.98 ± 0.05 | 99.99 ± 0.02 | 99.85 ± 0.31 | 99.96 ± 0.10 |
| Class 06 | 99.31 ± 0.69 | 98.31 ± 0.92 | 98.52 ± 1.14 | 99.01 ± 0.99 | 98.75 ± 1.72 | 98.86 ± 2.37 |
| Class 07 | 94.06 ± 5.39 | 93.03 ± 3.86 | 93.44 ± 7.29 | 95.79 ± 6.94 | 99.01 ± 0.73 | 99.23 ± 1.87 |
| Class 08 | 96.30 ± 1.83 | 96.50 ± 2.35 | 98.48 ± 1.64 | 95.35 ± 2.58 | 89.88 ± 4.86 | 97.75 ± 1.37 |
| Class 09 | 91.86 ± 6.17 | 92.69 ± 3.89 | 93.08 ± 5.32 | 95.46 ± 5.91 | 92.17 ± 6.54 | 99.56 ± 0.66 |
| OA | 98.07 ± 0.38 | 97.51 ± 0.51 | 98.54 ± 0.39 | 98.31 ± 0.54 | 97.38 ± 0.53 | 98.88 ± 0.49 |
| AA | 96.43 ± 1.09 | 95.61 ± 0.96 | 97.01 ± 1.20 | 97.14 ± 1.38 | 95.73 ± 1.00 | 98.51 ± 0.72 |
| Kappa | 97.45 ± 0.50 | 96.69 ± 0.68 | 98.07 ± 0.52 | 97.76 ± 0.72 | 96.53 ± 0.70 | 98.51 ± 0.65 |
| Macro-F1 | 96.65 ± 0.84 | 95.92 ± 0.91 | 97.53 ± 0.98 | 97.35 ± 1.16 | 95.94 ± 1.01 | 98.47 ± 0.76 |
| Weighted-F1 | 98.07 ± 0.38 | 97.49 ± 0.52 | 98.53 ± 0.40 | 98.31 ± 0.55 | 97.36 ± 0.54 | 98.87 ± 0.50 |
Table 3 Class-wise recall and overall performance on Salinas (%), ten-seed mean ± standard deviation). All metrics, including kappa, are expressed as percentages. Class IDs follow the reference labels; bold marks the highest mean in each row.
| Metric | SFMamba | HyperTransXNet | S²Mamba | DSFormer | SSFTT | ViTTT-HSI |
|---|---|---|---|---|---|---|
| Class 01 | 98.70 ± 2.79 | 99.36 ± 0.82 | 99.90 ± 0.24 | 97.64 ± 5.07 | 99.84 ± 0.30 | 99.85 ± 0.41 |
| Class 02 | 99.99 ± 0.03 | 99.96 ± 0.11 | 100.00 ± 0.00 | 100.00 ± 0.00 | 99.91 ± 0.16 | 99.99 ± 0.02 |
| Class 03 | 98.69 ± 3.80 | 99.16 ± 1.15 | 99.98 ± 0.04 | 99.78 ± 0.53 | 99.98 ± 0.07 | 99.53 ± 0.50 |
| Class 04 | 98.95 ± 2.13 | 97.56 ± 2.60 | 98.66 ± 1.24 | 99.43 ± 0.33 | 99.02 ± 0.70 | 99.39 ± 1.34 |
| Class 05 | 98.69 ± 1.92 | 98.55 ± 1.02 | 98.64 ± 2.20 | 98.91 ± 1.60 | 99.02 ± 1.23 | 98.01 ± 0.83 |
| Class 06 | 99.89 ± 0.20 | 99.83 ± 0.36 | 99.83 ± 0.53 | 100.00 ± 0.00 | 99.89 ± 0.19 | 99.90 ± 0.23 |
| Class 07 | 99.92 ± 0.09 | 99.64 ± 0.71 | 99.97 ± 0.05 | 99.99 ± 0.01 | 99.78 ± 0.58 | 99.86 ± 0.29 |
| Class 08 | 92.57 ± 2.78 | 95.91 ± 2.55 | 96.23 ± 1.44 | 96.88 ± 0.72 | 98.36 ± 0.83 | 99.12 ± 0.64 |
| Class 09 | 99.98 ± 0.03 | 99.79 ± 0.30 | 100.00 ± 0.00 | 100.00 ± 0.00 | 99.97 ± 0.04 | 99.98 ± 0.06 |
| Class 10 | 97.93 ± 1.52 | 99.08 ± 0.77 | 98.95 ± 1.18 | 98.32 ± 1.14 | 98.76 ± 1.25 | 99.44 ± 0.87 |
| Class 11 | 99.01 ± 0.74 | 99.83 ± 0.25 | 99.52 ± 0.09 | 99.94 ± 0.15 | 99.66 ± 0.60 | 99.34 ± 1.09 |
| Class 12 | 99.25 ± 1.67 | 99.38 ± 1.11 | 99.97 ± 0.06 | 99.88 ± 0.12 | 99.76 ± 0.44 | 99.86 ± 0.19 |
| Class 13 | 99.65 ± 0.46 | 99.43 ± 1.17 | 99.62 ± 1.12 | 99.97 ± 0.08 | 96.34 ± 7.32 | 98.15 ± 2.77 |
| Class 14 | 98.91 ± 0.97 | 98.48 ± 1.72 | 98.95 ± 1.02 | 99.39 ± 0.60 | 97.76 ± 2.80 | 97.67 ± 2.08 |
| Class 15 | 92.19 ± 2.19 | 94.50 ± 2.69 | 94.06 ± 3.33 | 95.36 ± 2.18 | 97.53 ± 1.60 | 98.93 ± 0.73 |
| Class 16 | 98.84 ± 1.97 | 99.58 ± 0.75 | 99.49 ± 0.52 | 99.04 ± 2.49 | 98.48 ± 0.88 | 98.29 ± 3.55 |
| OA | 96.96 ± 0.40 | 98.02 ± 0.60 | 98.18 ± 0.69 | 98.41 ± 0.42 | 98.97 ± 0.28 | 99.33 ± 0.27 |
| AA | 98.32 ± 0.42 | 98.75 ± 0.34 | 98.99 ± 0.41 | 99.03 ± 0.41 | 99.00 ± 0.57 | 99.21 ± 0.44 |
| Kappa | 96.62 ± 0.44 | 97.80 ± 0.67 | 97.97 ± 0.77 | 98.23 ± 0.46 | 98.85 ± 0.32 | 99.25 ± 0.30 |
| Macro-F1 | 98.23 ± 0.46 | 98.67 ± 0.39 | 98.98 ± 0.40 | 98.97 ± 0.40 | 99.00 ± 0.51 | 99.19 ± 0.45 |
| Weighted-F1 | 96.96 ± 0.39 | 98.02 ± 0.60 | 98.18 ± 0.69 | 98.41 ± 0.42 | 98.97 ± 0.28 | 99.33 ± 0.27 |
Table 4 Class-wise recall and overall performance on Houston 2013 (%), ten-seed mean ± standard deviation). All metrics, including kappa, are expressed as percentages. Class IDs follow the reference labels; bold marks the highest mean in each row.
| Metric | SFMamba | HyperTransXNet | S²Mamba | DSFormer | SSFTT | ViTTT-HSI |
|---|---|---|---|---|---|---|
| Class 01 | 97.96 ± 1.08 | 97.63 ± 1.60 | 97.24 ± 1.02 | 98.18 ± 1.29 | 98.28 ± 1.63 | 98.41 ± 1.50 |
| Class 02 | 98.97 ± 0.97 | 98.32 ± 1.55 | 98.71 ± 0.53 | 99.23 ± 0.47 | 99.47 ± 0.76 | 99.20 ± 0.49 |
| Class 03 | 99.25 ± 0.43 | 99.36 ± 0.44 | 99.65 ± 0.30 | 98.82 ± 1.27 | 99.57 ± 0.29 | 100.00 ± 0.00 |
| Class 04 | 98.84 ± 1.08 | 97.07 ± 1.97 | 98.44 ± 0.65 | 99.23 ± 0.55 | 98.64 ± 0.50 | 99.09 ± 1.77 |
| Class 05 | 99.96 ± 0.09 | 99.96 ± 0.10 | 99.99 ± 0.03 | 100.00 ± 0.00 | 100.00 ± 0.00 | 100.00 ± 0.00 |
| Class 06 | 90.34 ± 5.67 | 93.17 ± 4.66 | 83.55 ± 4.00 | 93.89 ± 5.43 | 94.57 ± 5.95 | 97.34 ± 2.47 |
| Class 07 | 98.11 ± 1.09 | 95.95 ± 2.03 | 98.98 ± 0.71 | 98.48 ± 1.29 | 97.43 ± 2.79 | 97.94 ± 0.84 |
| Class 08 | 93.36 ± 2.28 | 92.83 ± 2.06 | 84.38 ± 4.50 | 94.50 ± 1.64 | 93.92 ± 3.86 | 94.64 ± 3.18 |
| Class 09 | 95.36 ± 2.23 | 94.80 ± 2.36 | 91.27 ± 2.54 | 95.36 ± 1.92 | 96.75 ± 1.36 | 97.31 ± 2.08 |
| Class 10 | 99.23 ± 0.75 | 99.10 ± 1.55 | 96.62 ± 1.44 | 99.25 ± 0.54 | 99.32 ± 0.75 | 99.84 ± 0.23 |
| Class 11 | 98.61 ± 1.16 | 97.76 ± 1.76 | 98.91 ± 1.24 | 98.88 ± 1.21 | 98.28 ± 1.71 | 98.74 ± 1.30 |
| Class 12 | 97.08 ± 1.24 | 95.98 ± 1.16 | 93.10 ± 3.55 | 97.12 ± 1.16 | 98.70 ± 0.65 | 97.97 ± 2.12 |
| Class 13 | 95.89 ± 3.44 | 92.53 ± 3.12 | 44.80 ± 32.17 | 97.40 ± 2.53 | 96.43 ± 3.32 | 96.36 ± 2.22 |
| Class 14 | 100.00 ± 0.00 | 99.30 ± 1.04 | 100.00 ± 0.00 | 99.61 ± 0.48 | 100.00 ± 0.00 | 100.00 ± 0.00 |
| Class 15 | 99.97 ± 0.11 | 99.85 ± 0.23 | 100.00 ± 0.00 | 99.95 ± 0.11 | 99.98 ± 0.05 | 99.97 ± 0.11 |
| OA | 97.76 ± 0.27 | 97.02 ± 0.62 | 94.40 ± 1.28 | 98.08 ± 0.26 | 98.16 ± 0.59 | 98.43 ± 0.60 |
| AA | 97.53 ± 0.41 | 96.91 ± 0.66 | 92.38 ± 2.42 | 97.99 ± 0.50 | 98.09 ± 0.74 | 98.45 ± 0.58 |
| Kappa | 97.58 ± 0.29 | 96.78 ± 0.67 | 93.94 ± 1.39 | 97.92 ± 0.29 | 98.01 ± 0.64 | 98.30 ± 0.64 |
| Macro-F1 | 97.71 ± 0.27 | 96.96 ± 0.63 | 92.68 ± 2.88 | 98.11 ± 0.35 | 98.14 ± 0.67 | 98.44 ± 0.60 |
| Weighted-F1 | 97.75 ± 0.27 | 97.02 ± 0.62 | 93.95 ± 1.74 | 98.08 ± 0.27 | 98.15 ± 0.59 | 98.43 ± 0.60 |
5.2 Classification maps and error visualization
Figures 3–6 compare six classifiers using consistent colors within each dataset. Predictions are paired with binary error maps (white: incorrect; black: other pixels). ViTTT-HSI uses the validation-selected checkpoint from seed 3405 (Sec. 4.2).

Fig 3 Classification maps on Indian Pines: (a) ground truth; (b) SFMamba; (c) HyperTransXNet; (d) S²Mamba; (e) DSFormer; (f) SSFTT; (g) ViTTT-HSI. Each model's prediction appears above its error map.

Fig 4 Classification maps on Pavia University. Panel order and the error-map convention follow Fig. 3.

Fig 5 Classification maps on Salinas. Panel order and the error-map convention follow Fig. 3.

Fig 6 Classification maps on Houston 2013. Panel order and the error-map convention follow Fig. 3. All maps are rotated 90° counterclockwise for readability.
5.3 Training dynamics and validation convergence
The loss and accuracy histories provide a complementary view of optimization under the specified training and checkpoint-selection protocol. Figures 7–9 plot the epoch-wise mean training loss, validation cross-entropy, and validation OA for all four datasets. The curves show rapid early improvements followed by a more gradual refinement of the validation metrics. The two types of validation measurement serve different purposes: OA determines the highest accuracy used in checkpoint selection, while cross-entropy resolves ties between epochs attaining that level. The plotted means use the runs that have reached the respective epoch, because individual runs stop at different epochs with an early-stopping patience of 50 epochs.

(c) Salinas
(d) Houston 2013

Fig 7 Training cross-entropy across seeds 3405–3414: (a) Indian Pines; (b) Pavia University; (c) Salinas; (d) Houston 2013. Lines and bands show the mean and one sample standard deviation of the available runs at each epoch; stopped runs are not extended.

(c) Salinas
(d) Houston 2013

Fig 8 Validation cross-entropy across seeds 3405–3414. The line/band convention and panels (a)–(d) follow Fig. 7; stopped runs are not extended.
(a) Indian Pines

(b) Pavia University
(c) Salinas
(d) Houston 2013

Fig 9 Validation overall accuracy across seeds 3405–3414. The line/band convention and panels (a)–(d) follow Fig. 7; stopped runs are not extended.
5.4 Effect of spectral embedding and TTT
Table 5 provides a factorial ablation of spectral versus linear embedding and the presence of the TTT mixer on Indian Pines and Pavia University. The TTT mixer improves Indian Pines classification with either embedding, and the spectral stem produces the highest OA and AA on Indian Pines. Pavia University also benefits from TTT, while linear embedding with TTT gives a slightly higher mean OA than spectral embedding with TTT. The two datasets therefore exhibit different sensitivities to the embedding pathway.
5.5 Role of the TTT inner update
Table 6 compares the full mixer against a model without the mixer and a frozen-inner version that retains the inner-model architecture but skips fast-weight updates. Full TTT improves Indian Pines OA by 3.5555 percentage points over the frozen-inner version, with a smaller gain of 0.2478 percentage points on Pavia University. These controlled comparisons isolate the benefit of patch-specific fast-weight updates more clearly than removing the mixer altogether: the learned inner-model architecture is retained in the frozen variant, whereas only its data-conditioned update is omitted.
5.6 Center–global features and patch-size analysis
The center–global classifier is assessed against center-only and global-only heads in Table 7. The center feature is especially important: global-only classification is markedly weaker on both datasets. Combining center and global features improves Indian Pines OA over center-only classification, while the center-only head is slightly better on Pavia University. The result is consistent with the different contributions of center-pixel evidence and neighborhood context across scenes.
Table 8 evaluates patch sizes 11, 21, and 29 under both full TTT and a no-TTT setting, using three seeds per configuration. The full TTT configuration obtains higher mean OA than the no-TTT setting at each evaluated patch size. The observed gain is largest at on Indian Pines
Table 5 Embedding and TTT ablation on Indian Pines and Pavia University (%, ten seeds).
| Dataset | Variant | OA | AA |
|---|---|---|---|
| Indian | Linear, no TTT | 93.76 ± 0.88 | 89.45 ± 3.13 |
| Indian | Spectral, no TTT | 94.19 ± 0.95 | 90.91 ± 2.16 |
| Indian | Linear, TTT | 97.42 ± 0.46 | 94.85 ± 1.89 |
| Indian | Spectral, TTT | 97.64 ± 0.58 | 95.18 ± 1.83 |
| Pavia | Linear, no TTT | 98.42 ± 0.38 | 97.72 ± 0.64 |
| Pavia | Spectral, no TTT | 98.46 ± 0.35 | 97.78 ± 0.69 |
| Pavia | Linear, TTT | 98.97 ± 0.35 | 98.67 ± 0.56 |
| Pavia | Spectral, TTT | 98.88 ± 0.49 | 98.51 ± 0.72 |
Table 6 Ablation of the TTT inner update (%, mean ± standard deviation; ten seeds).
| Dataset | Mixer setting | OA | AA |
|---|---|---|---|
| Indian | No TTT | 94.19 ± 0.95 | 90.91 ± 2.16 |
| Indian | Frozen inner | 94.08 ± 0.65 | 90.18 ± 2.06 |
| Indian | Full | 97.64 ± 0.58 | 95.18 ± 1.83 |
| Pavia | No TTT | 98.46 ± 0.35 | 97.78 ± 0.69 |
| Pavia | Frozen inner | 98.63 ± 0.31 | 98.11 ± 0.52 |
| Pavia | Full | 98.88 ± 0.49 | 98.51 ± 0.72 |
Table 7 Classification-head ablation (%, ten-seed OA mean ± standard deviation).
| Dataset | Head | OA |
|---|---|---|
| Indian | Center | |
| Indian | Global | |
| Indian | Center + Global | |
| Pavia | Center | |
| Pavia | Global | |
| Pavia | Center + Global |
and on Pavia University, indicating that the interaction between patch context and inner adaptation depends on the dataset.
5.7 Spatially separated evaluation
A further evaluation on Pavia University uses a spatial-block split with patch size 11 and three seeds. As summarized in Table 9, full TTT outperforms the no-TTT variant in this more spatially separated setup. The full TTT configuration achieves 90.16% OA, exceeding the no-TTT configuration by 1.40 percentage points in this spatial-block experiment.
5.8 Computational complexity and efficiency
Table 10 presents the parameter count, computational cost, and training and inference times of ViTTT-HSI on an NVIDIA RTX 3090. Computational cost in billions of floating-point operations (GFLOPs) is estimated for one input patch with a batch size of one, counting the main forward computations of both TTT inner adaptation and query evaluation at two floating-point operations per multiply-accumulate. Training time covers the epoch loop, including validation and checkpoint writing. Testing time is measured on the entire test loader after warm-up, with device synchronization.
Across all four datasets, the model uses approximately 0.09 million trainable parameters. The measured test-set runtime varies with the number of pixels evaluated and the dataset-specific patch size.
Table 8 Patch-size ablation on Indian Pines and Pavia University (%, mean OA over three seeds). The last column is the Full TTT minus No TTT difference in percentage points.
| Dataset | P | Full TTT | No TTT | Difference |
|---|---|---|---|---|
| Indian | 11 | 97.34 | 95.30 | +2.04 |
| Indian | 21 | 97.24 | 95.17 | +2.07 |
| Indian | 29 | 97.69 | 94.80 | +2.89 |
| Pavia | 11 | 97.46 | 97.36 | +0.11 |
| Pavia | 21 | 98.74 | 98.21 | +0.53 |
| Pavia | 29 | 98.72 | 98.50 | +0.22 |
Table 9 Spatial-block evaluation on Pavia University using patch size 11 (%, mean ± standard deviation across three seeds).
| Variant | OA | AA |
|---|---|---|
| Full | ||
| No TTT |
Table 10 Model complexity and seed-3405 runtime of ViTTT-HSI. GFLOPs denote the estimated major forward arithmetic operations per input patch; M denotes millions of parameters, and runtime is reported in seconds.
| Dataset | Parameters (M) | GFLOPs | Train (s) | Test (s) |
|---|---|---|---|---|
| Indian | 0.0923 | 0.167 | 139.1 | 4.04 |
| Pavia | 0.0914 | 0.165 | 42.2 | 11.15 |
| Salinas | 0.0923 | 0.145 | 93.3 | 20.44 |
| Houston 2013 | 0.0922 | 0.166 | 219.5 | 4.33 |
6 Conclusion
This study adapted the ViT³ visual test-time training mechanism to center-pixel hyperspectral classification through a spectral-aware embedding, spatial-token-preserving TTT encoders, and a center-global classifier. Four public benchmarks and ten random seeds supported competitive classification performance under the specified low-label random-pixel protocols. Controlled ablations indicate that the patch-conditioned TTT inner update contributes to the classification gains, especially on Indian Pines, while the benefits of the spectral stem and global feature pooling are dependent on the dataset. The results establish an experimental basis for applying patch-conditioned visual TTT to spectral-spatial center-pixel classification.
Disclosures
The authors declare that there are no financial interests, commercial affiliations, or other potential conflicts of interest that could have influenced the objectivity of this research or the writing of this paper.
Code and Data Availability
The Indian Pines, Pavia University, Salinas, and Houston 2013 datasets used in this study are available through the HSI Datasets repository on Hugging Face.¹⁶ The source code and reproduction scripts for ViTTT-HSI will be released in the project GitHub repository.
Acknowledgments
We thank OpenAI ChatGPT for assistance with English-language editing and LaTeX preparation. The authors take full responsibility for the scientific content, accuracy, and conclusions of this manuscript.
References
1 M. E. Paoletti et al., “Deep learning classifiers for hyperspectral imaging: A review,” ISPRS Journal of Photogrammetry and Remote Sensing 158, 279–317 (2019). doi:10.1016/j.isprsjprs.2019.09.006.
2 S. Jia et al., “A survey: Deep learning for hyperspectral image classification with few labeled samples,” Neurocomputing 448, 179–204 (2021). doi:10.1016/j.neucom.2021.03.035.
3 Z. Zhong et al., “Spectral–spatial residual network for hyperspectral image classification: A 3-D deep learning framework,” IEEE Transactions on Geoscience and Remote Sensing 56(2), 847–858 (2018). doi:10.1109/TGRS.2017.2755542.
4 S. K. Roy et al., “HybridSN: Exploring 3-D–2-D CNN feature hierarchy for hyperspectral image classification,” IEEE Geoscience and Remote Sensing Letters 17(2), 277–281 (2020). doi:10.1109/LGRS.2019.2918719.
5 D. Hong et al., “SpectralFormer: Rethinking hyperspectral image classification with Transformers,” IEEE Transactions on Geoscience and Remote Sensing 60, 1–15 (2022). doi:10.1109/TGRS.2021.3130716.
6 L. Sun et al., “Spectral–spatial feature tokenization transformer for hyperspectral image classification,” IEEE Transactions on Geoscience and Remote Sensing 60, 1–14 (2022). doi:10.1109/TGRS.2022.3144158.
7 G. Wang et al., “S²Mamba: A spatial-spectral state space model for hyperspectral image classification,” IEEE Transactions on Geoscience and Remote Sensing 63, 1–13 (2025). doi:10.1109/TGRS.2025.3530993.
8 Y. Sun et al., “Learning to (learn at test time): RNNs with expressive hidden states,” in Proceedings of the 42nd International Conference on Machine Learning, Proceedings of Machine Learning Research 267, 57503–57522 (2025). https://proceedings.mlr.press/v267/sun25h.html.
9 D. Han et al., “ViT³: Unlocking test-time training in vision,” in Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR), 51–61 (2026). https://openaccess.thecvf.com/content/CVPR2026/html/Han_ViT3_Unlocking_Test-Time_Training_in_Vision_CVPR_2026_paper.html.
10 A. Vaswani et al., “Attention is all you need,” in Advances in Neural Information Processing Systems, 30, 5998–6008 (2017). https://papers.nips.cc/paper/7181-attention-is-all-you-need.
11 Y. Xu et al., “Dual selective fusion transformer network for hyperspectral image classification,” Neural Networks 187, 107311 (2025). doi:10.1016/j.neunet.2025.107311.
12 X. Dai et al., “HyperTransXNet: Learning both global and local dynamics with a dual dynamic token mixer for hyperspectral image classification,” Remote Sensing 17(14), 2361 (2025). doi:10.3390/rs17142361.
13 A. Gu and T. Dao, “Mamba: Linear-time sequence modeling with selective state spaces,” in Proceedings of the Conference on Language Modeling (COLM), (2024). https://openreview.net/forum?id=tEYskw1VY2.
14 Z. Meng, L. Yue, and F. Zhao, “Spatial-frequency joint learning Mamba for hyperspectral image classification,” IEEE Geoscience and Remote Sensing Letters 23, 1–5 (2026). doi:10.1109/LGRS.2026.3652369.
15 X. Yue et al., “Beyond distribution shifts: Adaptive hyperspectral image classification at test time,” Neurocomputing 678, 133188 (2026). doi:10.1016/j.neucom.2026.133188.
16 Tanishq165, “HSI Datasets.” Hugging Face dataset repository. Accessed 30 October 2026. https://huggingface.co/datasets/Tanishq165/HSI_Datasets.
Xiang Zhao received his B.Sc. degree in mathematics and applied mathematics from Harbin Engineering University, Harbin, China, in 2025. He is currently pursuing an M.Sc. degree in mathematics at the College of Mathematical Sciences, Harbin Engineering University. His research interests include remote sensing image processing, hyperspectral image classification, and deep learning algorithms, particularly graph neural networks and attention mechanisms.