[Paper Review] Attention-based Neural Bag-of-Features Learning for Sequence Data
This paper proposes 2D-Attention (2DA), a generic attention mechanism that enhances the Neural Bag-of-Features (NBoF) model for sequence data by enabling dynamic, learnable weighting of quantized features across time and codeword dimensions. By integrating 2DA as a plug-in module into NBoF, the model achieves improved performance and robustness on financial forecasting, audio analysis, and medical diagnosis tasks, outperforming standard NBoF and even matching GRU-based models on noisy data.
In this paper, we propose 2D-Attention (2DA), a generic attention formulation for sequence data, which acts as a complementary computation block that can detect and focus on relevant sources of information for the given learning objective. The proposed attention module is incorporated into the recently proposed Neural Bag of Feature (NBoF) model to enhance its learning capacity. Since 2DA acts as a plug-in layer, injecting it into different computation stages of the NBoF model results in different 2DA-NBoF architectures, each of which possesses a unique interpretation. We conducted extensive experiments in financial forecasting, audio analysis as well as medical diagnosis problems to benchmark the proposed formulations in comparison with existing methods, including the widely used Gated Recurrent Units. Our empirical analysis shows that the proposed attention formulations can not only improve performances of NBoF models but also make them resilient to noisy data.
Motivation & Objective
- To address the limitation of standard NBoF models, which treat all quantized features equally during aggregation, leading to suboptimal representation learning in non-stationary, noisy sequence data.
- To develop a generic, plug-and-play attention mechanism that can dynamically assign importance to features across both time steps and codewords in matrix-structured sequence data.
- To improve the representational capacity and robustness of NBoF models in real-world applications involving noisy or imbalanced sequence data, such as financial time series, audio signals, and ECG/phonocardiogram recordings.
- To demonstrate that attention-based NBoF variants consistently outperform baseline NBoF and competitive recurrent models like GRUs across diverse sequence learning tasks.
Proposed method
- Proposes 2D-Attention (2DA), a differentiable attention mechanism that computes attention weights over a 2D feature map formed by time steps and codewords, enabling selective focus on relevant features.
- Integrates 2DA as a lightweight, learnable module that can be inserted at various stages in the NBoF architecture, allowing for flexible design of 2DA-NBoF models with distinct interpretations.
- Uses a multi-head attention mechanism with query, key, and value projections to compute attention scores, followed by softmax normalization to produce attention weights for feature reweighting.
- Applies the learned attention weights to perform a weighted average of the quantized features in the NBoF aggregation step, replacing the standard uniform averaging.
- Trains the entire 2DA-NBoF model end-to-end using stochastic optimization (ADAM), with regularization via weight decay, dropout, and batch normalization.
- Employs a shared codebook across all sequences, with codewords learned jointly during backpropagation to optimize the overall objective function.
Experimental results
Research questions
- RQ1Can a generic, learnable attention mechanism improve the representation power of the Neural Bag-of-Features (NBoF) model for sequence data?
- RQ2Does the proposed 2D-Attention mechanism enhance NBoF’s robustness to noisy and non-stationary sequence data across diverse domains?
- RQ3How do attention-enhanced NBoF variants compare in performance to standard NBoF and established recurrent models like GRUs in financial forecasting, audio analysis, and medical diagnosis?
- RQ4Can the 2DA module be effectively used as a plug-in component in different stages of the NBoF architecture, leading to distinct and interpretable model variants?
Key findings
- The 2DA-NBoF model achieved a mean F1 score of 88.81±1.07 on the AF dataset, significantly outperforming the baseline NBoF (88.68±0.95) and approaching the performance of GRU models.
- On the PCG dataset, the 2DA-NBoF model achieved a sensitivity and specificity mean of 72.34±1.32 and 69.45±0.89, respectively, demonstrating strong performance on noisy medical signal data.
- The attention-based models showed consistent performance gains across all three domains—financial forecasting, audio analysis, and medical diagnosis—indicating generalizability and robustness.
- The 2DA module improved the NBoF model’s resilience to noisy data, with performance gains observed even in imbalanced and non-stationary sequence settings.
- The proposed 2DA-NBoF variants matched or exceeded the performance of GRU-based models in medical diagnosis tasks, despite being simpler and more efficient.
- The ablation study confirmed that the attention mechanism significantly enhanced feature representation, with performance gains observed in both F1 score and balanced accuracy metrics.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.