1. Introduction
Accurate energy demand forecasting is a fundamental component of modern power system operations [
1,
2,
3,
4]. It underpins grid stability, generation scheduling, transmission planning, and energy market clearing [
5,
6,
7]. In an era of increasing renewable energy penetration and growing demand-side flexibility, precise and reliable load predictions have never been more critical [
8,
9,
10]. Errors in forecasting can lead to either costly over-generation, supply shortages, or blackouts. Hence, substantial research efforts have been devoted to developing sophisticated forecasting models that can capture the complex, nonlinear, and time-varying characteristics of energy consumption [
11,
12].
Energy demand time series are inherently challenging to predict due to multiple intertwined factors [
13]. These include weather conditions, calendar effects, socio-economic variables, and random behavioral patterns of consumers [
14,
15]. Moreover, the growing integration of distributed energy resources introduces additional volatility and uncertainty [
16]. Traditional statistical methods and machine learning ones have been widely applied to load forecasting [
1,
17]. While computationally efficient, these approaches often struggle to capture the high-dimensional nonlinearities and long-term dependencies present in modern energy demand data [
13]. As alternative solutions, deep learning techniques have become the dominant paradigm in energy demand forecasting [
4,
18]. For example, long short-term memory, and gated recurrent units excel at modeling sequential dependencies [
2,
19]. Convolutional neural networks and graph neural networks, on the other hand, are adept at extracting local patterns and hierarchical features from time series [
14,
20,
21,
22]. As for attention mechanisms and Transformer models, they have also demonstrated promising prospect for energy demand forecasting [
10,
23,
24].
Despite these advances, several challenges remain [
13,
25]. (1) The temporal patterns in energy demand often exhibit dynamic or multi-scale periodicities (daily, weekly, or seasonal) that require adaptive feature extraction [
13,
15]. To address these problems, many related studies have been conducted. For example, ensemble learning has been investigated to integrate multiple models with complementary strengths [
6,
17]. Multi-scale feature decomposition and hybrid algorithm designs have also been explored [
14,
26,
27]. Furthermore, network architectures with multi-scale learning capabilities have been developed [
28,
29,
30]. These methods have been successfully applied to energy-related forecasting problems with complex dynamics. However, they primarily focus on feature extraction algorithms and network architecture design. Although effective, such approaches require careful algorithm design and introduce a large number of learnable parameters, thereby increasing the learning difficulty. Hence, we aim to explore how the intrinsic properties of data can be leveraged to improve algorithmic performance without complex algorithm design. (2) Many existing deep learning models rely on fixed-kernel convolutions [
4,
21], which may not fully adapt to the varying spatial dynamics of the given data. Some targeted solutions have been proposed, such as multi-scale convolutions with different kernel sizes [
18,
30] and multi-sight convolutions based on multi-scale decomposition [
14]. However, these methods still essentially rely on static convolutions, and cannot adaptively adjust parameters according to different inputs. Although dynamic convolution can effectively solve this problem, it is mainly applied to image-related tasks [
31,
32,
33]. Some studies have also applied dynamic convolution to time-series analysis [
34,
35]. However, the application of dynamic convolution in energy demand forecasting is yet to be explored. (3) The hyperparameter configuration of a deep learning algorithm has a profound impact on the algorithmic performance, yet manual tuning is labor-intensive and often suboptimal [
1,
36]. Hence, it is worth investigating how to design and optimize deep learning algorithms for energy demand forecasting.
To address the aforementioned challenges, we propose an input-adaptive dynamic convolution-augmented Transformer, where Bayesian optimization is used to achieve adaptive design. Specifically, we introduce channel, phase, and joint channel–phase embeddings to capture latent periodicities and enrich the feature representation. Moreover, we design an input-adaptive dynamic one-dimensional convolution and integrate it with Transformer, thus enabling flexible feature extraction that adapts to varying energy-related patterns. Finally, we adopt the Tree-Structured Parzen Estimator (TPE) [
37] to adaptively design and optimize our method. Two real-world energy demand forecasting tasks are used to investigate the effectiveness of our method.
As an application-oriented study, our main contribution is to develop an automatically optimized hybrid architecture that integrates input-adaptive dynamic convolution with Transformer for energy demand forecasting. Compared with existing complex feature extraction algorithms [
14,
26,
27,
38], our embedding strategy can capture the latent periodicity within the data and the spatial relationships among variables without complex algorithm design. Compared with existing convolution–Transformer hybrid methods [
18,
30], our method improves both the convolutional computation and the hyperparameter optimization strategy. Our method enables input-dependent adaptive convolution and automated parameter optimization. It has been successfully applied to two real-world energy demand forecasting cases.
The rest of our work is organized as follows.
Section 2 reviews related work.
Section 3 describes the proposed methodology.
Section 4 presents the experiments and results.
Section 5 concludes with a discussion and future research directions.
2. Related Work
Energy demand forecasting research has evolved into several distinct methodological categories [
13,
18,
39]. These include traditional statistical methods, classical machine learning approaches, deep learning architectures, and hybrid models that blend multiple paradigms. Here, we primarily review the existing literature from two perspectives, including traditional machine learning and deep learning.
The traditional machine learning methods typically rely on feature engineering to capture relationships between demand and influencing factors like weather, time, and economic indicators. For example, Elmrini et al. developed an optimized XGBoost model for high-fidelity load forecasting in rural hybrid energy systems, demonstrating its effectiveness [
1]. Gao et al. used a random forest model to forecast the demand function of air conditioning resources in response to energy prices [
7]. A hybrid approach combining Light Gradient Boosting Machine (LightGBM) with an LSTM network was designed for high-fidelity forecasting of load demand and electricity prices [
40]. Moreover, Bouyakhsaine et al. utilized a LightGBM model within an adaptive online learning framework to predict residential energy consumption, effectively handling concept drift [
36]. Tu et al. introduced an arithmetic optimization algorithm to adaptively optimize parameters in a mixed-frequency fractional derivative grey model [
41]. While powerful, these models require feature selection and may not inherently capture long-range temporal dependencies as effectively as deep learning methods.
Deep learning methods have become the dominant approach for energy demand forecasting due to their automatic feature extraction and exceptional ability to model nonlinear and long-term temporal dependencies [
6,
7,
13]. For instance, Uhrig et al. proposed a multivariate LSTM-based model that effectively learns complex nonlinear dependencies from heterogeneous inputs for short-term forecasting [
2]. Somasundaram and Jothinathan developed a hybrid framework using a deep walk GRU with an attention mechanism for high-resolution peak-load forecasting [
42]. Du et al. used a two-layer decomposition framework with CEEMDAN and feature mode decomposition, and combined it with a hybrid architecture of bidirectional TCN, GRU, and attention mechanisms for battery swapping station demand forecasting [
43]. Zhu et al. proposed a hybrid strategy combining Mamba for long-term trends and Transformer for short-term fluctuations [
24]. Kaur et al. integrated an explainable AI tool with a Transformer-based LSTM model to interpret the influence of weather parameters on residential energy demand [
44]. Guo et al. combined a bidirectional LSTM with an attention mechanism and an improved whale optimization algorithm to forecast high-dynamic-load periods [
17].
In summary, while numerous deep learning-based methods have been proposed for energy demand forecasting, the practical application environment remains complex due to the highly nonlinear and multi-scale nature of load data. Furthermore, the performance of the advanced models is highly sensitive to hyperparameter settings, and manual tuning or grid search is often inefficient and suboptimal. Hence, how to design efficient algorithms, and how to optimize their numerous hyperparameters in an automated manner, remains an ongoing area of study and worthy of further investigation.
4. Experiments and Discussion
To investigate our method’s effectiveness, we selected two energy demand forecasting tasks with multivariate factors. The first task focuses on forecasting total energy use for multiple energy sources. It relies on historical energy-load records, weather conditions, and other demand-related multivariate variables. Similarly, the second task is to forecast the national electricity load in Panama.
For convincing comparison, we selected several state-of-the-art methods from the past three years as baselines for comparison, including different architectures, such as recurrent neural network-based SKOLR [
47], graph neural network-based FCSTGNN [
48], Transformer-based iTransformer [
49], and EMAformer [
45]. Moreover, we also used several hybrid methods, including MSGNet [
50], TimeKan [
51], FreDN [
52], and CaberNet [
38]. All the comparative experiments were conducted under the same conditions. Here, we evaluate the prediction performance using three standard regression metrics: the coefficient of determination (
), mean absolute percentage error (MAPE), and coefficient of variation of the root mean square error (CV-RMSE):
where
,
, and
denote the actual value, predicted value, and mean of actual values, respectively.
N denotes the total number of samples.
In all the experiments, the optimizer was Adam, and the normalization method employed was Z-score standardization. Missing values were removed directly. The batch size, the random seed, the number of initial samples, the maximum number of iterations,
, and
L were set to 128, 3407, 10, 100, 1, and 3, respectively. We adopted the same padding. The search range for the learning rate was from
to
, with a step size of
.
,
,
,
P, and
were selected from the sets {64, 128, 256, 512, 640, 768}, {64, 128, 256, 512, 640, 768, 1024}, {3, 5, 7}, {7, 24, 30, 60, 168, 360}, and {2, 3, 4, 5}, respectively. In the hyperparameter optimization, (1−
) was adopted as the optimization objective. The final hyperparameter configuration after optimization can be summarized as follows. For the two cases, the learning rates were
and
, respectively. The values of
and
are (128, 128) and (512, 512), respectively. The values of
and
P are (3, 360) and (5, 168), respectively. The value of
is 3. Experiments were conducted on a computer equipped with an Intel Core i7-13700 CPU, 128 GB of memory, and an NVIDIA GeForce RTX 4090 GPU. The source code will be available at
https://github.com/entask26/dconvformer (accessed on 2 September 2026).
4.1. An Energy Demand Forecasting Case in Spain
Here, we used an energy demand forecasting case in Valencia, Spain. In this case, there are multiple influencing factors, including generation types such as biomass, fossil gas, fossil hard coal, fossil oil, hydro run-of-river and poundage, hydro water reservoir, nuclear, solar, waste, and onshore wind, as well as weather-related variables like temperature, air pressure, humidity, wind speed, rainfall, weather conditions, and energy prices. The original dataset is available at
https://github.com/ritikdhame/Electricity_Demand_and_Price_forecasting (accessed on 2 September 2026). To predict the total energy demand, we selected several variables, including temperature (°C), humidity (%), 3-h rainfall (mm), pressure (hPa), wind speed (km/h), wind direction (°), weather description, energy price, and the previous energy demand (MW). This dataset was recorded hourly from 1 January 2015 to 31 December 2018, and contained 35,050 samples. It is split into three subsets in chronological order, with 70% for training, 10% for validation, and 20% for testing.
Table 1 presents the quantitative comparison between our method and eight advanced forecasting models. It clearly shows that our method outperforms all the comparative methods with respect to all the evaluation metrics. Specifically, for two advanced Transformer variants, iTransformer and EMAformer, their CV-RMSE values stand at 6.587% and 5.429%, respectively. However, our method maintains a much lower error of 3.6229%. As for other advanced methods, such as MSGNet, FreDN and CaberNet, most of them exhibit relatively high error rates, with MAPE scores above 4% and CV-RMSE values exceeding 5%.
Since the superiority of our method over the second-best method is not very significant in numerical terms, we further conducted a visual comparative analysis.
Figure 3 illustrates a histogram comparison of the prediction errors between our method and the second-best baseline model. As observed, the distribution for our method exhibits an extremely sharp, narrow, and concentrated peak centered exactly at zero. This indicates that the vast majority of our predictions are highly precise, with minimal variance. In contrast, the FCSTGNN shows a notably broader and more dispersed bell-shaped distribution, along with significantly longer tails on both the positive and negative sides. The results show that the prediction error distribution of our method is better than that of FCSTGNN.
The superiority of our method can be illustrated as follows. Our method benefits from the synergistic combination of channel–phase embeddings and adaptive dynamic convolution. The embeddings provide a richer initial representation that encodes both stable inter-channel relationships and periodic phase information. Although EMAformer is capable of providing diverse feature embedding representations, it lacks the adaptive learning capability inherent in dynamic convolution. Our dynamic convolution can achieve adaptively convolutional computation based on the input itself. It extracts more relevant features before the sequence is passed to the Transformer encoder. As a result, our method can efficiently predict the energy demand.
As shown in
Figure 4, we present a segment of the prediction curves to clearly compare our method with the second-best one. It can be seen that the predicted energy demand values of our method closely follow the true values across all the time steps. There is no obvious lag or systematic bias in the forecasts. However, the FCSTGNN method, with the second-best performance, shows clear lags in its predictions. Its performance disadvantage becomes more evident when energy demand changes suddenly or drastically.
Figure 5 presents a scatter plot of our predictions against the true values. Most points lie near the diagonal line, indicating a strong linear correlation. Only a few points deviate slightly from the line. In addition to the prediction results, we also present their trend and seasonal components.
Figure 6 shows that energy demand exhibits clear seasonal variation and cyclical upward and downward trends. This visual evidence explicitly confirms that our method can accurately capture both the magnitude and the fluctuations of the energy demand.
4.2. An Energy Demand Forecasting Case in Panama
In this case, a curated hourly national energy consumption dataset in Panama was collected to validate the effectiveness of our proposed method. The complete dataset contains 48,048 observations spanning from 3 January 2015 to 26 June 2020. Here, the specific energy refers to electrical load. It comes from daily post-dispatch reports published by the grid operator. The calendar information regarding school periods is obtained from the Ministry of Education of Panama. Public holiday schedules are acquired from the “When on Earth” website. There are a total of 22 distinct types of statutory and cultural holidays. The weather variables are retrieved from the Earthdata platform. The target variable represents the national electricity load measured in megawatt hours. The exogenous predictors are systematically categorized into meteorological features and temporal indicators. The meteorological features include temperature at two meters and relative humidity along with liquid precipitation and wind speed. These weather parameters are collected from geographically dispersed monitoring stations in Tocumen, Santiago, and David. The temporal indicators comprise dichotomous flags for holidays and school terms. The original dataset is available at
https://data.mendeley.com/datasets/byx7sztj59/1 (accessed on 2 September 2026). A full variable dictionary with units and data types is provided in
Table 2. Here, we also use 70% of the dataset for training, 10% for validation, and 20% for testing.
As shown in
Table 3, our method also outperforms all the comparative methods across all evaluation metrics. Compared with graph-based methods like FCSTGNN and MSGNet, our method reduces the CV-RMSE forecasting by approximately 41.0% and 33.9%, respectively. Compared with the Transformer variants, including iTransformer, EMAformer, and FreDN, our method reduces the CV-RMSE by at least approximately 20.1% and by up to approximately 65.76%. As for other advanced methods, including SKOLR and TimeKan, our method has an advantage across all the evaluation metrics. Even when compared to the method ranked second in overall performance, our method still maintains a certain advantage. As shown in
Figure 7, our error distribution exhibits a much higher peak and a tighter concentration around zero. However, the error curve for CaberNet shows a wider spread and a lower frequency at the center. This direct comparison also confirms the effectiveness of our method.
Figure 8 shows that our predicted demand aligns well with the actual data. No significant delays or consistent errors appear in the results. However, the second-best method CaberNet still exhibits clear lag in its predictions, and when energy demand changes suddenly or drastically, it still underperforms our method.
Figure 9 displays the scatter plot that compares our predicted results with the corresponding real ones. Most points lie near the diagonal line. This phenomenon reflects an exceptionally strong linear matching relationship between predictions and real observations. As shown in
Figure 10, the seasonality and trend predicted by our method are similar to those in the previous case, both showing relatively clear seasonal variation and a non-monotonic trend. All these visual results strongly confirm that our method can capture both the scale and dynamics of energy demand.
In summary, the quantitative and qualitative results highlight the effectiveness of our method. The combination of channel–phase embeddings and adaptive dynamic convolution leads to accurate forecasts. Hence, our method is a practical solution for energy demand forecasting.
4.3. Ablation Experiments
To verify the necessity and effectiveness of each module in our method, we further conduct ablation studies. We use our full method as the baseline model and conduct ablation experiments by removing each of the proposed modules. Specifically, ‘ThrEmd’ denotes the inclusion of all three embeddings (channel, phase, and joint channel–phase embeddings), while ‘Dconv’ denotes the dynamic convolution module. ‘w/o ThrEmd’ and ‘w/o Dconv’ indicate that ‘ThrEmd’ and ‘Dconv’ are removed from our method, respectively. ‘w/o ThrEmd, Dconv’ indicates that both components are removed. This variant is essentially the Transformer. ‘w/channel’, ‘w/phase’, and ‘w/channel–phase’ denote the variants where ‘ThrEmd’ is replaced by channel-only, phase-only, and joint channel–phase embeddings, respectively. ‘w/randSearch’ denotes the variant where the Bayesian optimizer is replaced with random search.
According to
Table 4 and
Table 5, we conducted a comparative analysis from three aspects. (1) By comparing ‘w/o ThrEmd’, ‘w/phase’, ‘w/channel’ and ‘w/channel-phase’ with our full method, we found that all proposed embedding strategies were effective. This indicates that explicit channel position embedding indeed helps the model capture relationships within and between channels. Meanwhile, explicit phase embedding can help the model extract latent periodic features from the data and thus improve learning efficiency. Moreover, the joint use of these embeddings can produce synergistic effects and further improve the algorithmic performance. In addition, ‘w/phase’ achieved higher prediction accuracy than ‘w/channel’. The possible reason is as follows. As shown in
Figure 4 and
Figure 8, both datasets exhibit latent periodic characteristics. Phase embedding explicitly characterizes this property and is clearly more informative than channel embedding, which provides only positional information. Since the model can exploit more feature information from the data, ‘w/phase’ may contribute more to performance improvement. (2) By comparing ‘w/o Dconv’ with our method, and ‘w/o ThrEmd, Dconv’ with ‘w/o ThrEmd’, we found that dynamic convolution indeed improved algorithm performance. Compared with the standalone Transformer, the introduced dynamic convolution improved
by at least 8.4%. This indicates that input-dependent adaptive convolution indeed captures correlations among different variables and thus improves performance. As shown in
Figure 11 and
Figure 12, dynamic convolution and ‘ThrEmd’ both significantly improve Transformer’s prediction performance, and their prediction error distributions are concentrated near zero. (3) Compared with ‘w/randSearch’, our Bayesian optimization method achieves better optimization performance under the same conditions. This indicates that the kernel density estimation-based Bayesian optimization method can indeed improve the optimization efficiency and achieve better optimization results than random search.
In summary, each module effectively improves the forecasting accuracy, and both are indispensable for achieving the best performance.
4.4. Discussion
Although the experimental results in the previous section confirm the effectiveness of our method, they are based on limited cases and comparison experiments. To further validate the effectiveness of our method, we analyzed it from both the theoretical and practical perspectives.
(1) Theoretically, the advantages of our method in the above comparative experiments can be mainly attributed to two aspects. (1) From the perspective of feature embedding, the triple embedding strategy can provide rich input representation, thus helping our method extract both temporal periodicity and channel characteristics. Specifically, the channel embedding provides stable inter-channel relationships, while the phase embedding captures periodic patterns such as daily or weekly cycles. The joint embedding models fine-grained interactions between each channel and its current phase. As shown in the ablation study, adding only the triple embedding module reduces the CV-RMSE scores by at least approximately 39.4% and by up to approximately 49.5%. It also reduces MAPE scores by at least approximately 43.5% and by up to approximately 56.7%. (2) From the perspective of dynamic convolution, it replaces a fixed static kernel with input-dependent one. This allows the method to adaptively extract features according to the input. When both the triple embeddings and the dynamic convolution are used together with Bayesian optimization, the full method achieves the best results across all evaluation metrics. The combination of better input representations, adaptive feature extraction, and automated hyperparameter tuning leads to a clear synergistic effect. In addition to the comparison with the second-best method in the above experiments, we further selected two Transformer variants, iTransformer and EMAformer. By comparing
Figure 13 and
Figure 14 with
Figure 3, we found that our prediction errors were more concentrated near zero and clearly smaller than those of the two variants. These different comparative experimental results clearly demonstrate the effectiveness and superiority of our method.
(2) In terms of practical application, we further evaluated the performance of our method from two aspects. (1) We conducted statistical analysis through multiple independent experiments. As shown in
Table 6, across 10 independent experiments, the standard deviation of the
values of our prediction results reached the order of
, and the mean values were close to or even higher than the prediction accuracy reported earlier. This fully demonstrates the high robustness of our method. (2) To evaluate the practical deployment performance of our method, we reported the model size, parameter count, FLOPs, and average inference time per sample. As shown in
Table 7, the model size, parameter count and FLOPs of our method in the Panama case were larger than those in the Spain case. Overall, the average inference time per sample of our method was only about 0.2 ms, which indicates very low latency. This shows that our method has good practical deployment performance.