Risk stratification of myocardial infarction (MI) in individuals without prevalent cardiovascular disease is crucial for early intervention and prevention. ECG-based models, enabled by artificial intelligence, show promise when predicting cardiovascular events. However, current methods remain limited. We hypothesized that performance of models could improve if the input data was presented in a matrix format, enabling the model to extract more relevant features from the same signal. We designed two Convolutional Neural Networks for predicting MI at 1, 2, 3, 4, 6, 8, 10, and 12 years of follow-up. The first model was designed to take a single-lead ECG as input to then pass through six 1D-convolutional layers, an attentive pooling mechanism and three fully connected layers to generate the 8 predictions. For the second model, we transformed the ECG signal into a representative matrix with four rows, where each row contained a 1.6-second segment of the ECG, aligned to the R-wave peak, including one heartbeat and a portion of the subsequent one. This was used as input for the network, with the convolutional layers adapted from 1D to 2D while keeping the attentive pooling and the three fully connected layers. We evaluated both models using the UK Biobank dataset, comprising 86,567 ECGs. Our proposed 2D-matrix model showed a slightly better performance, sustained across all predictions, with an average AUC increase of 0.021, obtaining the best improvement at 1-year prediction, where the AUC improved from 0.534 (95% CI [0.514-0.555]) to 0.591 (95% CI [0.550-0.632]). These results suggest the model that takes as input the 2D matrix better captures the inter-subject differences on the ECG that are associated with a higher risk of having MI in the future. This work may contribute to improving risk prediction for MI to provide clinicians more accurate and opportune information for decision making.