Transfer Learning in Financial Time Series with Gramian Angular Field

Hou-Wan Long, On-In Ho, Qi-Qiao He, Yain-Whar Si

Abstract

Deep learning models in financial forecasting often suffer from data scarcity and overfitting. While transfer learning offers a potential solution by leveraging knowledge from related source domains, the risk of "negative transfer"—where dissimilar source data degrades model performance—remains a significant hurdle. This paper presents a novel framework for source domain selection using Gramian Angular Field (GAF) transformations. By converting one-dimensional financial time series into two-dimensional images, the proposed method captures complex non-linear temporal dependencies more effectively than traditional methods. Experimental results on Hong Kong Stock Exchange data demonstrate that GAF-enhanced similarity measures significantly improve the performance of Deep Neural Networks (DNN) and Long Short-Term Memory (LSTM) models in price prediction tasks.

Introduction

Predicting financial markets is notoriously difficult due to the high level of noise and non-stationary nature of price data. Deep learning models, particularly LSTMs and DNNs, require vast amounts of data to generalize effectively. In many cases, specific target stocks lack sufficient historical depth or exhibit unique regimes that lead to overfitting. Transfer learning addresses this by pre-training models on a source domain before fine-tuning on a target domain. However, the success of this approach hinges on the similarity between the source and target. If the domains are poorly aligned, the model may learn irrelevant features, leading to negative transfer. This research explores whether transforming time series into a visual representation can improve the identification of beneficial source domains.

Methodology

Gramian Angular Field (GAF) Transformation

The core innovation lies in the three-step pipeline designed to refine source domain selection. The process begins with the GAF transformation, specifically the Gramian Angular Summation Field (GASF). The 1D time series data is first scaled and transformed into polar coordinates. This transformation preserves the temporal correlations and angular relationships of the price movements. By representing the data as a 2D image, the model can interpret relationships between distant time points as spatial pixels, effectively capturing the "rhythm" of the market.

Similarity Evaluation and Model Training

To identify the most compatible source domains, the researchers evaluated a suite of similarity functions across both raw 1D data and 2D GAF images. These functions included:

  • Euclidean distance and Pearson correlation
  • Maximum Mean Discrepancy (MMD)
  • Central Moment Discrepancy (CMD)
  • Correlation Alignment (CORAL)

Following the selection of the most similar source domains based on these metrics, the models (DNN and LSTM) were pre-trained on the source data and subsequently fine-tuned on the target dataset.

Experimental Setup

Datasets

The study utilized daily closing prices from the Hong Kong Stock Exchange (HKEX) spanning from early 2022 to the end of 2023.

  • Target Dataset: HSBC Holdings (0005.HK).
  • Source Domains:
  • Banking Sector: 10 major bank stocks (e.g., 0939.HK, 1398.HK).
  • Diversified Sector: 10 non-bank stocks from the Hang Seng Index, including technology firms like Tencent (0700.HK) and Meituan (3690.HK).

The data was split using a 7:3 ratio for training and testing purposes.

Key Insights and Results

Superiority of 2D Representations

The experiments confirmed that GAF-enhanced similarity functions consistently outperformed traditional 1D baseline measures. The GAF transformation acts as a natural smoother, highlighting underlying trends and directions of change while mitigating the impact of financial noise. This allows similarity functions to make more reliable domain selections.

Model-Specific Synergies

A key finding was that the effectiveness of a similarity function is highly dependent on the neural architecture used:

  • For DNNs: The Coral (GAF) metric emerged as the most effective for identifying beneficial source domains.
  • For LSTMs: The CMD (GAF) metric proved superior, likely due to its ability to capture higher-order moments in temporal structures.

Quantitative Performance

In the "Bank to Bank" transfer scenario, GAF-based selection led to a marked reduction in prediction errors. For example, using GAF-based CMD reduced the LSTM Mean Absolute Percentage Error (MAPE) from a baseline of 1.4436 to 1.1058. Significant improvements were also observed in Root Mean Square Error (RMSE) and $R^2$ values. In multi-source scenarios involving diverse industries, GAF-based methods (specifically ARE-GAF for LSTMs) continued to show a significant edge in capturing complex temporal patterns.

Conclusion and Future Work

This research demonstrates that GAF transformations provide a robust framework for improving transfer learning in finance. By converting time series into images, the method provides both a quantitative edge in prediction accuracy and a qualitative tool for researchers to visually inspect stock "textures" and similarities.

Future research will focus on exploring other GAF variations, such as Gramian Angular Difference Fields (GADF), and testing the framework on high-frequency trading data. Additionally, there is significant potential in integrating these similarity measures directly into the loss functions of neural networks to automate the domain alignment process during training.

Summary updated

BibTeX
@inproceedings{long2025transfer,
  author = {Hou-Wan Long and On-In Ho and Qi-Qiao He and Yain-Whar Si},
  title = {{Transfer Learning in Financial Time Series with Gramian Angular Field}},
  booktitle = {IJCNN},
  year = {2025},
  doi = {10.1109/ijcnn64981.2025.11227856},
}
Figure