Skip to content
All library documents

SAMformer: Stabilizing Time-Series Transformers with Sharpness-Aware Training

Article MQL5 articles

Summary

This article explains SAMformer, a compact Transformer approach for long-horizon multivariate time-series forecasting, and describes its proposed remedies for unstable training. The architecture uses channel-wise attention, a residual connection, a linear forecasting layer, and reversible instance normalization. The key optimization method is Sharpness-Aware Minimization (SAM), which updates parameters using gradients from both the current weights and a perturbed neighborhood. The article also outlines an MQL5 implementation that adapts gradient normalization across layers and parameter groups.

The cited paper’s experiments include a synthetic regression task and comparisons with a least-squares oracle and a randomly initialized attention baseline. The authors report that SAM reduces loss sharpness and improves forecasting results, while spectral reparameterization alone does not reach the same performance. The discussion argues that attention entropy collapse may coexist with good results under SAM. The article provides no detailed real-market performance evaluation; its MQL5 implementation is presented as ongoing work, with practical assessment deferred to a later installment.

Key ideas

  • SAMformer simplifies the Transformer to channel-wise attention, a residual connection, and a linear forecasting layer.
  • Sharpness-Aware Minimization uses a perturbed-parameter gradient step to favor flatter regions of the loss landscape.
  • The article reports better synthetic forecasting performance with SAM than with its standard and random-attention comparisons.
  • Reversible instance normalization is included to help address distribution shifts between training and test data.
  • The MQL5 implementation changes gradient normalization details, and its value on real historical data is not evaluated here.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.