Official implementation of JLSAE: Joint Low-Rank and Sparse Autoencoder for Hyperspectral Anomaly Detection.
JLSAE jointly models the low-rank structure of the background and the sparse characteristics of anomalies within a unified autoencoder framework. It can be viewed as a further development of Auto-AD and DeepLR.
This repository provides a simple implementation for reproducing and comparing hyperspectral anomaly detection methods.
A standard PyTorch environment is sufficient to run the code.
The main required packages include:
Python
PyTorch
NumPy
SciPy
Matplotlib
A CUDA-enabled PyTorch environment is recommended for GPU acceleration.
Place the test hyperspectral data in the data folder.
Each data file should be stored in MATLAB .mat format and contain the following variables:
data: hyperspectral image datamap: ground-truth anomaly map
An example directory structure is:
JLSAE/
├── data/
│ └── example.mat
├── models/
├── utils/
├── result/
└── train.py
The main folders are organized as follows:
data/: stores the hyperspectral data sets used for testing.result/: stores the generated detection maps, AUC values, or other output results.models/: contains the network architecture of JLSAE.utils/: contains commonly used utility functions, such as data loading, ROC calculation, AUC calculation, and result visualization.figures/: contains the images used in this README, including the framework and detection-result figures.
Before running the code, modify the data file name in train.py:
path = 'data/'
file_name = 'example.mat'Run the following command:
python train.pyThe detection results are automatically saved in the result folder.
The saved .mat file contains:
detection: anomaly detection mapauc: area under the ROC curve
For example:
result/example_result.mat
The following parameters can be adjusted in train.py:
num_iter = 150num_iter controls the number of optimization iterations. The default value for a new data set is 150. It can be adjusted according to the convergence behavior and detection performance.
Recommended candidate values include:
[100, 150, 200, 250, 300]pho = 1pho is the penalty parameter used in the optimization process. If the detection result is unsatisfactory, it can be tuned using values such as:
[1, 1.25, 1.5, 1.75]lam = 0.5lam is the trade-off parameter associated with the sparse anomaly component. It can be adjusted for different data sets to obtain better detection performance.
The network parameters and the input noise tensor Z are randomly initialized for each run. Therefore, the detection results and AUC values may vary slightly across different runs.
![]() Original HSI |
![]() Ground Truth |
![]() Reconstructed Background |
![]() Anomaly Component E |
![]() Detection Map |
Please contact fanjiahui24@mails.ucas.ac.cn if you have any questions about the code or its implementation.
If you find this code helpful, please cite:
@ARTICLE{fan2026jlsae,
author={Fan, Jiahui and Sun, Xiaotong and Wang, Degang and Sun, Xu and Gao, Lianru},
journal={IEEE Transactions on Geoscience and Remote Sensing},
title={JLSAE: Joint Low-Rank and Sparse Autoencoder for Hyperspectral Anomaly Detection},
year={2026},
volume={64},
number={},
pages={5522017-5522017},
keywords={Ranking (statistics);Modeling;Anomaly detection;Optimization;Signal detection;Pixel;Probability;Educational institutions;Personal digital devices;Hyperspectral imaging;Autoencoder (AE);background reconstruction;hyperspectral anomaly detection (HAD);low-rank prior;model-driven deep learning;sparse prior},
doi={10.1109/TGRS.2026.3716370}}





