A deep learning model using convolutional neural networks and conditional generative adversarial networks with multi-head attention for stock prediction
Stock prediction utilizing machine learning and deep learning models has attracted increasing attention in recent years. While recent research has made substantial progress in stock forecasting, many existing models perform inconsistently across markets and are sensitive to random initialization settings, which raises concerns about their robustness, generalizability, and practical applications. To address these issues, we propose ATTention-integrated Convolutional Neural Network-based Conditional Generative Adversarial Network (ATTCNN-CGAN), which leverages real historical samples as inputs to the generator, enabling more deterministic forecasting. Moreover, conventional generative adversarial networks (GANs) often employ recurrent generators that rely on sequential hidden state propagation, which can lead to longer gradient paths and may complicate adversarial optimization. Our approach utilizes convolutional neural networks (CNNs) for both the generator and the discriminator, which avoids the recurrent state propagation and extracts local temporal patterns in parallel, thereby enhancing training stability. Experiments on nine US large-cap stocks, conducted across multiple input lengths and random seeds, demonstrate that ATTCNN-CGAN achieves improved mean predictive performance compared to strong baselines under the tested configurations and exhibits more consistent performance across stocks. Furthermore, ablation studies suggest that the multi-head attention feature extraction, enhanced by the innovative dual-average aggregation strategy, boosts optimized feature representations and the forecasting performance. The findings highlight the potential of multi-head attention enhanced with diverse aggregation strategies for time-series forecasting.