Multi-Scale Attention with Dense Encoder for Handwritten Mathematical Expression Recognition

Jianshu Zhang, Jun Du, Lirong Dai

Introduction

Handwritten Mathematical Expression Recognition (HMER) presents unique challenges compared to standard optical character recognition. Beyond the inherent ambiguity of handwriting, mathematical notation is non-linear—featuring subscripts, superscripts, and fractions—and exhibits extreme scale variance. A large integral symbol may coexist with a tiny decimal point or a small digit in an exponent.

Existing "Watch, Attend and Parse" (WAP) models often suffer from "under-parsing." Standard Convolutional Neural Networks (CNNs) utilize pooling layers to extract abstract features, but these operations can inadvertently eliminate small symbols. If a decimal point is reduced to a single pixel or vanishes in the feature map, the attention mechanism fails to recognize it, leading to incorrect LaTeX output. This paper proposes a DenseNet-based encoder and a Multi-Scale Attention (MSA) mechanism to address these issues.

Proposed Methodology

Dense Encoder

The authors replace traditional VGG-style encoders with a DenseNet architecture. In a DenseNet, each layer receives feature maps from all preceding layers, promoting feature reuse and improving gradient flow. This architecture is particularly effective for HMER, where training datasets like CROHME are relatively small, as the dense connectivity acts as a form of regularization.

Multi-Scale Attention (MSA)

To mitigate the loss of fine-grained information caused by pooling, the model introduces a branched encoder. The Main Branch provides high-level semantic features at a lower resolution. The Multi-Scale Branch is extracted before the final pooling layer, preserving spatial details that are typically lost.

Architecture of the proposed Dense Encoder with Multi-Scale Branch.

The decoder, based on a Gated Recurrent Unit (GRU), employs dual attention models to process both resolutions simultaneously. By concatenating the context vectors from both branches, the model can maintain a global structural view while attending to minute details.

Key Insights and Results

The effectiveness of the MSA mechanism is most evident when visualizing attention maps. As shown in the figure below, the low-resolution branch often overlooks small symbols or misidentifies strokes. In contrast, the high-resolution branch correctly localizes and identifies these features, "saving" the final prediction.

Visualization of attention maps comparing low-resolution and high-resolution branches for small symbols and complex strokes.

The "Dense+MSA" model was evaluated on the CROHME 2014 and 2016 benchmarks, significantly outperforming previous state-of-the-art methods. On CROHME 2014, the model achieved an expression recognition rate (ExpRate) of 52.8%, a substantial improvement over the 44.4% baseline. Ablation studies confirmed that while the DenseNet encoder provided a ~6% accuracy boost, the addition of MSA contributed an additional ~3%.

Conclusion

By combining the feature-rich representations of DenseNet with a multi-scale attention strategy, the proposed model effectively tackles the under-parsing problem in HMER. While challenges remain—such as the strict "all-or-nothing" nature of mathematical expression accuracy and the computational cost of dual-branch attention—this work sets a new standard for robust handwritten math recognition.

Summary updated

BibTeX
@inproceedings{zhang2018multi,
  author = {Jianshu Zhang and Jun Du and Lirong Dai},
  title = {{Multi-Scale Attention with Dense Encoder for Handwritten Mathematical Expression Recognition}},
  booktitle = {ICPR},
  year = {2018},
  url = {https://openreview.net/forum?id=AYyIb9G7a9},
}
Figure