Wavenumber-Aware Deep Learning for Robust Analysis of Raman Spectra
Authors: Jihwan Kim, Jaeseong Heo, Yujin Kim, Sang Bin Yoon, Chanjoong Kim, Kwang-Im Oh, Hyon Bin Na, Kyungwon Kwak, Myeongkee Park, Joonyoung F. Joung
Organizations: Department of Chemistry, Kookmin University, 77 Jeongneung-ro, Seongbuk-gu, Seoul, 02707, Republic of Korea. · BB21+, Department of Chemistry, Pukyong National University, Busan, 48513, Republic of Korea. · Department of Chemical Engineering, Myongji University, Yongin, 17058, Republic of Korea. · School of Artificial Intelligence, Kookmin University, 77 Jeongneung-ro, Seongbuk-gu, Seoul, 02707, Republic of Korea. · Institute of Basic Science, Korea University, Seoul, 02841, Republic of Korea. · Center for Molecular Spectroscopy and Dynamics, Institute for Basic Science (IBS), Korea University, Seoul, 02841, Republic of Korea. · Department of Chemistry, Korea University, Seoul, 02841, Republic of Korea.
Machine-learning models for spectroscopy usually treat a spectrum as a fixed-grid intensity vector, leaving the physical coordinate implicit in the array index. Such models are tied to a single sampling grid, spectral range and resolution, which limits their use when measurement conditions change. Here we represent each spectral point as a pair of intensity and wavenumber and compute Transformer positional encodings from the wavenumber itself. On Raman spectra of three bacterial species and their synthetic mixtures, this representation remained robust to noise, sparser sampling and partial spectral coverage across convolutional, residual and Transformer networks. In controlled comparisons, wavenumber-based encoding outperformed index-based and learned encodings under partial observation and retained its performance on sampling grids never seen during training, where index-based encoding degraded. These findings were reproduced on a public 30-isolate bacterial benchmark. Explicit physical coordinates offer a simple route to robust spectral analysis under variable measurement conditions.
Figures & tables
Figure 1: Overview of spectral variability and representation strategies for Raman data. (a) Raman spectra acquired under varying measurement conditions, including differences in sampling density or resolution and partial observation due to missing or unreliable regions. (b) Conventional fixed-grid representations encode spectra as one-dimensional signals with implicitly defined wavenumber coordinates, requiring a fixed discretization and full spectral coverage. Such representations are not well suited for spectra with varying sampling densities or incomplete observations. (c) Proposed wavenumber-aware representation, where spectral intensity ( I ) and corresponding wavenumber ( ω ) are explicitly incorporated as separate input channels. This formulation enables flexible handling of varying sampling densities and partial spectral inputs without relying on a fixed discretization.
Figure 2: Data generation and augmentation pipeline for realistic Raman spectral modeling. (a) Measured Raman spectra of three bacterial species, illustrating characteristic spectral features and the presence of missing regions. (b) Synthetic mixture of two species generated by combining individual spectra with randomly sampled mixing ratios, enabling the modeling of spectral overlap. (c) Additive Gaussian noise applied to simulate experimental variability and environmental perturbations. (d) Downsampling of spectra to mimic reduced spectral resolution and sparse sampling conditions. (e) Segmentation of spectral regions to represent partial observation, reflecting scenarios where only limited spectral windows are available. (f) Combined spectral degradation incorporating downsampling, partial observation, and noise, simulating realistic sensing conditions encountered in field-deployed or portable Raman systems.
Figure 3: Comparison of neural network architectures operating on the proposed wavenumber-aware Raman representation. (a) CNN architecture for local spectral feature extraction using one-dimensional convolutions. (b) ResNet architecture employing residual blocks for hierarchical multi-scale spectral learning. (c) Transformer architecture treating each spectral point as an individual token and incorporating physical wavenumber information through positional encoding. All three architectures operate on the same wavenumber-aware representation, allowing differences in performance to be attributed to the learning architecture rather than the input representation.
CNN
ResNet
Transformer
Scenario
Exact
F1 micro
Exact
F1 micro
Exact
F1 micro
Unperturbed
79.95
93.68
81.48
94.27
80.02
93.78
Noise only
78.74
93.18
79.48
93.54
77.88
92.98
Noise + Slice
59.98
85.61
64.02
87.52
64.94
87.65
Noise + Downsample
73.82
91.33
74.75
91.78
73.59
91.31
Noise + Slice + Downsample
59.05
85.25
61.00
86.06
61.61
86.25
Table 1: Performance comparison of CNN, ResNet, and Transformer models. The best performance under each scenario is highlighted in bold.
Figure 4: Sliding-window analysis of spectral-region dependence in Transformer-based classification. Macro F1 scores were evaluated using moving windows of 128, 256, and 512 cm -1 , plotted against the window center wavenumber. The gray trace represents the mean Raman spectrum averaged over all bacterial samples.
Dataset (metric)
Scenario
Constant
Index
Learned
Wavenumber
In-house mixtures (F1 micro )
Unperturbed
86.39
93.37
88.54
93.78
Noise+Slice
77.72
81.69
76.93
87.65
Noise+Slice+Downsample
77.79
81.77
77.23
86.25
Benchmark single spectra (Top-1)
Unperturbed
27.28
93.96
92.54
95.90
Noise+Slice
19.43
42.82
24.81
73.91
Noise+Slice+Downsample
18.51
49.30
45.19
58.36
Table 2: Comparison of positional-encoding schemes under identical data, augmentation, and training conditions on the in-house dataset and on the public benchmark of Ho et al. (Transformer, %). All configurations use augmented training. For the in-house dataset, Exact Match results for all five scenarios are provided in Supplementary Table 7, and the remaining scenarios for the constant, index, and wavenumber encodings in Supplementary Table 9. The complete input-representation ablation on the benchmark is provided in Supplementary Table 14.
Scenario
I only
I+ω
I +aug. a
I+ω +aug.
Unperturbed
84.75
95.71
86.39
93.78
Noise+Slice
62.14
61.70
77.72
87.65
Noise+Slice+Downsample
64.97
61.71
77.79
86.25
Table 3: Effect of wavenumber information and data augmentation on Transformer performance (F1 micro , %). I denotes the intensity-only input and ω the explicit wavenumber channel.
Figure 5: Generalization beyond the training distribution under increasingly severe spectral degradation. (a) Effect of reducing the available spectral length from 2048 points to 128 points (roughly 140 cm -1 ). During training, spectra were segmented to lengths between 512 and 2048 points; shorter lengths were evaluated only during testing. (b) Effect of increasing the downsampling factor beyond the training range. The x -axis indicates the percentage of retained sampling points, where 100%, 50%, 33%, 25%, 17%, and 12.5% correspond to downsampling factors of 1, 2, 3, 4, 6, and 8, respectively. Training employed downsampling factors between 1 and 4. (c) Effect of additive Gaussian noise with standard deviation σ . Training used noise levels within σ≤0.05 , whereas larger noise levels were evaluated only during testing. Performance is reported as F1 micro (%).
Scenario
Encoding
Native
1 cm -1
2 cm -1
4 cm -1
In-house dataset
Unperturbed
Wavenumber (proposed)
93.78
93.74
93.68
92.44
Index
93.37
72.50
78.38
82.37
Constant
86.39
85.80
85.64
84.80
Noise+Slice
Wavenumber (proposed)
87.65
88.01
87.47
86.31
Index
81.69
79.37
79.80
81.37
Table 4: Generalization to sampling grids whose wavenumber values never appear during training (Transformer, synthetic mixtures, F1 micro , %). Evaluation spectra were resampled onto uniform grids with the indicated spacing; “native” denotes the original measurement grid (in-house: nonuniform, 0.84–1.10 cm -1 ; benchmark: uniform, about 1.41 cm -1 ). Complete results are provided in Supplementary Tables 9 and 15.
Neural network robustness studies how models withstand adversarial inputs, data shifts, noise, and hardware faults while maintaining reliable predictions.
Institute of Physical Chemistry (IPC) and Abbe Center of Photonics (ACP), Friedrich Schiller University Jena, Member of the Leibniz Centre for Photonics in Infection Research (LPI), Helmholtzweg 4, 07743, Jena, Germany