Hyperspectral Image Anomaly Detection Method Based on Quantization Learning
By building a signed 8-bit integer fully connected layer autoencoder network, the calculation efficiency problem caused by floating point number type parameters is solved, and efficient hyperspectral image anomaly detection on the device side of hardware resource-constrained.
Patent Information
- Application Number
- CN202310267283.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-17
- Publication Date
- 2025-07-29
- Estimated Expiration
- 2043-03-17
AI Technical Summary
In the existing hyperspectral image anomaly detection methods, the floating-point number type parameters of the autoencoder network cause long calculation time, making it difficult to effectively learn on edge devices with limited hardware resources.
The signed 8-bit integer fully connected layer is used to build an autoencoder network. Through quantitative learning, the number of bits and calculation time of network parameters is reduced and the computing time is improved.
It improves the computing rate and detection accuracy of the autoencoder network, and can efficiently detect hyperspectral image anomalies on edge devices with limited hardware resources.
Smart Images

Figure CN116468669B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and further relates to a hyperspectral image anomaly detection method based on quantization learning in the technical field of hyperspectral image detection. The present invention can be applied to anomaly detection fields related to hyperspectral images such as deep space exploration and earth observation. Background Art
[0002] Anomaly detection of hyperspectral images can be regarded as target detection lacking prior spectral information of the target. Its purpose is to find targets in hyperspectral images that are abnormal compared to the background. There is no definite definition method for abnormal targets, and they are usually regarded as "outliers" that deviate from the background clustering. Currently, there is no definite definition method for abnormal pixels, and they are usually regarded as pixel points that deviate from the background clustering. Anomaly detection is achieved by separating background pixels and abnormal pixels, and its principle is mainly based on two discriminative features of abnormal pixels in hyperspectral images: compared with background pixels, the probability of abnormal pixels appearing in the image is usually low; the spectral features of abnormal pixels usually deviate from the spectral features of their surrounding background pixels. In engineering practice, many anomaly detection methods for hyperspectral images are mainly autoencoder-based methods. In this method, the hyperspectral image is input into an autoencoder network. The hyperspectral image is input into the encoder to obtain deep features, and the deep features are input into the decoder to reconstruct background pixels. The residual between the hyperspectral image and the reconstructed background pixels is calculated to separate abnormal pixels. In this method, the autoencoder mainly uses floating-point numbers for network training. However, the network trained with floating-point numbers has problems such as long calculation time and difficulty in learning and training on edge devices with limited hardware resources.
[0003] Wuhan University proposed an anomaly detection method for hyperspectral images in its patent document "A Hyperspectral Image Anomaly Detection Method Based on a Fully Convolutional Autoencoder" (Patent Application No.: CN 202011508302.1, Publication No.: CN 112598636 A). The implementation steps of this method are as follows: First, input a hyperspectral remote sensing image to be detected and preprocess the image data, and then input a uniform noise image; Second, randomly initialize the network parameters of the fully convolutional autoencoder; Then, train the fully convolutional autoencoder network based on the adaptive moment estimation algorithm; Finally, use the trained fully convolutional autoencoder network to reconstruct the background, and take the reconstruction error map as the final anomaly detection result. This method combines the moment estimation algorithm with the autoencoder, which can enhance the network's ability to reconstruct the background and make the reconstruction error as the anomaly result more significant. However, the deficiencies still existing in this method are: In the process of the fully convolutional autoencoder network reconstructing the background, the data types of the inputs and weights of the convolutional layer and the fully connected layer of the fully convolutional autoencoder are signed 32-bit floating-point numbers. Compared with signed 8-bit integers, signed 32-bit floating-point numbers require more bits to represent, need to process more data during calculation, need to consider issues such as rounding errors, overflows, and underflows, and there are still defects of slow operation and low computational efficiency when detecting hyperspectral images.
[0004] Xi'an University of Technology proposed an anomaly detection method for hyperspectral images in its patent document "A Hyperspectral Anomaly Detection Method Based on a Fully Convolutional Cascade Autoencoder" (Patent Application No.: CN 202110621623.0, Publication No.: CN 113379859 A). The implementation steps of this method are as follows: Step 1, encode through the first encoder; Step 2, decode through the first decoder; Step 3, encode through the second encoder. The second encoder has the same structure as the first encoder, and the second encoder encodes the first reconstructed image into a second latent feature with the same size as the first latent feature; Step 4, decode through the second decoder, and the second decoder decodes the second latent feature into a second reconstructed image; Step 5, use the Mahalanobis distance to determine the anomaly value of each pixel on the second reconstructed image. This method can well reconstruct hyperspectral images by cascading two autoencoder training networks. However, the deficiencies still existing in this method are: Since the inputs and weights of the autoencoder network are of floating-point data type, more hardware resources are required, and the computational efficiency for detecting hyperspectral images is low, which is not conducive to learning on edge devices with limited hardware resources. Summary of the Invention
[0005] The object of the present invention is to propose a hyperspectral image anomaly detection method based on quantization learning for solving the technical problems of slow calculation, low optimization efficiency and difficulty in learning on edge devices with limited hardware resources existing in the prior art that the input and weights of the autoencoder network used to detect hyperspectral images are of floating-point data type.
[0006] The idea of realizing the object of the present invention is that considering that the network parameters of signed 8-bit integers only need to perform 8-bit integer operations, compared with the network parameters of signed 32-bit floating-point numbers that need to perform 32-bit floating-point operations, the operation rate is faster, which can accelerate the training and inference processes of the neural network. The network parameters of signed 8-bit integers only need fewer bits to represent, less parameter calculation time and less hardware resources to perform operations compared with the network parameters of signed 32-bit floating-point numbers. Therefore, an autoencoder with a fully connected layer whose data types of input and weights are signed 8-bit integers is used as the network framework for quantization learning. First, obtain the spectral matrix after dimensionality reduction of the hyperspectral image, input the spectral matrix into the autoencoder network to train and obtain the background reconstructed spectral matrix, calculate the reconstruction error matrix between the background reconstructed spectral matrix and the spectral matrix, and output the anomaly image. The autoencoder network constructed by the present invention can effectively quantize the input and weights of the fully connected layer in the autoencoder network, avoiding the defects of slow operation and difficulty in learning on edge devices with limited hardware resources existing in the network parameters of floating-point types.
[0007] To achieve the above object, the technical solution adopted by the present invention includes the following steps:
[0008] Step 1, generate a dimensionality-reduced spectral matrix:
[0009] Arrange the pixels from the first row to the last row in each two-dimensional image of each channel in a hyperspectral image to be detected row by row, and reduce the dimension to obtain each column in the spectral matrix, and normalize the spectral matrix.
[0010] Step 2, construct an autoencoder network:
[0011] Step 2.1, use the torch.nn.Linear function to construct a fully connected layer, and based on the fully connected layer structure, respectively construct the forward propagation module and the backward propagation module of the signed 8-bit integer quantization fully connected layer.
[0012] Step 2.2, use the signed 8-bit integer quantization fully connected layer to construct an autoencoder network composed of an encoder and a decoder connected in series.
[0013] Step 2.2.1: Build an encoder, whose structure is as follows in sequence: the first encoding quantization fully-connected layer, the first encoding activation layer, the second encoding quantization fully-connected layer, the second encoding activation layer, the third encoding quantization fully-connected layer, the third encoding activation layer; among them, the structures of the first to third encoding quantization fully-connected layers are the same, all using signed 8-bit integer quantization fully-connected layers, and the structures of the first to third encoding activation layers are the same, all using the ReLU function;
[0014] Set the parameters of the encoder as follows: Set the input channel parameters of the first to third encoding quantization fully-connected layers to the number of channels of the hyperspectral image to be detected, 128, and 64 respectively, and set the output channel parameters of the first to third encoding quantization fully-connected layers to 128, 64, and 20 respectively;
[0015] Step 2.2.2: Build a decoder, whose structure is as follows in sequence: the first decoding quantization fully-connected layer, the first decoding activation layer, the second decoding quantization fully-connected layer, the second decoding activation layer, the third decoding quantization fully-connected layer, the sigmoid layer; among them, the structures of the first to third decoding quantization fully-connected layers are the same, all using signed 8-bit integer quantization fully-connected layers, the structures of the first to second decoding activation layers are the same, all using the ReLU function, and the sigmoid layer is implemented using the sigmoid function;
[0016] Set the parameters of the decoder as follows: Set the input channel parameters of the first to third decoding quantization fully-connected layers to 20, 64, and 128 respectively, and set the output channel parameters of the first to third encoding quantization fully-connected layers to 64, 128, and the number of channels of the hyperspectral image to be detected respectively;
[0017] Step 3: Train the autoencoder network:
[0018] Step 3.1: Set the optimization algorithm and basic parameters for training the autoencoder network;
[0019] Step 3.2: Input the spectral matrix in Step 1 into the autoencoder network, output the reconstructed spectral matrix, and iteratively update the network parameters of the autoencoder until the loss value of the reconstruction error function between the spectral matrix and the reconstructed spectral matrix converges, obtaining the trained autoencoder network;
[0020] Step 4: Perform anomaly detection on the hyperspectral image:
[0021] Step 4.1: Input the spectral matrix in Step 1 into the trained autoencoder network to obtain the reconstructed spectral result matrix;
[0022] Step 4.2: Element-wise subtract the spectral matrix from the reconstructed spectral result matrix to obtain a reconstruction error matrix. Calculate the two-norm value of each row in the reconstruction error matrix, arrange all the two-norm values in a row to form a two-norm value matrix, and plot and save the anomaly image of this two-norm value matrix.
[0023] Compared with the existing technologies, the present invention has the following advantages:
[0024] First, the present invention uses a signed 8-bit integer quantized fully connected layer as the network framework of the autoencoder for hyperspectral image anomaly detection, overcoming the defects of the existing autoencoder with network parameter data type of signed 32-bit floating-point numbers, such as low operation efficiency and difficulty in learning on edge devices with limited hardware resources. Compared with the network with signed 32-bit floating-point network parameters, the autoencoder with signed 8-bit integer network parameters constructed by the present invention only needs fewer bits to represent, less parameter calculation time, and less hardware resources to perform operations, which improves the operation rate of the autoencoder network and the effectiveness of quantization learning on edge devices with limited hardware resources.
[0025] Second, the present invention uses an autoencoder with a fully connected layer as the network framework for hyperspectral image anomaly detection, overcoming the deficiency of low detection accuracy caused by the complex network structure composed of multiple cascaded convolutional layers in the existing technologies, which improves the detection accuracy of anomaly targets. Description of the Drawings
[0026] Figure 1 is the implementation flowchart of the present invention;
[0027] Figure 2 is the simulation diagram of the present invention. Detailed Embodiments
[0028] The present invention will be further described in detail below with reference to the drawings and embodiments.
[0029] Refer to Figure 1 to further describe in detail the implementation steps of the embodiments of the present invention.
[0030] Step 1: Generate a dimensionality-reduced spectral matrix.
[0031] Arrange the values from the first row to the last row of each channel's two-dimensional image in a hyperspectral image to be detected as the values of each column in the spectral matrix and normalize the spectral matrix; where, z i represents the i-th pixel in the hyperspectral image to be detected, i = 1, 2,..., L, and L = M × N represents the number of pixel points, and M, N, and B respectively represent the number of row pixels, column pixels, and channels of Z. Denote the set of real numbers as \( \mathbb{R} \), and \( \mathbb{Q} \) j denote a spectral vector formed by arranging the values of the \( j \)-th row of the spectral matrix.
[0032] Step 2. Construct an autoencoder network.
[0033] Step 2.1, Design a signed 8-bit integer quantization fully connected layer.
[0034] Step 2.1.1, Use the torch.nn.Linear function to construct a fully connected layer.
[0035] Step 2.1.2, Based on the fully connected layer structure in Step 2.1.1, construct the forward propagation module of the signed 8-bit integer quantization fully connected layer.
[0036] Step 2.1.2.1, Use the formula to calculate the input quantization scale factor of the fully connected layer, the weight quantization scale factor of the fully connected layer, the input quantization matrix of the fully connected layer, and the weight quantization matrix of the fully connected layer; where \( x \) scale denotes the input quantization scale factor of the fully connected layer, \( x \) max denotes the maximum value of the elements of the input matrix of the fully connected layer, \( x \) min denotes the minimum value of the elements of the input matrix of the fully connected layer, \( n \) represents the number of quantization bits, \( n = 8 \), \( w \) scale denotes the weight quantization scale factor of the fully connected layer, \( w \) max denotes the maximum value of the elements of the weight matrix of the fully connected layer, \( w \) min denotes the minimum value of the elements of the weight matrix of the fully connected layer, \( X \) q denotes the input quantization matrix of the fully connected layer, the torch.round(·) function means rounding each element of its input to the nearest integer, \( X \) represents the input matrix of the fully connected layer, \( x \) scale denotes the input quantization scale factor of the fully connected layer, \( W \) q denotes the weight quantization matrix of the fully connected layer, \( W \) represents the weight matrix of the fully connected layer, \( w \) scale denotes the weight quantization scale factor of the fully connected layer; for example, if the input matrix \( X \) of the fully connected layer is \([1, 2; 3, 4]\), then \( x \) min and \( x \) max are 1 and 4 respectively, and if the weight matrix \( W \) of the fully connected layer is \([5, 6; 7, 8]\), then \( w \) min and \( w \) max are 5 and 8 respectively.
[0037] Step 2.1.2.2, Use \( Y \) q \( = \) torch.mm(X q , W q ) formula to calculate the dot product matrix of the input quantization matrix of the fully connected layer and the weight quantization matrix of the fully connected layer; where \( Y \)q Denote the dot product matrix of the fully connected layer input quantization matrix and the fully connected layer weight quantization matrix. The torch.mm(·, ·) function represents taking the dot product of its two inputs, X q represents the fully connected layer input quantization matrix, and W q represents the fully connected layer weight quantization matrix.
[0038] Step 2.1.2.3, use Y deq = Y q *(x scale * w scale ) formula to calculate the dequantization matrix of the dot product matrix of the fully connected layer input quantization matrix and the fully connected layer weight quantization matrix, and pass the dequantization matrix Y deq to the next-level network; where Y deq represents the dequantization matrix of the dot product matrix of the fully connected layer input quantization matrix and the fully connected layer weight quantization matrix, Y q represents the dot product matrix of the fully connected layer input quantization matrix and the fully connected layer weight quantization matrix, * represents multiplication, x scale represents the fully connected layer input quantization scale factor, and w scale represents the fully connected layer weight quantization scale factor.
[0039] The forward propagation module is implemented using the following formula:
[0040]
[0041] where Y deq represents the output matrix of the forward propagation module, dot(·, ·) represents the dot product operation, R(·) represents the rounding operation, X represents the input matrix of the forward propagation module, and x max represents the maximum value of the elements of the input matrix of the forward propagation module, x min represents the minimum value of the elements in the input matrix of the forward propagation module, n represents the number of quantization bits, n = 8, W represents the fully connected layer weight matrix, and w max represents the maximum value of the elements of the fully connected layer weight matrix, and w min represents the minimum value of the elements of the fully connected layer weight matrix.
[0042] Step 2.1.3, based on the fully connected layer structure in Step 2.1.1, construct a signed 8-bit integer quantization fully connected layer backpropagation module.
[0043] Step 2.1.3.1, use formula to calculate the quantization scale factor of the fully connected layer backpropagation gradient and the fully connected layer backpropagation gradient quantization matrix; where d scale represents the quantization scale factor of the fully connected layer backpropagation gradient, and d maxThe maximum value of the elements of the backpropagation gradient matrix of the fully connected layer, d min represents the minimum value of the elements of the backpropagation gradient matrix of the fully connected layer, n represents the number of quantization bits, n = 8, D q represents the backpropagation gradient quantization matrix of the fully connected layer. The torch.round(·) function rounds each element of its input to the nearest integer. D represents the backpropagation gradient matrix of the fully connected layer, d scale represents the input quantization scale factor of the fully connected layer.
[0044] Step 2.1.3.2, use X Gq = torch.mm(D q , W q Τ ), W Gq = torch.mm(X q Τ , D q ) and the formula to calculate the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the input quantization matrix of the fully connected layer, and the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the weight quantization matrix of the fully connected layer; where X Gq represents the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the input quantization matrix of the fully connected layer. The torch.mm(·, ·) function performs the dot product of its two inputs. D q represents the backpropagation gradient quantization matrix of the fully connected layer, W q represents the weight quantization matrix of the fully connected layer, Τ represents the transpose of the matrix, and W Gq represents the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the weight quantization matrix of the fully connected layer. X q represents the input quantization matrix of the fully connected layer.
[0045] Step 2.1.3.3, use X Gdeq = X Gq *(d scale * w scale ), W Gdeq = W Gq *(x scale * d scale ) formula to calculate the dequantization matrix of the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the input quantization matrix of the fully connected layer, and the dequantization matrix of the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the weight quantization matrix of the fully connected layer; where X Gdeq represents the dequantization matrix of the dot product matrix of the backpropagation gradient quantization matrix and the transposed matrix of the input quantization matrix of the fully connected layer. X Gq represents the input quantization gradient matrix of the fully connected layer. * represents multiplication. d scale represents the quantization scale factor of the backpropagation gradient of the fully connected layer, w scaleDenote the quantization scale factor of the fully connected layer weights, W Gdeq Denote the dequantization matrix of the dot product matrix of the backpropagated gradient quantization matrix and the transpose matrix of the fully connected layer weight quantization matrix, W Gq Denote the fully connected layer weight quantization gradient matrix, x scale Denote the quantization scale factor of the fully connected layer input.
[0046] Step 2.1.3.3, replace the fully connected layer weight matrix with the dequantization matrix of the dot product matrix of the backpropagated gradient quantization matrix and the transpose matrix of the fully connected layer weight quantization matrix W Gdeq Update the network weights, and dequantize the dot product matrix of the backpropagated gradient quantization matrix and the transpose matrix of the fully connected layer input quantization matrix X Gdeq Send it back to the previous-level network.
[0047] The backpropagation module is implemented using the following formula:
[0048]
[0049]
[0050] where, X Gdeq Denote the gradient matrix output by the backpropagation module, D denote the input matrix of the backpropagation module, d max Denote the maximum value of the elements of the input matrix of the backpropagation module, d min Denote the minimum value of the elements of the input matrix of the backpropagation module, Τ denote the transpose operation, W Gdeq Denote the weight matrix of the output of the backpropagation module.
[0051] Step 2.2, use the signed 8-bit integer quantization fully connected layer to construct an autoencoder network composed of an encoder and a decoder connected in series.
[0052] Step 2.2.1, build an encoder, whose structure is in turn: the first encoding quantization fully connected layer, the first encoding activation layer, the second encoding quantization fully connected layer, the second encoding activation layer, the third encoding quantization fully connected layer, the third encoding activation layer; among them, the structures of the first to third encoding quantization fully connected layers are the same, all using the signed 8-bit integer quantization fully connected layer, the structures of the first to third encoding activation layers are the same, all using the ReLU function, and the input of the first encoding quantization fully connected layer is the spectral matrix in step 1;
[0053] Set the parameters of the encoder as follows: set the input channel parameters of the first to third encoding quantization fully connected layers to the number of channels of the hyperspectral image to be detected, 128, and 64 respectively, and set the output channel parameters of the first to third encoding quantization fully connected layers to 128, 64, and 20 respectively;
[0054] Step 2.2.2: Build a decoder, whose structure is as follows in sequence: the first decoding quantization fully-connected layer, the first decoding activation layer, the second decoding quantization fully-connected layer, the second decoding activation layer, the third decoding quantization fully-connected layer, and the sigmoid layer. Among them, the structures of the first to third decoding quantization fully-connected layers are the same, all using signed 8-bit integer quantization fully-connected layers; the structures of the first to second decoding activation layers are the same, all using the ReLU function; the sigmoid layer is implemented using the sigmoid function, and the output of the sigmoid layer is the reconstructed spectral matrix. Q jr represents a spectral vector formed by arranging the values of the j-th row of the reconstructed spectral matrix, represents the set of real numbers, j = 1, 2,..., L, where L represents the number of pixel points in the hyperspectral image in Step 1, and B represents the number of channels of the hyperspectral image in Step 1 respectively;
[0055] Set the parameters of the decoder as follows: set the input channel parameters of the first to third decoding quantization fully-connected layers to 20, 64, and 128 respectively, and set the output channel parameters of the first to third encoding quantization fully-connected layers to 64, 128, and the number of channels of the hyperspectral image to be detected respectively;
[0056] Step 3. Train the autoencoder network.
[0057] Step 3.1: Set the optimization algorithm and basic parameters for training the autoencoder network. Among them, use the SGD optimization algorithm for training, set the learning rate to 0.1, and set the number of training iterations to 5000.
[0058] The setting of the optimization algorithm and basic parameters for training the autoencoder network is as follows: use the SGD optimization algorithm for training, set the learning rate to 0.1, and set the number of training iterations to 5000.
[0059] Step 3.2: Input the spectral matrix in Step 1 into the autoencoder network to output a reconstructed spectral matrix with a shape of [L, B], and iteratively update the network parameters of the autoencoder. Among them, L represents the number of pixel points in the hyperspectral image in Step 1, and B represents the number of channels of the hyperspectral image in Step 1.
[0060] Step 3.3: Determine whether the loss value of the reconstruction error function of the spectral matrix and the reconstructed spectral matrix satisfies the convergence condition. If so, execute Step 3.4; otherwise, execute Step 3.2. Among them, the convergence condition is as follows:
[0061]
[0062] Among them, loss represents the loss value of the reconstruction error function, ∑ represents the summation operation, j = 1, 2,..., L, where L represents the number of pixel points in the hyperspectral image in step 1, k = 1, 2,..., B, where B represents the number of channels in the hyperspectral image in step 1, (·) 2 represents squaring, Q jk represents the element value at the j-th row and k-th column in the spectral matrix, Q ruv t represents the element value at the u-th row and v-th column in the reconstructed spectral matrix obtained from the t-th iteration training, and the values of j and k are respectively equal to the corresponding values of u and v.
[0063] The reconstruction error functions of the spectral matrix and the reconstructed spectral matrix are as follows:
[0064]
[0065] Among them, loss represents the loss value of the reconstruction error function, ∑ represents the summation operation, j = 1, 2,..., L, where L represents the number of pixel points in the hyperspectral image in step 1, k = 1, 2,..., B, where B represents the number of channels in the hyperspectral image in step 1, Q jk represents the element value at the j-th row and k-th column in the spectral matrix, Q ruv t represents the element value at the u-th row and v-th column in the reconstructed spectral matrix obtained from the t-th iteration training, and the values of j and k are respectively equal to the corresponding values of u and v.
[0066] Step 3.4, save the trained autoencoder network model, and load the model to obtain the trained autoencoder network.
[0067] Step 4. Perform anomaly detection on the hyperspectral image.
[0068] Step 4.1 Input the spectral matrix in step 1 into the autoencoder network trained in step 3.4 to obtain the reconstructed spectral result matrix Among them, Q routi represents a reconstructed spectral result vector formed by arranging the values of the u-th row in the reconstructed spectral result matrix, and the value of j is equal to the value of u.
[0069] Step 4.2 Take the element-wise difference between the spectral matrix and the reconstructed spectral result matrix to obtain the reconstruction error matrix, calculate the two-norm value of each row of the reconstruction error matrix, arrange the L two-norm values in a row to form a two-norm value matrix with the shape of [M, N], and use the plt.imshow function to plot this two-norm value matrix into an anomaly image with the shape of [M, N] and save the anomaly image using plt.savefig.
[0070] The effects of the present invention will be further described below in conjunction with simulation experiments:
[0071] 1. Simulation experiment conditions:
[0072] The hardware platform for the simulation experiment of the present invention is as follows: The processor is an Inter i7 10700CPU with a main frequency of 2.9GHz and a memory of 16GB.
[0073] The software platform for the simulation experiment of the present invention is: Windows 10 operating system and python3.9.
[0074] The edge device for the simulation experiment of the present invention is a Raspberry Pi 4B: The processor is a Broadcom BCM2711, 1.5GHz, 64-bit, 4 cores, ARM Cortex-A72 architecture, 1MB shared L2 cache, and the RAM is 1, 2, 4GB LPDDR4-3200 RAM.
[0075] The input image used in the simulation experiment of the present invention is the Coast hyperspectral image. The Coast hyperspectral image is collected from the airborne visible / infrared imaging spectrometer AVIRIS. The image size is 100×100×207 pixels. The image contains a total of 207 bands, and the image format is mat.
[0076] 2. Simulation content and result analysis:
[0077] In simulation experiment 1 of the present invention, the method of the present invention is used to perform anomaly detection on the input Coast hyperspectral image on the software platform and the edge device respectively to obtain an anomaly image.
[0078] In simulation experiment 2 of the present invention, an existing technology is used to perform anomaly detection on the input Coast hyperspectral image on the software platform to obtain an anomaly image.
[0079] In the simulation experiment, an existing technology used refers to:
[0080] An anomaly detection method for hyperspectral images disclosed by Xi'an University of Technology in its patent document "A Hyperspectral Anomaly Detection Method Based on a Fully Convolutional Cascade Autoencoder" (Patent Application No.: CN202110621623.0, Publication No.: CN113379859A).
[0081] In order to verify the effect of the improved fully connected layer of the present invention, the operation time consumption of the signed 8-bit integer quantization fully connected layer constructed by the present invention and the fully connected layer of the existing technology (see the description of the fully connected layer in step 2.1.1 of the "Specific Embodiments" of the present invention) is compared on the software platform.
[0082] The following further describes the effects of the present invention in conjunction with Figure 2 the following.
[0083] Figure 2 (a) is the abnormal target label image of the Coast hyperspectral image, Figure 2 (b) is the result image of abnormal detection of the Coast hyperspectral image on the software platform using the prior art, Figure 2 (c) is the result image of abnormal detection of the Coast hyperspectral image on the software platform using the method of the present invention, Figure 2 (d) is the result image of abnormal detection of the Coast hyperspectral image on the edge device side using the method of the present invention.
[0084] From Figure 2 (b), Figure 2 (c) and Figure 2 (d), it can be seen that the method of the present invention has the same accuracy for abnormal detection on the software platform and the edge device side with limited hardware resources, has a higher degree of abnormal detection for most pixel points of the abnormal label image, and the detected abnormal image has a more obvious spatial structure visually and is closer to the label image, proving that the present invention not only has better abnormal detection effect than the prior art, but also overcomes the defect that it is difficult to learn on the edge device side with limited hardware resources in the prior art.
[0085] When the spectral matrix (see the description of the spectral matrix in step 1 of the "Detailed Embodiment" of the present invention) is input to the autoencoder network of the present invention for training on the software platform, from the first training cycle to the two-hundredth training cycle, the time taken to calculate the dot product of the input of the signed 8-bit integer quantization fully connected layer and the weights is 1.0934 seconds; when the fully connected layer in the autoencoder network of the present invention is replaced with the fully connected layer of the prior art to obtain a general autoencoder network, and the spectral matrix is input to the general autoencoder network for training on the software platform, from the first training cycle to the two-hundredth training cycle, the time taken to calculate the dot product of the input of the fully connected layer of the prior art and the weights is 1.1750 seconds. It can be seen that the operation time of the operation based on the signed 8-bit integer quantization fully connected layer constructed by the present invention is less than that of the fully connected layer of the prior art. The low-precision network parameters require fewer bits to represent, less parameter calculation time, and less hardware resources to perform operations than the high-precision network parameters, which makes the present invention improve the operation rate of the autoencoder network and the effectiveness of quantization learning on the edge device side with limited hardware resources.
[0086] The evaluation index AUC is used to evaluate the abnormal detection results of the present invention and the prior art. The calculation formula of the AUC value is as follows:
[0087]
[0088] Where \(f(x)\) is the receiver operating characteristic (ROC) curve equation of the detection results of the autoencoder network on the hyperspectral image to be detected, and the meaning of the AUC index is to calculate the area under the entire ROC curve.
[0089] Table 1. Comparison table of AUC between the present invention and the prior art in the simulation experiment
[0090]
[0091] Based on the data in Table 1, it can be seen that for the hyperspectral image target detection method of the present invention, the detection accuracy on both the software platform and the edge device side is 0.9993, and this index is higher than that of the prior art, which proves that the present invention can obtain higher hyperspectral image anomaly detection accuracy.
[0092] The above simulation experiments show that: the present invention constructs a signed 8-bit integer quantization fully connected layer, and constructs an autoencoder network based on this fully connected layer, overcoming the defects of the autoencoder with the network parameter data type of signed 32-bit floating-point numbers in the prior art, such as low operation efficiency and difficulty in learning on the edge device side with limited hardware resources. The network parameters of signed 8-bit integers only need fewer bits to represent, less parameter calculation time, and less hardware resources to perform operations, improving the operation rate of the autoencoder network and the effectiveness of quantization learning on the edge device side with limited hardware resources, and improving the accuracy of hyperspectral image anomaly detection.
Claims
1. A hyperspectral image anomaly detection method based on quantization learning, characterized in that, Design a signed 8-bit integer quantization fully connected layer and construct an autoencoder network based on quantization learning. The steps of this anomaly detection method are as follows: Step 1, generate a dimensionality-reduced spectral matrix: Arrange the pixels from the first row to the last row of each channel's two-dimensional image in a hyperspectral image to be detected row by row, and obtain each column in the spectral matrix after dimensionality reduction. Normalize the spectral matrix. Step 2, construct an autoencoder network: Step 2.1, use the torch.nn.Linear function to construct a fully connected layer. Based on the fully connected layer structure, construct the forward propagation module and the backward propagation module of the signed 8-bit integer quantization fully connected layer respectively. Step 2.2, use the signed 8-bit integer quantization fully connected layer to construct an autoencoder network composed of an encoder and a decoder in series. Step 2.2.1, build the encoder. Its structure is in turn: the first encoding quantization fully connected layer, the first encoding activation layer, the second encoding quantization fully connected layer, the second encoding activation layer, the third encoding quantization fully connected layer, the third encoding activation layer. Among them, the structures of the first to third encoding quantization fully connected layers are the same, all using the signed 8-bit integer quantization fully connected layer, and the structures of the first to third encoding activation layers are the same, all using the ReLU function. Set the parameters of the encoder as follows: set the input channel parameters of the first to third encoding quantization fully connected layers to the number of channels of the hyperspectral image to be detected, 128, and 64 respectively, and set the output channel parameters of the first to third encoding quantization fully connected layers to 128, 64, and 20 respectively. Step 2.2.2, build the decoder. Its structure is in turn: the first decoding quantization fully connected layer, the first decoding activation layer, the second decoding quantization fully connected layer, the second decoding activation layer, the third decoding quantization fully connected layer, the sigmoid layer. Among them, the structures of the first to third decoding quantization fully connected layers are the same, all using the signed 8-bit integer quantization fully connected layer, the structures of the first to second decoding activation layers are the same, all using the ReLU function, and the sigmoid layer is implemented using the sigmoid function. Set the parameters of the decoder as follows: set the input channel parameters of the first to third decoding quantization fully connected layers to 20, 64, and 128 respectively, and set the output channel parameters of the first to third encoding quantization fully connected layers to 64, 128, and the number of channels of the hyperspectral image to be detected respectively. Step 3, train the autoencoder network: Step 3.1, set the optimization algorithm and basic parameters for training the autoencoder network. Step 3.2, input the spectral matrix in Step 1 into the autoencoder network, output the reconstructed spectral matrix, and iteratively update the network parameters of the autoencoder until the loss value of the reconstruction error function between the spectral matrix and the reconstructed spectral matrix is less than or equal to 0.0011, and obtain the trained autoencoder network. Step 4, perform anomaly detection on the hyperspectral image: Step 4.1, input the spectral matrix in Step 1 into the trained autoencoder network to obtain the reconstructed spectral result matrix. Step 4.2: Element-wise subtract the spectral matrix from the reconstructed spectral result matrix to obtain a reconstruction error matrix. Calculate the two-norm value of each row in the reconstruction error matrix, arrange all the two-norm values in a row to form a two-norm value matrix, plot this two-norm value matrix, and save the abnormal image.
2. The hyperspectral image anomaly detection method based on quantization learning according to claim 1, wherein, The forward propagation module described in Step 2.1 is implemented using the following formula: Among them, Y deq represents the output matrix of the forward propagation module, dot(·, ·) represents the dot product operation, R(·) represents the rounding operation, X represents the input matrix of the forward propagation module, and x max represents the maximum value of the elements of the input matrix of the forward propagation module, and x min represents the minimum value of the elements in the input matrix of the forward propagation module, n represents the number of quantization bits, n = 8, W represents the fully connected layer weight matrix, and w max represents the maximum value of the elements of the fully connected layer weight matrix, and w min represents the minimum value of the elements of the fully connected layer weight matrix.
3. The hyperspectral image anomaly detection method based on quantization learning according to claim 2, characterized in that, The backward propagation module described in Step 2.1 is implemented using the following formula: Among them, X Gdeq represents the gradient matrix output by the backpropagation module, D represents the input matrix of the backpropagation module, d max represents the maximum value of the elements of the input matrix of the backpropagation module, d min represents the minimum value of the elements of the input matrix of the backpropagation module, Τ represents the transpose operation, W Gdeq represents the weight matrix of the output of the backpropagation module.
4. The hyperspectral image anomaly detection method based on quantization learning according to claim 1, characterized in that, The optimization algorithm and basic parameters for setting the training of the autoencoder network in Step 3.1 are as follows: The SGD optimization algorithm is used for training optimization, the learning rate is set to 0.1, and the number of training iterations is set to 5000.
5. The hyperspectral image anomaly detection method based on quantization learning according to claim 1, characterized in that, The reconstruction error function of the spectral matrix and the reconstructed spectral matrix in Step 3.2 is as follows: Among them, loss represents the loss value of the reconstruction error function, ∑ represents the summation operation, j = 1, 2,..., L, where L represents the number of pixel points of the hyperspectral image in step 1, k = 1, 2,..., B, where B represents the number of channels of the hyperspectral image in step 1, Q jk represents the element value of the j-th row and k-th column in the spectral matrix, Q ruv t represents the element value of the u-th row and v-th column in the reconstructed spectral matrix obtained by the t-th iterative training, and the value ranges of j and k are respectively equal to those of u and v.
Citation Information
Patent Citations
Hyperspectral image anomaly detection method based on full convolution auto-encoder
CN112598636A
Hyperspectral anomaly detection method based on full convolution cascade auto-encoder
CN113379859A
Hyperspectral anomaly detection method based on spectrum-preserving sparse auto-encoder
CN111461087A
Hyperspectral anomaly detection method based on spatial-spectral depth collaboration
CN114445720A