JEOS RP ISSN02 | Página 130

J. Eur. Opt. Society-Rapid Publ. 21, 43( 2025) 125
the upper constrained self-attention transformer module, effectively detecting abnormal targets in hyperspectral images.
3. We conducted experimental verification using real hyperspectral images and compared them with stateof-the-art methods, ultimately proving the effectiveness of our proposed method.
2 Preliminary
2.1 Multi-head attention
The Transformer is a deep learning model proposed by Vaswani et al. [ 43 ] for natural language processing; it processes all elements in a sequence in parallel and can efficiently and quickly capture long-term dependencies in text. The Vision Transformer( ViT) uses the encoder module from the Transformer architecture for image classification tasks by segmenting images into patches and flattening them. This approach transforms the image recognition problem into a“ sequence-to-sequence” problem [ 44 ]. The core of the Transformer encoder is the multi-head attention( MSA) mechanism, where each self-attention( SA) corresponds to a set of matrices W q, W k, andW v, which are multiplied by the input X of SA to obtain the query Q, key K, and value V as follows:
Q ¼ XW q; K ¼ XW k; V ¼ XW V: ð1Þ The corresponding output of SA is:
SA ¼ attention ðQ; K; VÞ ¼ softmax QKT pffiffiffi
V: d ð2Þ
The product of Q and K T represents similarity, while V can be seen as a vector of a single input feature. Figure 1 illustrates the computation of multi-head attention as implemented in the actual code. It consists of multiple self-attention mechanisms. The input X is split into segments, and the corresponding self-attention is computed basedonequations( 1) and( 2). These are then concatenated to obtain Z, which satisfies the following equation:
Z ¼ MSA ðQ; K; V
Þ ¼ concatðSA 1; SA 2; L; SA h Þ: ð3Þ where h is the number of self-attention groups.
2.2 Stacked autoencoder
The Autoencoder is an unsupervised neural network model designed to learn deep features of data and reconstruct the input. Essentially, it is a three-layer neural network comprising an input layer, a hidden layer, and a reconstruction layer [ 45 ]. Figure 2 shows the structure of a stacked Autoencoder, which is a symmetric multi-layer neural network formed by stacking multiple Autoencoders. The output of the lth layer in the stacked Autoencoder is:
y ðlÞ ¼ f W ðÞ l y ðl�1Þ þ b ðÞ l: ð4Þ
Fig. 1. The calculation process of multi-head attention.
Fig
. 2. Diagram of stacked autoencoder( SAE).
3 Proposed method
In this section, we specifically introduce the proposed dualwindow transformer framework with pyramid structure and Constrained self-attention. Figure 3 shows the framework of the proposed method, a pyramid structure where the final result of each layer’ s operation provides feedback for the next layer. The hyperspectral images of each scale in the pyramid are entered into Dual window Preprocessing and Constrained self-attention transformer module( CSATM) in order of scale. The framework’ s core is the CSATM, whose weight of self-attention is Constrained by the upper layer of the pyramid. The framework consists of four parts:
1. Pyramid construction: Hyperspectral images are downsampled step by step spatially and input into subsequent modules. After completing all subsequent modules of a certain scale hyperspectral image, input the next scale hyperspectral image.
2. Dual-window preprocessing: The pixel-by-pixel moving dual-windows extract the hyperspectral image into a set of“ center pixels – pixels within the dualwindow”, and process the set into a form that can be received by CSATM. The center pixel and background pixel of the dual window at a certain position form a training sample.
3. CSATM: The core part of the framework is to learn spectral depth differences and provide pixel-level anomaly score maps.