Energy-driven online adaptive method for distributed shift time series prediction
By constructing a multidimensional energy function for online adaptation, the performance degradation of time series prediction models under test distribution shifts is solved, achieving efficient adaptation under label-less conditions and improving prediction accuracy and stability.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XINJIANG UNIVERSITY
- Filing Date
- 2026-05-21
- Publication Date
- 2026-07-31
AI Technical Summary
Existing time series forecasting models suffer from performance degradation under test distribution offset conditions, especially with high accumulated uncertainty over long forecast ranges. Traditional test-adaptive techniques are difficult to apply to continuous value regression problems.
By constructing a multidimensional energy function, including boundary continuity energy, temporal regularization energy, and frequency domain consistency energy, only the adaptation parameters in the basic prediction model are updated, achieving online self-adaptation to the data distribution of the current test sample.
In the absence of real future labels, it improves the performance of time series prediction models under test distribution offset conditions, avoids catastrophic drift and overfitting, and is suitable for real prediction deployment environments.
Smart Images

Figure CN122491607A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of time series forecasting, and more particularly to an energy-driven online adaptive method for forecasting distributed offset time series. Background Technology
[0002] The fundamental task of time series forecasting is to estimate the values at several future time steps based on a given historical observation sequence using a forecasting model. However, time series in practical applications often exhibit significant non-stationarity, which manifests in multiple ways, such as: changes in the statistical mean and variance over time; directional or amplitude shifts in the trend term; changes in amplitude, frequency shifts, or phase adjustments in periodic characteristics; abrupt changes in local data patterns due to changes in the external environment (such as policy adjustments, extreme weather, and unforeseen events); and dynamic evolution of the correlation structure among multiple variables over time. For example, in electricity load forecasting, the load distribution patterns of peak summer air conditioning consumption differ significantly from those of peak winter heating consumption; similarly, traffic flow patterns differ fundamentally between weekdays and holidays. These phenomena are prevalent in actual industrial deployment scenarios, and the cumulative effect of distribution shifts becomes more pronounced as the time span increases.
[0003] Therefore, the data distribution during the training phase of a predictive model is often inconsistent with that during the testing phase. Under this distribution shift, the fixed model parameters obtained during training are unlikely to remain optimal, leading to a significant increase in prediction error during testing. This problem is particularly pronounced over long prediction ranges, as the prediction interval covers a larger time span and accumulates greater uncertainty.
[0004] Test-Time Adaptation (TTA) is a technique that has emerged in recent years to address the distribution shift problem during the inference phase. Current TTA techniques are mostly geared towards image classification tasks, primarily constructing optimization objectives around classification probability, prediction entropy, pseudo-labels, or class distribution. However, time series prediction tasks are continuous value regression problems, and their outputs lack a discrete probability distribution structure, fundamentally different from image classification tasks. Therefore, the aforementioned methods are difficult to directly transfer and apply.
[0005] Therefore, how to solve the problem of performance degradation of current time series prediction models under test distribution offset conditions is a technical problem that this invention urgently needs to solve. Summary of the Invention
[0006] To address the aforementioned technical problems, this invention provides an energy-driven online adaptive method for predicting distributed offset time series, aiming to overcome or at least partially solve the aforementioned problems.
[0007] The first aspect of this invention provides an energy-driven online adaptive method for predicting distributed migration time series, the method comprising: Using traffic flow training data, the time series prediction model is trained to obtain the trained traffic flow prediction model. The parameters of the trained traffic flow prediction model are divided into frozen parameters and adaptive parameters to obtain an adaptive traffic flow prediction model for testing. Traffic flow test data with a distribution offset relative to the traffic flow training data is input into the adaptive traffic flow prediction model to be tested to obtain the first traffic flow prediction data. The traffic flow test data includes: the actual values of C traffic flow indicators at L historical time steps; the first traffic flow prediction data includes: the first indicator prediction values of C traffic flow indicators at the L+1 to L+H prediction time steps. Based on the first traffic flow prediction data and traffic flow test data, the boundary continuity energy function value is obtained. The boundary continuity energy function value represents the continuity between the initial change trend of the first traffic flow prediction data and the final change trend of the traffic flow test data. Based on the first traffic flow prediction data, the time-series regularized energy function value is obtained. The time-series regularized energy function value characterizes the temporal smoothness of the first traffic flow prediction data. Based on the first traffic flow prediction data and traffic flow test data, the frequency domain consistent energy function value is obtained. The frequency domain consistent energy function value represents the continuity between the frequency characteristics of the initial segment of the first traffic flow prediction data and the frequency characteristics of the final segment of the traffic flow test data. Based on the boundary continuity energy function value, the time series regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test. Input traffic flow test data or actual traffic flow data that does not have a distribution offset relative to the traffic flow test data into the traffic flow prediction model that has completed its adaptive test, and obtain the traffic flow prediction results.
[0008] In the energy-driven online adaptive method for distribution-offset time series prediction proposed in this invention, after training a traffic flow prediction model based on traffic flow training data, a multidimensional energy function is constructed based on the current test sample (i.e., traffic flow test data with a distribution offset relative to the traffic flow training data) during the model inference stage. The multidimensional energy function is then used to update the adaptation parameters in the trained traffic flow prediction model online, enabling the model to quickly adapt to the data distribution represented by the current test sample and more accurately predict traffic flow for that sample. The multidimensional energy function includes at least boundary continuity energy, temporal regularization energy, and frequency domain consistency energy, constructing unlabeled optimization objectives from three dimensions: boundary continuity, temporal smoothness, and frequency domain dominant frequency consistency.
[0009] Thus, the present invention has at least the following beneficial effects: First, this invention enables online adaptation of model parameters during the testing phase without accessing the true future labels. By constructing boundary continuity energy, temporal regularization energy, and frequency domain consistency energy around the current test samples, an effective optimization objective can be formed under label-less conditions. Therefore, it is suitable for time series application scenarios where the true future values cannot be obtained in a timely manner in real prediction deployment environments, thus improving the performance of time series prediction models under test distribution offset conditions.
[0010] Second, this invention constructs a multi-dimensional energy function to address the requirements of continuous value output, multi-step prediction, boundary alignment, temporal smoothness, and frequency domain structure preservation in time series prediction tasks. Compared to entropy minimization or pseudo-label methods designed for classification tasks, this approach is more in line with the technical characteristics of time series prediction tasks themselves. This invention does not employ a single consistency loss, but rather uses multiple energy terms to jointly constrain multiple structural dimensions of the prediction results.
[0011] Third, this invention updates only a subset of parameters in the base prediction model (e.g., only updating the adaptation parameters in a trained traffic flow prediction model), without updating all parameters of the model. These adaptation parameters are more sensitive to distribution shifts, and the number of parameters is significantly less than the total number of parameters, making online updates more lightweight, stable, and less prone to catastrophic drift. Attached Figure Description
[0012] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1This is a flowchart illustrating the steps of an energy-driven online adaptive method for distributed offset time series prediction according to an embodiment of the present invention; Figure 2 This is a schematic diagram of an overall architecture for energy-driven online adaptive prediction of distributed offset time series, as shown in an embodiment of the present invention. Detailed Implementation
[0014] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0015] As mentioned earlier, the fundamental task of current time series forecasting is to estimate the values at several future time steps based on a given historical observation sequence using a forecasting model. Let the historical input sequence be: ;in, Indicates the length of the input history. Indicates the number of variables. Indicates the first The goal of a time series forecasting model is to obtain the observed values of all variables at each time step. Output the future length based on Predicted sequence ;in, The parameter is Time series prediction models, This indicates the prediction step size. The optimization objective of a time series forecasting model is to make the predicted series... As close as possible to the actual future observations During the training phase, the model parameters are optimized by minimizing the prediction loss function: ;in, For predicting the loss function, The training data distribution. After training, the optimal model parameters. It is permanently stored for use in subsequent reasoning stages.
[0016] Mainstream time series forecasting methods typically follow a static "train-freeze-inference" workflow. This means that model parameters are first optimized on training data, and then future series predictions are directly executed using fixed parameters during the testing phase. While this static inference mechanism is simple to implement and easy to deploy, it implicitly assumes a fundamental problem: that the training distribution is essentially the same as the testing distribution. When this assumption is not true, the model with frozen parameters cannot make any dynamic adjustments based on the current test samples. This traditional fixed-parameter inference model lacks adaptive capability during the inference phase, which constitutes a serious performance bottleneck in non-stationary time series scenarios. As practical applications increasingly demand higher prediction accuracy and reliability, and as the non-stationary characteristics of time series data become more prominent, the impact of this bottleneck is becoming increasingly significant, necessitating an adaptive mechanism that can dynamically respond to changes in the test distribution during the inference phase.
[0017] To address the goal of dynamically responding to changes in test distribution during the inference phase, this invention considers that current test-time adaptive techniques are mostly geared towards image classification tasks, primarily constructing optimization objectives around classification probability, prediction entropy, pseudo-labels, or category distribution. However, time series prediction tasks are continuous value regression problems, fundamentally different from image classification tasks. Through careful research, this invention has identified several reasons why test-time adaptive methods are difficult to directly transfer and apply to time series prediction tasks: First, the output of time series forecasting is not a single discrete category label, but a continuous value prediction matrix of length H and number of variables C. This means that it is impossible to directly use indicators based on discrete probability distributions, such as softmax probability or classification entropy, to construct an adaptive optimization objective. The output space of time series forecasting is a high-dimensional continuous space, lacking the probability structure naturally present in classification tasks. Second, the prediction quality of time series forecasting depends not only on the numerical accuracy of each future time step, but also on the temporal structure of the entire prediction interval. A high-quality time series forecast result requires that the predicted value at each time step be as close as possible to the true value, and that the entire prediction curve exhibits a reasonable trend, appropriate smoothness, and a dynamic change pattern consistent with historical inputs in the time dimension. This requirement for the rationality of the overall temporal structure does not exist in classification tasks. Third, the predicted sequence must maintain a reasonable connection with the historical input at the connection boundary: the beginning of the predicted sequence should naturally continue the changing trend of the end of the input sequence, rather than exhibiting unnatural jumps or breaks. This requirement for boundary continuity is a technical constraint unique to time series forecasting tasks and is completely absent in classification tasks. Fourth, the predicted sequence usually needs to retain periodicity and dominant frequency information consistent with the historical sequence: if the historical input contains obvious daily, weekly, or other significant frequency components, then the predicted sequence should also reflect the corresponding periodic patterns and frequency domain characteristics. This requirement for consistency at the frequency domain level is also unique to time series tasks.
[0018] Therefore, the test-time adaptive objective designed for image classification is difficult to directly serve as an effective unlabeled optimization objective for time series prediction tasks. Especially in the testing phase where there are no real future labels, this invention argues that how to construct an objective function that can both fully reflect the rationality of time series prediction and effectively drive model parameter updates is the core problem that needs to be solved in time series test-time adaptive optimization.
[0019] Furthermore, this invention also considers that in time series prediction tasks, relying solely on a single unsupervised constraint is often insufficient to fully characterize the multidimensional structural features that a reasonable prediction result should satisfy. For example, in solving this problem, this invention found that if only consistency between the prediction results of the original input and the augmented input is required (i.e., a single prediction consistency constraint), the model may tend to produce prediction sequences that are consistent with each other but unreasonable in the time or frequency domains. The model may satisfy the consistency requirement by outputting a nearly flat straight line, because a constant output is naturally consistent with any input perturbation, but such predictions obviously lack practical significance. If only local smoothness constraints are emphasized, the model may excessively pursue the smoothness of the prediction sequence at the expense of its ability to express real trend changes and periodic structures, resulting in overly smoothed prediction results that lose detail. If only frequency domain consistency constraints are emphasized, although the model can maintain a certain consistency in the global frequency structure, it may ignore short-term local dynamic features and transition features at the input-prediction boundary.
[0020] The above observations of this invention reveal a fundamental problem: the rationality of time series prediction results is multi-dimensional and cannot be fully characterized by any single indicator. A truly rational time series prediction result should simultaneously satisfy at least three of the following requirements: robust consistency against input disturbances; dynamic continuity between the prediction start point and the input tail; rationality of the temporal structure within the prediction interval; and frequency domain principal component features matching the input history tail segment. Therefore, this invention proposes that the test-time adaptation of time series prediction tasks requires a joint optimization objective that simultaneously reflects the above multiple dimensions.
[0021] Furthermore, this invention also considers that even if an online update mechanism is introduced during the testing phase, a lack of refined control strategies can easily lead to new technical problems. Since the testing phase lacks real future labels as supervisory signals, model updates rely entirely on the surrogate objective function. In this unsupervised online optimization scenario, at least the following stability risks exist: First, excessive parameter freedom leads to overfitting of the current test batch. Because optimization during testing is usually based on only a single or a small number of test samples, updating a large number of model parameters simultaneously can easily cause the model to overfit the specificity and noise patterns of the current samples, resulting in a significant decrease in its generalization ability to subsequent test samples. This overfitting problem is particularly prominent in streaming testing scenarios because the parameter state of each sample after adaptation directly affects the processing of subsequent samples. Second, unsupervised updates may destroy the model's original feature extraction and sequence modeling capabilities, leading to catastrophic drift. The basic prediction model learns general temporal feature extraction capabilities and prediction mapping relationships through a large amount of data during the training phase, enabling it to maintain a certain level of prediction performance under various data distributions. If model parameters are updated without constraints during the adaptive process during testing, the core capabilities accumulated during the training phase may be accidentally destroyed, leading to irreversible degradation of the overall model performance.
[0022] Based on the above analysis of this invention, it can be seen that test-time adaptive methods in time series prediction scenarios face multiple technical challenges. On the one hand, optimization strategies based on classification probability or prediction entropy, as used in classification tasks, cannot be simply adopted because time series prediction is a continuous multi-step regression problem, and its output does not possess a discrete probability distribution structure. On the other hand, online fine-tuning cannot rely solely on a single self-supervised objective, as reasonable time series prediction needs to simultaneously meet multiple quality requirements such as boundary continuity, temporal smoothness, and frequency domain structure preservation. Furthermore, the test-time online update process itself requires a fine control mechanism to avoid overfitting, catastrophic drift, and optimization imbalance caused by excessively free parameter updates.
[0023] Based on this, in order to at least partially solve one or more of the above-mentioned problems and other potential problems, this invention proposes a test-time adaptive method designed for the characteristics of time series prediction tasks. Specifically, it proposes an energy-driven online adaptive method for distribution-biased time series prediction, which constructs a multidimensional energy target using the current test sample under conditions without real future labels, and performs online parameter updates in a small-scale, controllable, and rollback-friendly manner. Specifically, the core idea of this method is to construct a multidimensional energy function around the current test sample during the testing phase without changing the main structure of the basic prediction model, and to perform a finite-step online update only on the adaptation parameters in the model (such as a small number of normalized correlation parameters), enabling the model to quickly adapt to the data distribution represented by the current test sample. The idea of this invention comes from the theoretical framework of energy-based models: a scalar energy value is defined for each data-model configuration. A well-fitting model should have low energy on correctly distributed data, while distribution bias or unreasonable prediction will lead to increased energy. Therefore, by minimizing the energy function, the model parameters are guided to adjust in a direction that better fits the current test data.
[0024] Specifically, the following embodiments illustrate the adaptive nature of the energy-driven online adaptive method for distribution-shifted time series prediction proposed in this invention.
[0025] Please refer to Figure 1 , Figure 1 This is a flowchart illustrating the steps of an energy-driven online adaptive method for distributed offset time series prediction, as shown in an embodiment of the present invention. Figure 1 As shown, the energy-driven online adaptive method for distributed migration time series prediction provided in this embodiment includes at least the following steps: Step S11: Use traffic flow training data to train the time series prediction model to obtain the trained traffic flow prediction model.
[0026] In this embodiment, traffic flow training data can be acquired and used to train a time series prediction model, resulting in a trained traffic flow prediction model. This trained traffic flow prediction model receives historical multivariate traffic flow time series as input and outputs a predicted future traffic flow time series.
[0027] Furthermore, the prediction process of the traffic flow prediction model can be decomposed into two stages: encoding and decoding. ;in, This represents the encoding process (including input normalization, feature extraction, and sequence modeling). This represents the decoding process (mapping encoded features to predicted output). It should be noted that the innovation of this embodiment lies not in the internal structure design of a specific base prediction model (i.e., time series prediction model), but in proposing an energy-driven test-time adaptive mechanism that can be independently attached to the base prediction model. In a preferred embodiment, the time series prediction model can be a UniTST model. The test-time adaptive mechanism proposed in this embodiment is essentially independent of a specific time series prediction model structure; its core lies in the parameter selection strategy during the testing phase, the construction method of the multidimensional energy function, and the online adaptation process. Therefore, provided that the base prediction model (i.e., the time series prediction model) can receive historical time series inputs and output future predicted sequences, and the model contains at least learnable normalized parameters, this embodiment can be integrated as a plug-in adaptation module into time series prediction models of various depths.
[0028] Step S12: Divide the parameters of the trained traffic flow prediction model into frozen parameters and adaptive parameters to obtain an adaptive traffic flow prediction model for testing.
[0029] In this embodiment, after obtaining the trained traffic flow prediction model, it is adaptively tested. To reduce the drift risk caused by unsupervised updates during the testing phase, this embodiment does not update all parameters of the trained traffic flow prediction model. Instead, the parameters of the trained traffic flow prediction model are divided into two parts: frozen parameters and adaptive parameters, resulting in an adaptive traffic flow prediction model for testing. The frozen parameters in the adaptive traffic flow prediction model for testing... The adaptation parameters remain unchanged during the adaptive testing phase. Participation in online optimization updates is permitted during the adaptive testing phase.
[0030] In a preferred example, the parameters are frozen. This includes core modeling parameters such as feature extraction layer weights, encoder main parameters, and prediction head main parameters in the trained traffic flow prediction model; adaptation parameters. This includes the normalized relevant parameters in the trained traffic flow prediction model. Let all the model parameters be denoted as... Then it can be divided into freeze parameters. Adaptation parameters during testing : Preferably, Includes at least one of the following types of normalization-related parameters: learnable scaling parameters in the Reversible Instance Normalization Layer (RevIN). With bias parameters Scaling parameters in LayerNorm With bias parameters Scaling parameters in the batch normalization layer (BatchNorm) With bias parameters In other words, the adaptation parameters in this embodiment include at least the learnable scaling parameters and bias parameters in the reversible instance normalization layer, the layer normalization layer, and the batch normalization layer.
[0031] During the adaptive testing phase, only for Perform gradient updates, and Keep frozen. The adaptive optimization objective during testing is: After adaptation is complete, use the updated parameter combination. Calculate the final prediction result , where E represents the total energy function.
[0032] In this embodiment, choosing normalized parameters as the adaptive update targets during testing has a profound technical rationale: In deep neural networks, the normalization layer plays a crucial role in adjusting the feature distribution, and its parameters directly participate in feature scaling, bias shifting, and distribution correction. When the input data distribution shifts, these adjustment parameters of the normalization layer are most sensitive to the new distribution, thus enabling rapid adaptation to the current test distribution with minimal parameter changes. Simultaneously, since the number of normalized parameters is significantly less than the total number of model parameters, updating only these parameters can significantly reduce the degrees of freedom for online optimization during the testing phase, thereby avoiding problems such as overfitting, catastrophic drift, and loss of generalization ability that may result from unsupervised full parameter updates. Furthermore, the normalization layer plays a role in feature distribution adjustment rather than core feature extraction or pattern recognition; therefore, small adjustments to its parameters will not fundamentally destroy the main modeling capabilities learned during the training phase.
[0033] Step S13: Input the traffic flow test data, which has a distribution offset relative to the traffic flow training data, into the adaptive traffic flow prediction model to be tested to obtain the first traffic flow prediction data.
[0034] In this embodiment, after obtaining the adaptive traffic flow prediction model for the test time, the traffic flow test data is input into the adaptive traffic flow prediction model for the test time for processing, resulting in the first traffic flow prediction data output by the adaptive traffic flow prediction model for the test time. The traffic flow test data can be any traffic flow time series data, without restriction, and the traffic flow test data may have a distribution offset relative to the traffic flow training data. The traffic flow test data includes: the actual values of C traffic flow indicators at L historical time steps; the first traffic flow prediction data includes: the predicted values of the C traffic flow indicators at the L+1 to L+H prediction time steps.
[0035] Step S14: Based on the first traffic flow prediction data and traffic flow test data, obtain the boundary continuity energy function value.
[0036] In this embodiment, after obtaining the first traffic flow prediction data, the boundary continuity energy function value can be determined based on the first traffic flow prediction data and the traffic flow test data. The boundary continuity energy function value characterizes the continuity between the initial trend of change in the first traffic flow prediction data and the final trend of change in the traffic flow test data.
[0037] In this embodiment, a boundary continuity energy is specifically constructed to address the characteristics of time series prediction tasks. This boundary continuity energy requires the predicted sequence to continue the trend of the input tail at the boundary, rather than simply requiring the values to be close. Compared to general consistency loss, this embodiment particularly emphasizes the trend continuity between the predicted sequence and the input historical sequence at the connection boundary, thereby making the prediction results after adaptation during testing more consistent with the dynamic evolution of real time series.
[0038] Step S15: Based on the first traffic flow prediction data, obtain the time-series regularized energy function value.
[0039] In this embodiment, to improve the temporal structure rationality of the prediction results after online adaptation during the testing phase, a temporal regularization energy is introduced. This temporal regularization energy is used to constrain the rationality of the prediction results in the time dimension. Based on this, this embodiment determines the temporal regularization energy function value based on the predicted first traffic flow prediction data. This temporal regularization energy function value characterizes the temporal smoothness of the first traffic flow prediction data.
[0040] Step S16: Based on the first traffic flow prediction data and traffic flow test data, obtain the frequency domain consistency energy function value.
[0041] Since time series prediction results should not only satisfy temporal continuity but also maintain periodicity and dominant frequency structure consistent with historical inputs as much as possible, this embodiment introduces frequency domain consistency energy. This frequency domain consistency energy is used to constrain the consistency of the predicted sequence with the tail of the input historical sequence in terms of dominant frequency components. Based on this, this embodiment determines the frequency domain consistency energy function value based on the first traffic flow prediction data and traffic flow test data. This frequency domain consistency energy function value characterizes the continuity between the frequency characteristics of the initial segment of the first traffic flow prediction data and the frequency characteristics of the final segment of the traffic flow test data.
[0042] Step S17: Based on the boundary continuity energy function value, the temporal regularization energy function value, and the frequency domain consistency energy function value, update the adaptation parameters of the adaptive traffic flow prediction model to be tested, and obtain the adaptive traffic flow prediction model to be tested.
[0043] In this embodiment, the constructed test-time adaptive objective function is a total energy function composed of multiple energy terms. This total energy function includes at least: a boundary continuity energy function, a temporal regularization energy function, and a frequency domain consistency energy function. This embodiment can determine the total energy function value based at least on the obtained boundary continuity energy function value, temporal regularization energy function value, and frequency domain consistency energy function value. The goal is to minimize this total energy function value, guiding the adaptation parameters in the test-time adaptive traffic flow prediction model to adjust towards better fitting the traffic flow test data. This process updates the adaptation parameters until the parameters are fully adapted, resulting in a test-time adaptive traffic flow prediction model.
[0044] In this embodiment, by minimizing the total energy function value, the adaptive traffic flow prediction model under test can gradually adapt to the data distribution represented by the current test sample (i.e., traffic flow test data) without relying on test labels.
[0045] Step S18: Input the traffic flow test data or the actual traffic flow data that does not have a distribution offset relative to the traffic flow test data into the traffic flow prediction model that has completed the adaptive test, and obtain the traffic flow prediction result.
[0046] In this embodiment, after obtaining the adaptive traffic flow prediction model during testing, the traffic flow test data, or actual traffic flow data that does not exhibit distribution offset relative to the test data, can be input into the adaptive traffic flow prediction model for processing. This yields the traffic flow prediction result output by the adaptive traffic flow prediction model, thereby achieving accurate prediction for either the test traffic flow data or the actual traffic flow data that does not exhibit distribution offset relative to the test data. Specifically, the traffic flow prediction result in this embodiment is the predicted time-series traffic flow data corresponding to the test traffic flow data or the actual traffic flow data.
[0047] In this embodiment, at least the following beneficial effects exist: First, this invention enables online adaptation of model parameters during the testing phase without accessing real future labels. By constructing boundary continuity energy, temporal regularization energy, and frequency domain consistency energy around the current test samples, an effective optimization objective can be formed under label-less conditions. Therefore, it is suitable for time series application scenarios where future true values cannot be obtained in a timely manner in real prediction deployment environments.
[0048] Second, this invention constructs a multi-dimensional energy function to address the requirements of continuous value output, multi-step prediction, boundary alignment, temporal smoothness, and frequency domain structure preservation in time series prediction tasks. Compared to entropy minimization or pseudo-label methods designed for classification tasks, this approach is more in line with the technical characteristics of time series prediction tasks themselves. This invention does not employ a single consistency loss, but rather uses multiple energy terms to jointly constrain multiple structural dimensions of the prediction results.
[0049] Third, this invention updates only a subset of parameters in the base prediction model (e.g., only updating the adaptation parameters in a trained traffic flow prediction model), without updating all parameters of the model. These adaptation parameters are more sensitive to distribution shifts, and the number of parameters is significantly less than the total number of parameters, making online updates more lightweight, stable, and less prone to catastrophic drift.
[0050] In one implementation, based on the above embodiments, for each test batch in different test batches (i.e., traffic flow training data with different distribution offsets), steps S12 to S18 can be repeatedly executed to perform test-time adaptation. In this embodiment, test-time adaptation is re-executed for each test batch with a distribution offset. For example, if the traffic flow test data is the first test batch, and the third traffic flow test data, which has a distribution offset from both the traffic flow test data and the traffic flow training data, is the second test batch, then for the second test batch, steps S12 to S18 need to be repeatedly executed to perform test-time adaptation for the second test batch, thereby achieving accurate prediction.
[0051] In conjunction with the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed offset time series prediction. In this method, in addition to the steps described above, steps S21 to S24 may be included, and step S17 may specifically include step S25: Step S21: Perform time-series augmentation on the traffic flow test data to obtain augmented traffic flow test data.
[0052] In this embodiment, in order to construct a proxy optimization signal that can be used for model adaptation during the testing phase without real future labels, temporal augmentation is performed on the current test input sample to obtain augmented input samples. This involves performing time-series augmentation on traffic flow test data to obtain enhanced traffic flow test data. The enhanced traffic flow test data has the same semantics as the regular traffic flow test data, but it exhibits local perturbations compared to the regular traffic flow test data. This enhanced traffic flow test data includes: perturbation values of C traffic flow indicators over L historical time steps.
[0053] The augmentation process in this embodiment is not intended to expand the scale of the training data, but rather to construct a temporal variant with the same semantics as the original input but with local perturbations. By requiring the model (i.e., the traffic flow prediction model that is adaptive at the time of testing) to produce consistent predictions on both the original and augmented inputs, an effective self-supervised adaptive signal can be constructed without any labels.
[0054] Step S22: Input the enhanced traffic flow test data into the adaptive traffic flow prediction model under test to obtain the second traffic flow prediction data.
[0055] In this embodiment, after obtaining the enhanced traffic flow test data, the enhanced traffic flow test data can be input into the adaptive traffic flow prediction model for the test time for processing, to obtain the second traffic flow prediction data output by the adaptive traffic flow prediction model for the test time. The second traffic flow prediction data includes: the predicted values of C traffic flow indicators at the L+1 to L+H prediction time steps.
[0056] Step S23: Take i from 1 to H and c from 1 to C in sequence. Based on the difference between the second index prediction value and the first index prediction value of the c-th traffic flow index at the L+i prediction time step, obtain the robust consistency energy function value.
[0057] In this embodiment, a robust consistency energy is introduced, which measures the difference between the original prediction (i.e., the first traffic flow prediction data) and the enhanced prediction (i.e., the second traffic flow prediction data). Specifically, i can be sequentially selected from 1 to H (H is an integer greater than 1), and c can be selected from 1 to C (C is an integer greater than 1). Based on the second index prediction value of the c-th traffic flow index at the L+i prediction time step and the first index prediction value of the c-th traffic flow index at the L+i prediction time step, the difference between the second index prediction value and the first index prediction value of the c-th traffic flow index at the L+i prediction time step is determined. Then, based at least on the difference between the second index prediction value and the first index prediction value of the c-th traffic flow index at the L+i prediction time step, the robust consistency energy function value is obtained. This robust consistency energy function value characterizes the consistency between the first traffic flow prediction data and the second traffic flow prediction data.
[0058] In a specific example, to reflect the differentiated contributions of different prediction steps to the overall prediction quality, this embodiment introduces a time decay weighting mechanism. The technical intuition is that prediction steps closer to the current time generally have higher reliability and stronger practical significance, and therefore should be given a greater consistency constraint weight; while later prediction steps, due to greater accumulated uncertainty, should have their consistency requirements appropriately relaxed. Based on this, the robust consistency energy function... It can be defined as: ; Among them, the adaptive traffic flow prediction model under test is based on the original input. The prediction results (i.e., the first traffic flow prediction data) on the traffic flow test data are: In enhancing input The prediction results (i.e., the second traffic flow prediction data) on the enhanced traffic flow test data are: ; Let c be the predicted value of the first indicator of the c-th traffic flow indicator at the L+i prediction time step. Let c be the predicted value of the second indicator for the c-th traffic flow indicator at the L+i prediction time step. Indicates the first Consistency constraint weights for prediction time steps.
[0059] Preferably, The exponential decay form is: ; in, The time decay coefficient, This serves as the minimum lower bound for the weights (to prevent the weights in later prediction steps from becoming too low and completely losing their binding force). The mean normalization operation in the denominator ensures that the average of the weights is 1, without changing the magnitude of the overall energy.
[0060] Step S24: Based on the robust consistency energy function value and the boundary continuity energy function value, obtain the predicted consistency energy function value.
[0061] In this embodiment, the prediction consistency energy function value can be determined based on the robust consistency energy function value and the boundary continuity energy function value. The prediction consistency energy in this embodiment does not simply require the model output to remain unchanged, but is specifically constructed for the characteristics of time series prediction tasks. This prediction consistency energy comprises at least two parts: one part is the robust consistency energy between the prediction results corresponding to the original input samples and the enhanced input samples, which assigns differentiated constraints to different prediction steps through a time decay weighting mechanism; the other part is the boundary continuity constraint between the first prediction time step and the end of the input, requiring the prediction sequence to continue the changing trend of the input end at the boundary, rather than simply requiring the values to be close.
[0062] In other words, the prediction consistency energy in this embodiment is used to constrain the model to maintain consistency in its prediction results on both the original and augmented input samples, while ensuring reasonable dynamic continuity between the start of the prediction sequence and the tail of the historical input. The design philosophy of this energy term is that if the model's prediction for the current test sample is reliable and accurate, then applying a small, temporally structure-preserving perturbation to that input should not significantly change the model's prediction output. If the model is extremely sensitive to slight perturbations, it indicates that its predictions under the current data distribution are not robust enough and need to be improved through adaptation.
[0063] In a specific optional example, predict the consistency energy function By robust consistency energy function and boundary continuity function constitute: ;in, and These are the weighting coefficients for the two sub-items, respectively.
[0064] Step S25: Based on the prediction consistency energy function value, the time-series regularization energy function value, and the frequency domain consistency energy function value, update the adaptation parameters of the adaptive traffic flow prediction model to be tested, and obtain the adaptive traffic flow prediction model to be tested.
[0065] In this embodiment, the total energy function includes at least: a prediction consistency energy function, a temporal regularization energy function, and a frequency domain consistency energy function. This embodiment can determine the total energy function value based at least on the obtained prediction consistency energy function value, temporal regularization energy function value, and frequency domain consistency energy function value. With the goal of minimizing this total energy function value, the adaptive parameters in the adaptive traffic flow prediction model under test are guided to adjust in a direction that better adapts to the traffic flow test data. These adaptive parameters are updated until the parameters are fully adapted, resulting in a fully adaptive traffic flow prediction model for the test.
[0066] Among them, the total energy function It can be represented as: ;in, This represents the prediction consistency energy function. Represents the time-series canonical energy function. Represents the frequency domain uniformity energy function; , , These represent the weighting coefficients of the corresponding energy terms.
[0067] In this embodiment, by constructing prediction consistency energy, time-series regularization energy, and frequency-domain consistency energy around the current test sample, an effective optimization objective can be formed under label-free conditions. Therefore, it is suitable for time series application scenarios where future true values cannot be obtained in a timely manner in real prediction deployment environments.
[0068] In conjunction with any of the above embodiments, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction, in which step S14 may specifically include steps S31 to S33: Step S31: Extract the actual values of C traffic flow indicators in the last historical time step from the traffic flow test data, and extract the actual values of C traffic flow indicators in the penultimate historical time step to determine the final change trend of the traffic flow test data.
[0069] In this embodiment, the actual values of C traffic flow indicators at the last historical time step and the actual values of C traffic flow indicators at the penultimate historical time step can be extracted from the traffic flow test data (i.e., the input sequence). The difference between the actual values of C traffic flow indicators at the last historical time step and the actual values of C traffic flow indicators at the penultimate historical time step is determined as the ending trend of the traffic flow test data.
[0070] For example, suppose the actual value of C traffic flow indicators in the input sequence at the penultimate historical time step is... The actual value of traffic flow indicator C at the last historical time step is The final trend of traffic flow test data for: .
[0071] Step S32: Extract the predicted values of the first indicators of C traffic flow indicators in the first prediction time step from the first traffic flow prediction data, and combine them with the actual values of the C traffic flow indicators in the last historical time step to determine the initial trend of change of the first traffic flow prediction data.
[0072] In this embodiment, the predicted values of C traffic flow indicators at the first prediction time step can be extracted from the first traffic flow prediction data (i.e., the prediction sequence). The difference between the extracted predicted values of the C traffic flow indicators at the first prediction time step and the actual values of the C traffic flow indicators at the last historical time step is determined as the initial trend of the first traffic flow prediction data. The first prediction time step and the last historical time step are two adjacent time steps.
[0073] For example, suppose the predicted value of the first indicator in the C traffic flow indicators in the prediction sequence is [value missing] at the first prediction time step. The initial trend of change in the first traffic flow prediction data for: .
[0074] Step S33: Determine the boundary continuity energy function value based on the ending trend of traffic flow test data and the starting trend of the first traffic flow prediction data.
[0075] In this embodiment, the boundary continuity energy function value can be determined based on the ending trend of traffic flow test data and the initial trend of the first traffic flow prediction data.
[0076] In a preferred example, to ensure a natural transition between the prediction interval and the historical input interval, a differential boundary continuity constraint is used as the boundary continuity energy function. This is one of the key technical features that distinguishes this embodiment from general consistency loss. Specifically, the boundary continuity energy function... It can be expressed by the following formula: .
[0077] The technical significance of the differential boundary continuity constraint in this embodiment lies in the fact that it does not simply require the predicted first point value to be close to the input last point (i.e., absolute value constraint). Instead, it requires the predicted sequence to continue the dynamic trend of the input tail at the boundary, a distinction that is crucial in practical applications. Consider a specific scenario: if the end of the input sequence is in a clear upward trend, i.e. Then the initial value of the predicted sequence It should be higher than the input terminal value. If absolute value constraints are used, the model will be unreasonably penalized for the continuation of this natural trend, attempting to suppress it. Pull towards The numerical level of the boundary is artificially created by introducing trend breaks at the boundary. Difference constraints, on the other hand, allow for such reasonable numerical jumps, requiring only the direction and magnitude of the jump (i.e.,...). ) and the changing trend of the input terminal (i.e. As long as the consistency remains the same, the difference-type boundary continuity constraint is more in line with the continuous evolution of real time series and can better guide the adaptive prediction results to transition naturally at the boundary during testing.
[0078] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In this method, step S21 may specifically include steps S41 to S44: Step S41: Generate noisy data with time correlation over L historical time steps.
[0079] In this embodiment, for time series enhancement, noise data with temporal correlation over L historical time steps is first generated. This embodiment uses temporally correlated noise to perturb the input sequence, rather than using independent Gaussian white noise for each time step. This design choice has a clear technical reason: in real time series, observations at adjacent time steps usually have a high statistical correlation, and changes in observations are typically gradual rather than abrupt. If independent and identically distributed white noise is used for enhancement, the noise is completely uncorrelated between time steps, introducing unnatural high-frequency jagged components into the time series, disrupting the original temporal continuity, causing the enhanced samples to no longer be reasonable "neighbors" of the original samples, thus rendering the consistency constraints constructed based on the enhanced samples unreliable.
[0080] In an optional embodiment, this embodiment uses a first-order autoregressive process to generate noisy data with time correlation over L historical time steps. : ;in, Let be the time correlation coefficient, satisfying ; The variance of the random disturbance term is set to make the variance of the stationary distribution of the noise data equal to the target variance. ,Right now: In this way, the generated noise data has a variation between adjacent time steps caused by… The high correlation of the control simulates the slow drift and gradual perturbation characteristics commonly found in real time series.
[0081] Step S42: Determine the scaling factor for the traffic flow test data based on the traffic flow test data.
[0082] In this embodiment, the scaling factor for the traffic flow test data can be determined based on the statistics of each channel of the traffic flow test data. This scaling factor is also called the scaling factor. Preferably, the scaling factor for the traffic flow test data is the standard deviation of each channel of the traffic flow test data along the time dimension.
[0083] Step S43: Based on the scaling factor adapted to the traffic flow test data, scale the noise data, and then superimpose the scaled noise data with the traffic flow test data to obtain traffic flow test data with injected time-related noise.
[0084] In this embodiment, based on the noise data, the noise data is adaptively scaled according to a scaling factor adapted to the traffic flow test data, and then superimposed on the original traffic flow test data. Specifically, the noise data can be scaled based on the scaling factor adapted to the traffic flow test data to obtain scaled noise data, and then the scaled noise data is superimposed on the traffic flow test data to obtain traffic flow test data injected with time-related noise.
[0085] Example: Traffic flow test data with injected time-dependent noise. for: Where S represents the scaling factor for adapting traffic flow test data. This represents element-wise multiplication. For noisy data, For traffic flow test data; this adaptive scaling of channels ensures that the noise amplitude is proportional to the actual fluctuation amplitude of the data in each channel.
[0086] Step S44: Perform time masking enhancement on the traffic flow test data with injected time-related noise to obtain enhanced traffic flow test data.
[0087] In this embodiment, time masking enhancement is also performed on the traffic flow test data injected with time-related noise to obtain enhanced traffic flow test data. Let the time masking enhancement operation be... The final enhanced traffic flow test data It can be represented as: .
[0088] In this embodiment, the technical objective of time masking enhancement is to simulate local data loss or observational anomalies that may occur in real-world scenarios, and to test whether the model can still produce a predictive output consistent with the complete input under conditions of partial information loss. Preferably, the time masking enhancement operation includes at least one of the following methods: First, continuous block masking. That is, randomly selecting one or more continuous time segments on the time axis and masking the observations within the segments; continuous block masking simulates continuous data loss under scenarios such as short-term sensor failure or communication interruption. Second, random point masking. That is, randomly selecting several discrete moments on the time axis for masking, simulating scattered data anomalies or measurement noise.
[0089] For the masked location, one of the following filling strategies is preferred: local mean filling, which uses the mean of the corresponding channel of the input sequence to replace the value of the masked location; noise filling, which uses random noise matching the local statistics to replace it; interpolation filling, which uses linear interpolation of the boundary values at both ends of the masked region to fill it.
[0090] This embodiment constructs enhanced samples for the test input using the aforementioned temporal enhancement strategies (including temporal correlation noise injection and time masking operations of various modes). It can construct enhanced samples that are perturbed in local observations but maintain overall temporal semantic consistency, thereby providing an effective (more temporally characteristic) unlabeled adaptive signal for subsequent prediction consistency energy construction.
[0091] In other words, this embodiment employs time-related noise and multiple time masking patterns for time-series-aware enhancement, resulting in enhanced samples that better reflect the perturbation characteristics of real time series. Furthermore, the method framework of this embodiment has strong scalability; without changing the main workflow, it can also incorporate extension modules such as comparative energy optimization and different cross-batch parameter propagation strategies.
[0092] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In this method, S15 specifically includes steps S51 to S52: Step S51: Take i from 1 to H and c from 1 to C in sequence. Extract the first index prediction value of the c-th traffic flow index at the L+i-1 prediction time step, the L+i-1 prediction time step, and the L+i+1 prediction time step from the first traffic flow prediction data to determine the second difference value of the c-th traffic flow index at the L+i prediction time step.
[0093] In this embodiment, considering that in most practical application scenarios, reasonable time series prediction should have moderate smoothness and should not exhibit severe high-frequency sawtooth fluctuations that are mismatched with the inherent dynamic characteristics of the input sequence, although some time series themselves may have large fluctuation amplitudes, abnormally sharp jumps generated by the model under distribution offset conditions are usually signals of poor prediction quality rather than accurate capture of the real data pattern. Based on this, the preferred implementation of the time series regularization energy function is to construct it using second-order difference smoothing constraints on the predicted sequence to suppress unreasonable high-frequency jitter and local oscillations.
[0094] Specifically, we can sequentially select i from 1 to H, and c from 1 to C, starting from the first traffic flow prediction data (let the first traffic flow prediction data be...). In the above, the predicted value of the first indicator of the c-th traffic flow indicator at the L+i prediction time step is extracted respectively. The predicted value of the first indicator of the c-th traffic flow indicator at the L+i-1 prediction time step. And the predicted value of the first indicator of the c-th traffic flow indicator at the L+i+1 prediction time step. .
[0095] The predicted value of the first indicator can be based on the c-th traffic flow indicator at the L+i prediction time step. The predicted value of the first indicator of the c-th traffic flow indicator at the L+i-1 prediction time step. And the predicted value of the first indicator of the c-th traffic flow indicator at the L+i+1 prediction time step. Determine the second difference value of the c-th traffic flow index at the L+i-th prediction time step. : .
[0096] This embodiment considers that the first-order difference reflects the rate of change of the sequence between adjacent time steps, while the second-order difference reflects the rate of change of that rate of change—that is, the "acceleration" of the sequence. When the sequence exhibits sharp inflection points or sawtooth fluctuations, the absolute value of the second-order difference will increase significantly. In other words, the second-order difference constraint allows for the prediction of linear trend changes in the sequence, penalizing only nonlinear and drastic fluctuations, making it a more reasonable measure of smoothness than the first-order difference constraint.
[0097] Step S52: Based on the second-order difference values of C traffic flow indicators at the L+1 to L+H prediction time steps, obtain the time-series regularized energy function value.
[0098] In this embodiment, the time-series regularized energy function value can be determined based on the second-order difference values of C traffic flow indicators at the (L+1)th to (L+H)th prediction time steps. Specifically, the time-series regularized energy function... It can be defined as: .
[0099] It should be noted that this embodiment chooses second-order difference instead of first-order difference as the measure of smoothness for a specific technical reason. Using first-order difference as a constraint (i.e., penalty) would be problematic. If the first energy term is used, it will tend to make the predicted sequence approximate a constant straight line, which is inconsistent with the actual behavior of most time series. The second-order difference constraint, however, allows for linear trend changes in the sequence (the second difference of a linear function is always zero), penalizing only sharp nonlinear fluctuations, thus providing a more reasonable and flexible measure of smoothness. Through this energy term, the predicted sequence can be constrained to have smoother and more natural dynamic changes over time without relying on the true label.
[0100] Furthermore, in another alternative implementation, the time-series regularization energy function can also be composed of a gradient sensitivity term of the model output relative to the input perturbation. Let the random projection vector be... Constructing scalar responses Then the gradient-type regular energy can be defined as: This implementation indirectly constrains the stability of the prediction by penalizing the sensitivity of the model output to small perturbations in the input. However, the preferred implementation remains the second-order difference smoothing constraint because it is more computationally efficient (does not require second-order differentiation) and has a more intuitive physical meaning.
[0101] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In this method, step S16 may specifically include steps S61 to S66: Step S61: Starting from the last historical time step, extract a traffic flow test data segment of length H from the traffic flow test data.
[0102] In this embodiment, the frequency domain consistency energy is designed based on an important prior in time series analysis: the frequency characteristics of time series typically exhibit a certain degree of local continuity, meaning that the main periodic components and frequency patterns contained in the input sequence should continue into the predicted sequence in the short term. For example, if the input data exhibits a clear 24-hour daily periodicity, then the subsequent predicted sequence should also reflect a similar periodic pattern. If the frequency domain characteristics of the predicted sequence deviate significantly from those of the input sequence, it usually indicates a problem with the model's prediction quality under the current distribution.
[0103] Specifically, starting from the last historical time step, a traffic flow test data segment of length H is extracted from the traffic flow test data; that is, a segment of the same length as the prediction is extracted from the end of the historical sequence of the input column. The traffic flow test data segment... for: .
[0104] This embodiment selects the tail of the input data rather than any arbitrary segment because the tail data is closest to the prediction interval in time, and its frequency characteristics are most strongly correlated with the prediction interval. Selecting a segment of the same length as the prediction segment ensures that the frequency resolution of the Fourier transform is perfectly aligned on both the input and prediction sides, avoiding frequency mapping problems caused by differences in length.
[0105] Step S62: Perform real-valued fast Fourier transform on the traffic flow test data segments and the first traffic flow prediction data along the time dimension. Based on the real-valued fast Fourier transform results of the traffic flow test data segments, extract the amplitude spectrum and phase spectrum of the traffic flow test data segments. Also, based on the real-valued fast Fourier transform results of the first traffic flow prediction data, extract the amplitude spectrum and phase spectrum of the first traffic flow prediction data.
[0106] In this embodiment, traffic flow test data can be segmented. Perform a real-valued fast Fourier transform along the time dimension to obtain segments of the traffic flow test data. The real-valued Fast Fourier Transform (FFT) results are used to extract the amplitude spectrum and phase spectrum of the traffic flow test data segments based on the FFT results of the traffic flow test data segments. Additionally, the first traffic flow prediction data... Perform a real-valued fast Fourier transform along the time dimension to obtain the first traffic flow prediction data. The real-valued Fast Fourier Transform (FSFT) results of the first traffic flow prediction data are used to extract the amplitude spectrum and phase spectrum of the first traffic flow prediction data.
[0107] Among them, the real-valued Fast Fourier Transform results of the traffic flow test data segments are: The real-value Fast Fourier Transform result of the first traffic flow prediction data is: , For real-valued Fast Fourier Transform operations: .
[0108] In a preferred embodiment, when extracting amplitude spectrum and phase spectrum information, the DC component (the frequency component with K=0, which reflects the mean level of the sequence, is naturally different between the input and the prediction, and constraining it is meaningless).
[0109] Step S63: Select the K frequency indices with the largest amplitude from the amplitude spectrum of the traffic flow test data segments to obtain the main frequency set.
[0110] In this embodiment, a dominant frequency constraint strategy is adopted, rather than imposing constraints on all frequency components. Based on this, the K (K is an integer greater than 0) frequency indices with the largest amplitude values can be selected from the amplitude spectrum of the traffic flow test data segments to obtain the dominant frequency set. .
[0111] Only in this main frequency set Applying consistency constraints has the following advantages: the main frequency components contain the most important periodic information in the sequence, and constraining them can effectively ensure the core consistency of the frequency domain features; at the same time, ignoring minor frequency components with small amplitudes can avoid excessive constraints on noise and weak frequency components, giving the model appropriate degrees of freedom in predicting details.
[0112] Step S64: Based on the amplitude spectra of the traffic flow test data segments and the first traffic flow prediction data, determine the amplitude consistency term on the dominant frequency set.
[0113] In this embodiment, a selected set of main frequencies can be used. Based on the amplitude spectrum of the traffic flow test data segments and the amplitude spectrum of the first traffic flow prediction data, the amplitude consistency term is determined.
[0114] In a specific optional example, the amplitude consistency term The amplitude error term can be expressed by the following formula: ; in, For numerically stable terms, For the c-th traffic flow index in the first traffic flow prediction data, in the... The magnitude of the amplitude of each frequency component For the c-th traffic flow index in the traffic flow test data segment, in the... The modulus of the amplitude of each frequency component.
[0115] This embodiment uses a relative error form (divided by the square of the input amplitude) instead of an absolute error form because the amplitude magnitudes of different frequency components may differ greatly, and the relative error ensures that each main frequency component receives equal constraint.
[0116] Step S65: Based on the phase spectra of the traffic flow test data segments and the first traffic flow prediction data, determine the phase consistency term on the dominant frequency set.
[0117] In this embodiment, a selected set of main frequencies can be used. Based on the phase spectrum of the traffic flow test data segments and the phase spectrum of the first traffic flow prediction data, the phase consistency term is determined.
[0118] In a specific optional example, the phase consistency term The cosine distance metric can be expressed by the following formula: ; in, For the c-th traffic flow index in the first traffic flow prediction data, in the... The phase of each frequency component, The c-th traffic flow index in the traffic flow test data segment is in the... The phase of each frequency component.
[0119] This embodiment uses cosine distance instead of direct phase difference to measure phase difference because the phase angle has a periodicity of [-π, π]. Directly calculating the difference may produce false large differences due to periodic entanglement, while cosine distance naturally handles this periodicity.
[0120] Step S66: Based on the phase consistency term and the amplitude consistency term, obtain the frequency domain consistent energy function value.
[0121] In this embodiment, the frequency domain uniformity energy function value can be obtained based on the phase uniformity term and the amplitude uniformity term. In an optional example, the frequency domain uniformity energy function... Phase consistency term and amplitude consistency term Weighted combination: ;in, The amplitude error term weighting coefficient is used. Preferably, the amplitude term weight is greater than the phase term weight because amplitude determines the intensity of each frequency component and is the main carrier of frequency domain features; although phase information is also important (determining the time alignment of the periodic signal), in adaptive scenarios, the predicted phase may have a natural deviation from the input phase, and excessively strong phase constraints may limit the predictive flexibility of the model.
[0122] In this embodiment, by performing frequency domain transformations on the input tail segment and the prediction result respectively, a set of dominant frequency components is selected from the input tail segment, and the differences in amplitude and phase between the prediction and the input are compared on this set, thereby constructing a frequency domain consistency energy term. Compared with adaptive methods that rely solely on time domain errors, this design enables the model to better maintain the original periodicity and dominant frequency structure of the time series under distribution offset conditions.
[0123] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for predicting distributed offset time series. In this method, the prediction consistency energy function value, the time-series regularization energy function value, and the frequency domain consistency energy function value are each used as a target energy function value; in addition to the above steps, for any target energy function value, steps S71 to S74 may be included, and step S25 may specifically include step S75: Step S71: In the b-th test batch, based on the target energy function value in the b-th test batch, determine the baseline scale of the target energy function value in the b-th test batch.
[0124] This invention addresses the issue of significant differences in numerical dimensions among multiple surrogate optimization objectives, which can lead to an imbalance in the joint optimization direction. When using multiple self-supervised signals to constitute a joint optimization objective, the numerical scales of different signals may differ by several orders of magnitude. Without appropriate scale correction, the larger objective term will dominate the gradient direction, preventing other equally important but smaller constraint terms from playing their proper guiding role. Ultimately, this results in the model updating only along a single constraint direction while ignoring other important constraints.
[0125] In other words, since the predictive consistency energy, temporal regularization energy, and frequency domain consistency energy originate from different structural priors, their numerical scales are usually inconsistent. In actual operation, the original numerical magnitudes of the three energy terms may differ by several orders of magnitude. If the energy terms are directly summed linearly, even if a larger weight coefficient is set for the smaller energy term, its contribution to the total energy gradient may still be much smaller than that of the larger energy term, causing the weight coefficient to fail to intuitively control the relative importance of each term as expected. To address this, this invention introduces an energy scale normalization mechanism.
[0126] Specifically, in the b-th test batch, based on the target energy function value in the b-th test batch, the baseline scale of that target energy function value in the b-th test batch is determined. The baseline scale of a target energy function value in the b-th test batch reflects its typical magnitude in that batch. This baseline scale can be obtained by independently calculating the target energy function value in the b-th test batch in the initial state of the model (i.e., before any adaptive updates have been performed).
[0127] It is understandable that the target energy function value of the b-th test batch is based on... Let K represent the energy function value of the Kth type of target. K can take the value 1, 2 or 3. For example, K value 1 represents the prediction consistency energy function value, K value 2 represents the time-series regularization energy function value, and K value 3 represents the frequency domain consistency energy function value.
[0128] Step S72: Based on the global scale of the target energy function value in the (b-1)th test batch and the baseline scale of the target energy function value in the bth test batch, obtain the global scale of the target energy function value in the bth test batch.
[0129] In this embodiment, a global scale estimate across test batches is also maintained. Specifically, the global scale of the target energy function value in the b-1 test batch can be obtained at least based on the global scale of the target energy function value in the b-1 test batch and the baseline scale of the target energy function value in the b-1 test batch. The global scale of a target energy function value in the b-1 test batch reflects a smooth estimate of the evolution of the target energy function value over time in the b-1 test batch.
[0130] In an optional example, the global scale is obtained by performing an exponential moving average on the scale information of historical batches. Here, the energy function value of the Kth class objective is represented at the global scale of the b-th test batch. It can be expressed by the following formula: ;in, For smoothing coefficients, Let be the baseline scale for the energy function value of the Kth type objective in the bth test batch. The global scale represents the energy function value of the Kth class objective in the (b-1)th test batch, where b is an integer greater than 1. The global scale provides a smooth estimate of the evolution of the magnitude of each energy term over time, capturing the asymptotic changes in energy magnitude caused by variations in data distribution.
[0131] Step S73: Mix the global scale and baseline scale of the target energy function value in the b-th test batch to obtain the normalized scale of the target energy function value in the b-th test batch.
[0132] In this embodiment, the global scale of the target energy function value in the b-th test batch and the baseline scale of the target energy function value in the b-th test batch can be mixed to obtain the normalized scale of the target energy function value in the b-th test batch.
[0133] In one example, the normalized scale of the Kth class objective energy function value in the bth test batch. It can be expressed by the following formula: ;in, This indicates the proportion of the current batch size. Greater than 0.5. The normalization scale combines local information from the current batch and global information from historical batches. The local scale (i.e., the baseline scale) has a larger weight to ensure that normalization is mainly based on the magnitude of the current data; the global scale has a smaller weight to smooth the data and prevent scale abrupt changes caused by a single abnormal batch.
[0134] Step S74: Based on the normalized scale of the target energy function value in the b-th test batch and the target energy function value, obtain the normalized value of the target energy function value.
[0135] In this embodiment, the normalized value of the target energy function in the b-th test batch can be obtained at least based on the normalized scale of the target energy function value in the b-th test batch and the target energy function value in the b-th test batch.
[0136] In one example, the normalized value of the Kth target energy function in the bth test batch. It can be expressed by the following formula: ; in, To prevent stability constants where the denominator is zero, the normalized energy terms are all of similar magnitude, making the weighting coefficients... It can truly and intuitively control the relative importance of each item in the total energy.
[0137] In another optional embodiment, a logarithmic transformation can be further applied to the normalized energy function value to compress the energy range and enhance optimization stability.
[0138] Step S75: Based on the normalized values of the prediction consistency energy function, the time-series regularization energy function, and the frequency domain consistency energy function, update the adaptation parameters of the adaptive traffic flow prediction model to be tested, and obtain the adaptive traffic flow prediction model to be tested.
[0139] In this embodiment, after obtaining the normalized values of each energy function value, the total energy function value can be determined based at least on the normalized values of the prediction consistency energy function value, the time-series regularization energy function value, and the frequency domain consistency energy function value. The adaptive parameters in the adaptive traffic flow prediction model to be tested are updated with the goal of minimizing the total energy function value, until the parameters are fully adapted, and the adaptive traffic flow prediction model to be tested is obtained.
[0140] In an optional example, the total energy function It can be represented as: :in, This represents the normalized value of the prediction consistency energy function. This represents the normalized value of the time-series canonical energy function. The normalized value representing the frequency domain uniformity energy function value; , , These represent the weight coefficients of the corresponding energy terms. The normalized energy terms (marked with a tilde) are used here instead of the original energy terms because the original numerical magnitudes of different energy terms may differ significantly. Normalization ensures that all terms participate in joint optimization on a uniform scale.
[0141] In this embodiment, to avoid imbalance in joint optimization caused by differences in the dimensions and numerical scales of different energy terms, an energy scale normalization mechanism is introduced. Specifically, the baseline scale of each energy term can be estimated for each test batch, and a mixed scale (i.e., a normalized scale) can be formed by combining it with the exponential moving average scale of historical batches. This mixed scale is then used to normalize each energy term. This mechanism allows different energy terms to participate in optimization at a unified scale, thereby improving the stability and controllability of multi-objective joint adaptation. In other words, this embodiment, through an energy scale normalization mechanism combining the current batch scale with the historical global scale, enables energy terms from different sources and with different dimensions to participate in joint optimization at a unified scale, improving the controllability and stability of the multi-objective adaptation process. Compared to a simple linear weighting method, this design gives the weight coefficients a clearer physical meaning and better adjustability.
[0142] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In this method, step S75 may specifically include steps S81 to S85: Step S81: Before the start of each test batch, determine the initial total energy function value based on the adaptive traffic flow prediction model for the test.
[0143] In this embodiment, after the total energy function is constructed, the adaptation parameters are adjusted during the adaptive testing phase. Perform online updates in a finite number of rounds. A gradient-based adaptive optimizer (preferably an Adam-type optimizer) is preferred. Let the... The parameters after the round of updates are Then its update process can be represented as: ;in, This represents the adaptive learning rate during testing. Preferably, a fixed number of rounds are performed within each test batch. The algorithm updates the gradient and records the current total energy function value after each round. To prevent abnormal gradients from causing excessively large update magnitudes and leading to parameter runaway, a gradient norm pruning operation can be performed to reduce the gradient's... The norm is limited to a preset upper limit.
[0144] It should be noted that the number of adaptive rounds during testing... The number of rounds should not be too large or too small. Too few rounds may not be enough for the model to fully adapt to the current test distribution, while too many rounds not only increase computational overhead but may also cause the model to over-optimize on the proxy objective function, deviating from the true optimum. In actual deployment, The value of M should be determined by weighing the real-time requirements and computing resource constraints of the specific application scenario (M is an integer greater than 1).
[0145] Since online updates during testing rely on a surrogate energy function rather than the true future labels, even if the designed energy function generally reflects the prediction quality, it cannot guarantee that every update in each test batch will necessarily lead to a decrease in the true prediction error. Especially in cases of local distribution anomalies, large sample fluctuations, or significant differences between the test samples and the training distribution, simply using the last update state as the final model state for that test batch might directly retain an unfavorable update, leading to a decline in prediction performance. Therefore, this embodiment designs an optimal state rollback decision mechanism to safely control the multi-round online adaptation process within each test batch.
[0146] First, before each test batch begins, based on the adaptive traffic flow prediction model for the test, the normalized values of the initial prediction consistency energy function, the initial time-series regularization energy function, and the initial frequency domain consistency energy function are determined for the current test batch. Then, based on these normalized values, the initial total energy function value for the current test batch is determined.
[0147] Let the adaptable parameter state before the start of each test batch be: Then the corresponding initial total energy function value for: .
[0148] Step S82: In each test batch, take m sequentially from 1 to M, and determine the total energy function value of the m-th round based on the normalized value of the prediction consistency energy function value, the normalized value of the time-series regularized energy function value, and the normalized value of the frequency domain consistency energy function value. Then, update the adaptive parameters of the adaptive traffic flow prediction model to be tested in the m-th round.
[0149] In this embodiment, in each test batch, m is sequentially selected from 1 to M for multiple rounds of adaptive updates. In the m-th round, the normalized values of the prediction consistency energy function, the temporal regularization energy function, and the frequency domain consistency energy function are obtained. Based on these values, the total energy function value for the m-th round is determined. Then, based on the total energy function value for the m-th round, the adaptive parameters of the adaptive traffic flow prediction model for the test are updated for the m-th round until M rounds of updates are completed, resulting in the total energy function value for the M-th round.
[0150] Step S83: Determine the minimum total energy function value from the total energy function value of the M-wheel.
[0151] In this embodiment, after M rounds of updates, a series of intermediate states are obtained. Each round corresponds to a total energy value. The minimum total energy function value can be determined from the total energy function values of the M rounds.
[0152] Throughout the adaptive process, the current optimal total energy value and corresponding parameter states are continuously maintained. The optimal number of rounds is defined. for: .
[0153] Step S84: If the minimum total energy function value is less than the initial total energy function value, the updated model, which uses the minimum total energy function value to adapt the adaptive parameters of the traffic flow prediction model under test, is determined as the traffic flow prediction model that has completed the adaptation under test.
[0154] In this embodiment, after the adaptive process is completed, the minimum total energy function value can be compared with the initial total energy function value. If the minimum total energy function value is less than the initial total energy function value, the updated model, which uses the minimum total energy function value to adjust the adaptive parameters of the traffic flow prediction model before testing, is determined as the traffic flow prediction model that has completed adaptive testing.
[0155] Step S85: If the minimum total energy function value is not less than the initial total energy function value, then the adaptive traffic flow prediction model during the test is used as the adaptive traffic flow prediction model during the test.
[0156] In this embodiment, if the minimum total energy function value is not less than the initial total energy function value, the traffic flow prediction model that has not undergone adaptive parameter adaptation during the test is directly used as the traffic flow prediction model that has completed adaptive parameter adaptation during the test.
[0157] In a specific example, after the adaptation process is complete, the following decision rule is adopted: If Then accept Otherwise, roll back to .
[0158] The essence of this strategy is not "unconditionally using the last update," but rather "selecting the optimal acceptable state from multiple iterations." Therefore, it allows the model to actively adapt on local batches while preventing undesirable drift caused by unsupervised online updates from being forcibly retained. From a technical perspective, this mechanism has at least three important functions. First, it provides a safety valve for test-time online adaptation, ensuring overall model stability even when the surrogate objective is not entirely reliable—in the worst-case scenario, the model can at least revert to its performance level before test-time adaptation. Second, it transforms test-time optimization from "single-point updates" (using only the final state) to "trajectory-based optimization" (selecting the best state from the entire optimization trajectory), improving the success rate of local adaptation because the optimal state does not necessarily appear in the last step. Third, combined with a lightweight adaptation strategy that only updates normalized parameters, it further reduces the risk of catastrophic drift during the testing phase. Therefore, this rollback decision mechanism is not a simple engineering patch, but a crucial component of the stable deployment capability of this embodiment.
[0159] In this embodiment, it is considered that the unsupervised optimization results of some test batches may actually be worse than the original model state. When the surrogate objective and the true prediction error are not completely consistent, there is a risk that after multiple rounds of online updates, although the surrogate objective value decreases, the actual prediction quality of the model may actually deteriorate. If there is no ability to identify and avoid this situation, the model may be incorrectly guided to a worse parameter state in some test batches. Based on this, this embodiment performs a finite number of rounds of online optimization within each test batch and continuously records the parameter state corresponding to the optimal energy. If the optimal state during the adaptation process is better than the pre-adaptation state, the optimal state is accepted; otherwise, the model is rolled back to the pre-adaptation state to suppress the risk of performance degradation caused by updates during unlabeled testing. This rollback mechanism ensures that the adaptation process is "only forward, not backward," and that the model maintains at least the same performance level as when no adaptation is performed, even without adaptive gain. Thus, this embodiment, through the optimal state recording and rollback mechanism, only accepts the update result when the energy after adaptation is better than the energy before adaptation; otherwise, it reverts to the pre-adaptation state. This mechanism effectively reduces the risk of performance degradation that may be caused by unsupervised online updates.
[0160] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In addition to the steps described above, this method may further include steps S91 to S92: Step S91: In reset mode, before the start of each test batch, reset the traffic flow prediction model that has been adapted during the test to the traffic flow prediction model that is adapted during the test.
[0161] In this embodiment, test-time adaptation involves not only parameter updates within a single test batch but also the propagation of parameter states between different test batches. In real-world continuous time series applications, test samples are typically not completely independent but arrive sequentially over time, and adjacent samples may share similar distribution characteristics. To address this characteristic, this embodiment designs two cross-batch parameter propagation mechanisms. Let the first... The final accepted parameter status for each test batch is as follows: .
[0162] The first method is the reset mode. In reset mode, before the start of each test batch, the traffic flow prediction model that has completed its adaptive transformation during the test is reset to the traffic flow prediction model that was adapted before the test; that is, before the start of each test batch, the model is restored to the global initial state saved before the start of the test. This mode is suitable for scenarios where there are significant differences between test batches. Its advantage is that each batch is completely independent, with no error accumulation, resulting in more robust results. For example, traffic flow prediction is suitable for this reset mode.
[0163] Step S92: In cumulative mode, the traffic flow prediction model that has completed the test time adaptation in the previous test batch is used as the traffic flow prediction model to be tested in the current test batch.
[0164] In this embodiment, the second method is the cumulative mode. In the cumulative mode, the traffic flow prediction model that has completed its adaptive testing in the previous test batch can be used as the traffic flow prediction model to be tested in the current test batch. That is, the parameter state finally accepted in the previous batch is directly used as the starting state of the next batch. This mode is suitable for continuous scenarios where the distribution of test data drifts slowly over time. Since subsequent batches are usually closer to the previous batch in statistical characteristics, retaining the distribution adaptation information already obtained from the previous batch helps the model form a more stable dynamic tracking capability in a continuously drifting environment. For example, charge prediction is suitable for this cumulative mode.
[0165] In conjunction with any of the above embodiments, in one implementation, the present invention also provides an energy-driven online adaptive method for distributed migration time series prediction. In this method, in addition to the steps described above, steps S101 to S104 may also be included, and step S25 may specifically include step S105: Step S101: Generate negative traffic flow test data based on traffic flow test data.
[0166] In this embodiment, in addition to the aforementioned energy function, a comparative energy optimization mechanism can be introduced to enhance the energy function's ability to distinguish between reasonable and unreasonable samples. The basic idea of this mechanism is not only to require a reduction in the energy corresponding to the current test sample, but also to require a higher energy for artificially constructed negative samples, thereby forming a discriminative optimization objective. Specifically, for negative samples, negative traffic flow test data can be generated based on traffic flow test data. This negative traffic flow test data, compared to the traffic flow test data, exhibits unreasonable numerical jumps and / or discontinuous trends in its changing pattern.
[0167] In one optional specific example, negative samples can be generated through a stochastic dynamics process based on the gradient of the energy function and noise perturbation. Preferably, stochastic gradient Langevin dynamics (SGLD) can be used for sampling, assuming the initial state of the negative traffic flow test data is... Then the first Step sampling update can be represented as: ; in, The sampling step size, For random noise, For the first +1 step sampling of negative traffic flow test data For the first Negative traffic flow test data obtained from step sampling. For traffic flow test data, For gradient, To predict the consistency energy function, and to ensure that the sampling results fall within a reasonable range, interval pruning can be performed on the sampling results: ;in, For the cropping operation, and The range is determined based on the statistical range of the test input data (i.e., traffic flow test data). In another optional implementation, a persistent initialization method can be used, where the negative samples (negative traffic flow test data) obtained in the previous test batch are used as the initial state of the negative samples in the next batch, in order to improve sampling continuity and efficiency.
[0168] Step S102: Input the negative traffic flow test data into the adaptive traffic flow prediction model under test to obtain the third traffic flow prediction data.
[0169] In this embodiment, negative traffic flow test data can be input into the adaptive traffic flow prediction model for the test time to obtain the third traffic flow prediction data output by the adaptive traffic flow prediction model for the test time.
[0170] Step S103: Based on the negative traffic flow test data and the third traffic flow prediction data, obtain the negative prediction consistency energy function value.
[0171] In this embodiment, the negative prediction consistency energy function value can be obtained based on negative traffic flow test data and third traffic flow prediction data. The specific implementation method for obtaining the negative prediction consistency energy function value based on negative traffic flow test data and third traffic flow prediction data is the same as or similar to the specific implementation method for obtaining the prediction consistency energy function value based on first traffic flow prediction data and traffic flow test data, and can be referred to the above embodiments, so it will not be repeated here.
[0172] Step S104: Based on the negative prediction consistency energy function value and the prediction consistency energy function value, obtain the comparative energy value.
[0173] In this embodiment, a comparative energy value can be obtained based on the negative prediction consistency energy function value and the prediction consistency energy function value.
[0174] In a preferred example, the comparative energy value It can be represented using a hinge with gaps: ;in, For interval parameters, For constructing negative traffic flow test data, For traffic flow test data, To predict the uniformity energy function value, This represents the negative prediction consistency energy function value.
[0175] Step S105: Based on the comparative energy value, the temporal regular energy function value, and the frequency domain consistent energy function value, update the adaptation parameters of the adaptive traffic flow prediction model to be tested, and obtain the adaptive traffic flow prediction model to be tested.
[0176] In this embodiment, after obtaining the comparative energy value, the total energy function value can be determined based on the comparative energy value, the time-series regularized energy function value, and the frequency domain consistent energy function value. The adaptive parameters in the adaptive traffic flow prediction model to be tested are updated with the goal of minimizing the total energy function value, until the parameters are fully adapted, and the adaptive traffic flow prediction model to be tested is obtained.
[0177] In an optional example, the total energy function It can be expressed by the following formula: . This represents the normalized value of the time-series canonical energy function. The normalized value representing the frequency domain uniformity energy function value; , These represent the weighting coefficients of the corresponding energy terms.
[0178] In one embodiment, such as Figure 2 As shown, Figure 2 This is a schematic diagram of an overall architecture for energy-driven online adaptive prediction of distributed offset time series, as illustrated in an embodiment of the present invention. Figure 2 In this model, the base prediction model is an adaptive traffic flow prediction model obtained by dividing the parameters of the trained traffic flow prediction model into frozen parameters and adaptive parameters, and then testing the model. In the base prediction model, the yellow part represents the adaptive parameters, and the blue-purple part represents the frozen parameters. The normalization parameter selection module allows filtering of the adaptive and frozen parameters; the adaptive parameters (i.e., the updated parameters in the figure) include at least: layer normalization scaling parameters, layer normalization bias parameters, and reversible instance normalization layer parameters (preferred); the frozen parameters are all parameters in the model except for the adaptive parameters, which remain frozen.
[0179] Figure 2Historical data (i.e., traffic flow test data) can be input into the basic prediction model to obtain initial prediction results (i.e., first traffic flow prediction data). The historical data input can be processed through the time series enhancement module to obtain enhanced traffic flow test data, which can then be input into the basic prediction model to obtain second traffic flow prediction data.
[0180] exist Figure 2 The multidimensional energy function construction module includes three sub-modules: prediction consistency energy, time-series regularized energy, and frequency-domain consistency energy. Specifically, the prediction consistency energy construction sub-module can construct a boundary continuity energy function based on the first traffic flow prediction data and traffic flow test data, construct a robust consistency energy function based on the second traffic flow prediction data and the first traffic flow prediction data, and finally construct the prediction consistency energy function based on the boundary continuity energy function and the robust consistency energy function.
[0181] exist Figure 2 In the temporal regularized energy construction submodule, a temporal regularized energy function can be constructed based on the first traffic flow prediction data; Figure 2 In the frequency domain consistent energy construction submodule, a frequency domain consistent energy function can be constructed based on the first traffic flow prediction data and traffic flow test data. Then, based on the multi-dimensional energy function values (prediction consistent energy function value, time-series regularized energy function value, and frequency domain consistent energy function value), the total energy function is obtained by summing through weight parameters. Minimizing the total energy function allows for parameter adaptation of the basic prediction model.
[0182] Specifically, for each energy function, an energy scale normalization module can normalize the multidimensional energy function values to improve the controllability and stability of the multi-objective adaptation process. Furthermore, during parameter adaptation based on the multidimensional energy function, a multi-step online optimization module updates the updatable model parameters based on the normalized energy minimization. Finally, an optimal state rollback module ensures that the updated result is only accepted when the adapted energy is better than the pre-adaptation energy; otherwise, the system reverts to the pre-adaptation state to effectively reduce the performance degradation risk that may arise from unsupervised online updates. Ultimately, the final result is generated based on the optimal parameter state.
[0183] In summary, the present invention performs the following processing flow on the input test samples during the testing phase: obtaining the current test input sample; selecting a small number of normalized parameters from the basic prediction model that can participate in the update during the testing phase; constructing a time-series augmented sample for the current test sample; establishing a multidimensional energy function based on the original input, augmented input, and model prediction results; performing scale normalization on the multidimensional energy function; performing finite-step online optimization on a small number of parameters using the normalized total energy; deciding whether to accept the update result based on the energy change before and after adaptation; and outputting the final prediction result.
[0184] The above process clearly defines the main technical line of this invention as follows: it is not retraining, not supervised learning, but rather rapid adaptation to the current test distribution by updating parameters within a small range and minimizing the unlabeled energy function during the testing phase.
[0185] The method proposed in this invention allows for online adjustment of a small number of parameters in the model during the model inference phase, without access to real future labels, based solely on information from the current test samples. This improves the model's prediction accuracy and adaptive stability under test distribution shift scenarios. This invention is applicable to time series prediction models with learnable normalized parameters, and is preferably applicable to multivariate time series prediction models based on the Transformer architecture. In a preferred embodiment, the base prediction model can be a UniTST model. This UniTST model receives historical time series inputs and outputs future predicted sequences, thus serving as the carrier model and validation base for the test-time adaptive method of this invention. However, the core of this invention is not limited to a specific time series prediction network structure, but rather to proposing a general test-time adaptive mechanism. This mechanism does not depend on the specific internal structure of UniTST and can be further extended to other time series prediction models with learnable normalized parameters.
[0186] In a preferred embodiment, the energy-driven online adaptive method of this embodiment can be implemented according to the following steps.
[0187] Step S1: Obtain the base prediction model. Obtain the base prediction model that has been trained offline on the training data. The basic prediction model has been optimized for parameters through a standard training process and is capable of generating future prediction sequences based on historical time series inputs. In a preferred embodiment, the basic prediction model may be the UniTST model.
[0188] Step S2: Selecting parameters for testing. The basic prediction model parameters are divided into frozen parameters. and adaptation parameters ,in It remains unchanged during the testing phase. Online updates are permitted during the testing phase. Preferably, only normalization-related parameters (including scaling and bias parameters in the reversible instance normalization layer, layer normalization layer, and / or batch normalization layer) are selected as adaptation parameters.
[0189] Step S3: Construct enhanced input samples. For the current test sample... Execution timing awareness enhancement is obtained Preferred methods include time-dependent noise injection (generating time-dependent noise through a first-order autoregressive process and superimposing it after adaptive scaling) and time mask perturbation (continuous block mask or random point mask, combined with mean filling, noise filling or interpolation filling). Step S4: Construct a multidimensional energy function. Based on the original input. Enhance input And construct the total energy function from the model prediction results: Among them, prediction consistency energy constrains the prediction consistency and boundary continuity of the original and enhanced inputs; temporal regularization energy constrains the temporal smoothness of the prediction sequence; and frequency domain consistency energy constrains the consistency of the prediction sequence with the dominant frequency of the input tail segment.
[0190] Step S5: Perform energy scale normalization. Estimate the baseline scale of each energy term in the current test batch, combine it with the global scale of the exponential moving average of historical batches to form a mixed scale, and then use the mixed scale to normalize each energy term, so that energy terms with different dimensions participate in joint optimization under a unified scale.
[0191] Step S6: Perform a finite-step online adaptive update. Adjust the adaptation parameters... implement The gradient update is performed step-by-step, preferably using a gradient-based adaptive optimizer, and the current total energy value is recorded after each update step. Norm pruning of the gradient is also preferred to limit the magnitude of the update per step.
[0192] Step S7: Optimal state rollback decision. During the adaptation process, continuously record the parameter state with the minimum total energy. .like If the optimal state is accepted as the final parameter, then the state before adaptation will be rolled back. .
[0193] Step S8: Output the final prediction result and handle cross-batch propagation. Generate the final prediction result based on the model parameters after the rollback decision. When entering the next test batch, the initial parameter state is determined according to the selected mode (reset mode restores the global initial state, or cumulative mode passes the current parameters).
[0194] Step S4a (optional): In an optional implementation, negative samples can be generated using SGLD based on the current test samples before step S6, and a comparative energy loss can be constructed as an additional optimization objective.
[0195] In a preferred embodiment, this embodiment is deployed on the UniTST time series prediction model. The UniTST model includes the following main components: an input normalization module, which uses Reversible Instance Normalization (RevIN) to independently normalize each input sample at the instance level to reduce the differences in statistical scales between different samples; a time segment partitioning and embedding module, which divides the normalized input sequence into several equal-length time segments (Patches) through left padding and sliding window operations, and maps each Patch to a high-dimensional embedding space through one-dimensional convolution; a positional encoding module, which uses a hybrid scheme of fixed sinusoidal positional encoding and learnable positional encoding to add positional information to each Patch; a Transformer encoding module, which consists of multiple stacked standard Transformer encoder layers and adopts a channel-independent strategy, that is, the Patch sequence of each variable is independently input into the encoder for processing to avoid direct interaction between channels; and a prediction decoding module (linear prediction head), which flattens the encoded Patch features and maps them to the prediction length through linear projection, and finally restores the original data scale through inverse normalization of RevIN.
[0196] First, the UniTST model is trained offline on the training dataset to obtain a basic prediction model. At the start of the testing phase, the model parameters are divided into frozen parameters. and adaptation parameters ,in These are the learnable scaling and bias parameters in the RevIN and LayerNorm layers.
[0197] For each test batch The following process is executed: First, the baseline scale of each energy term is calculated based on the current model parameters, and a normalized scale is formed; then, temporal augmentation is performed on the current test sample to obtain... The system constructs a prediction consistency energy (including a robust consistency term and a differential boundary continuity term) based on the prediction results of the original input and the enhanced input. Simultaneously, it constructs a time-series regularization energy based on the second-order difference of the predicted sequence itself, and a frequency-domain consistency energy based on the comparison of the Fourier spectra of the input tail segment and the predicted sequence. These energy terms are then scaled to form the total energy function. Next, a finite number of online updates are performed on the normalized parameters, and the optimal state is recorded. After adaptation, the final parameters are determined based on the rollback decision, and the prediction results are output.
[0198] In this embodiment, UniTST serves only as a carrier for the basic prediction model. The innovation of this invention lies not in the main network structure of UniTST, but in an energy-driven test-time adaptive mechanism that can be independently attached to the basic prediction model. Provided that the basic model can receive historical time series inputs and output future prediction sequences, and that it possesses learnable normalized parameters, this invention can also be extended to other time series prediction models with learnable normalized parameters, preferably Transformer-based models.
[0199] In addition, in a specific experimental configuration, the parameters can be set as follows.
[0200] UniTST model parameters: Input sequence length Predicted length Alternatively, the values can be (192, 336, 720), with a patch length of 16, a stride of 8, a model dimension of 64, 8 attention heads, 2 Transformer encoder layers, a feedforward network dimension of 128, and a Dropout rate of 0.1. The training phase uses the Adam optimizer, Huber loss function, and an initial learning rate of... Batch size 128, early stop strategy enabled (patience value 3).
[0201] Adaptive parameters during testing: Total energy weight , , Robust consistency weights in predicted consistency energy Boundary continuity weights Time decay coefficient Minimum weight lower bound . Noise correlation coefficient Noise standard deviation The continuous block mask ratio is 0.05, the number of mask segments is 2, and mean fill is used. The number of frequency domain main frequencies... Amplitude weight EMA smoothing coefficient Current batch size proportion The Adam optimizer was used during testing, with a learning rate of [missing information]. Each batch updates 30 times, with a gradient pruning cap of 5.0. The default mode uses cumulative mode to pass parameters across batches.
[0202] The parameters described above are merely an exemplary configuration and are not the only feasible set of parameters for the method of this invention. These parameters can be adjusted according to actual needs on other datasets, other prediction lengths, or other underlying prediction models.
[0203] As can be seen, the time-series test-time adaptive method proposed in this embodiment of the invention not only constructs an effective label-free optimization objective, but also possesses a controlled parameter update range, a stable multi-objective scale normalization mechanism, and a safe decision-making mechanism that can suppress deteriorating updates. These three capabilities are indispensable and together constitute the fundamental guarantee for the reliable operation of the test-time adaptive method in real-world scenarios.
[0204] Furthermore, the present invention aims to propose an energy-driven online adaptive method for distribution-shifted time series prediction, addressing the performance degradation of relevant prediction models under test distribution-shifted conditions. Another objective of the present invention is to propose a mechanism that allows for finite-step online adaptation of the model during the inference phase without requiring real future labels, enabling the model to dynamically adjust a small number of parameters based on the current test samples, thereby improving the prediction stability and accuracy of the model in test distribution-shifted environments. A further objective of the present invention is to introduce a multi-dimensional energy function tailored to the characteristics of time series prediction tasks, design an energy scale normalization mechanism, and an optimal state rollback mechanism by updating only the normalized correlation parameters in the model, thus balancing online adaptation efficiency, parameter update stability, and prediction result reliability.
[0205] In summary, this invention proposes an energy-driven online adaptive method for time series forecasting with distribution shifts, belonging to the field of time series forecasting and model adaptation. This method addresses the performance degradation of related time series forecasting models during the testing phase when faced with data distribution shifts, and the difficulty of directly applying adaptive methods during testing to continuous value forecasting tasks. It proposes constructing a multi-dimensional energy function based on the current test samples during the inference phase, and performing a finite-step online update only on the normalized correlation parameters in the basic forecasting model. The multi-dimensional energy function includes prediction consistency energy, temporal regularization energy, and frequency domain consistency energy, constructing label-free optimization objectives from three dimensions: prediction robustness and boundary continuity, temporal smoothness, and frequency domain dominant frequency consistency, respectively. This invention unifies the scale of different energy terms through an energy scale normalization mechanism and suppresses the performance degradation risk caused by label-free online updates through optimal state recording and rollback mechanisms. This invention is applicable to time series forecasting models with learnable normalized parameters.
[0206] This invention does not propose a new static model structure for a specific prediction network, but rather a test-time adaptive mechanism that can be independently deployed on top of a base prediction model. This mechanism is driven by a multidimensional energy function, relies on online updates of a small number of normalized parameters, and uses energy scale normalization and optimal state rollback as stability guarantees. It can effectively improve the adaptive capability and prediction performance of time series prediction models in real-world testing scenarios when faced with distribution shifts. The UniTST model is primarily used in this invention as a preferred benchmark prediction model and embodiment to illustrate the implementation and application effects of this invention in practical time series prediction tasks.
[0207] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.
[0208] The terms "first," "second," etc., used in the specification and claims of this invention are used to distinguish similar objects and are not used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.
[0209] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of the present invention is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0210] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.
[0211] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.
Claims
1. An energy-driven online adaptive method for distribution-biased time series prediction, characterized in that, The method includes: Using traffic flow training data, the time series prediction model is trained to obtain the trained traffic flow prediction model. The parameters of the trained traffic flow prediction model are divided into frozen parameters and adaptive parameters to obtain an adaptive traffic flow prediction model for testing. Traffic flow test data with a distribution offset relative to the traffic flow training data is input into the adaptive traffic flow prediction model to be tested to obtain the first traffic flow prediction data. The traffic flow test data includes: the actual values of C traffic flow indicators at L historical time steps; the first traffic flow prediction data includes: the first indicator prediction values of C traffic flow indicators at the L+1 to L+H prediction time steps. Based on the first traffic flow prediction data and traffic flow test data, the boundary continuity energy function value is obtained. The boundary continuity energy function value represents the continuity between the initial change trend of the first traffic flow prediction data and the final change trend of the traffic flow test data. Based on the first traffic flow prediction data, the time-series regularized energy function value is obtained. The time-series regularized energy function value characterizes the temporal smoothness of the first traffic flow prediction data. Based on the first traffic flow prediction data and traffic flow test data, the frequency domain consistent energy function value is obtained. The frequency domain consistent energy function value represents the continuity between the frequency characteristics of the initial segment of the first traffic flow prediction data and the frequency characteristics of the final segment of the traffic flow test data. Based on the boundary continuity energy function value, the time series regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test. Input traffic flow test data or actual traffic flow data that does not have a distribution offset relative to the traffic flow test data into the traffic flow prediction model that has completed its adaptive test, and obtain the traffic flow prediction results.
2. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 1, wherein, The method further includes: Time-series augmentation is performed on traffic flow test data to obtain augmented traffic flow test data. The augmented traffic flow test data has the same semantics as the traffic flow test data, and the augmented traffic flow test data has local perturbations relative to the traffic flow test data. The augmented traffic flow test data includes: perturbation values of C traffic flow indicators at L historical time steps. The enhanced traffic flow test data is input into the adaptive traffic flow prediction model under test to obtain the second traffic flow prediction data; the second traffic flow prediction data includes: the second index prediction values of C traffic flow indicators at the L+1 to L+H prediction time steps. Taking i sequentially from 1 to H and c sequentially from 1 to C, based on the difference between the predicted value of the second indicator and the predicted value of the first indicator at the L+i prediction time step of the c-th traffic flow indicator, the robust consistency energy function value is obtained. The robust consistency energy function value represents the consistency between the first traffic flow prediction data and the second traffic flow prediction data. Based on the robust consistency energy function value and the boundary continuity energy function value, the predicted consistency energy function value is obtained; Based on the boundary continuity energy function value, the time-series regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test, including: Based on the predictive consistency energy function value, the temporal regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test.
3. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 1, wherein, Based on the first traffic flow prediction data and traffic flow test data, the boundary continuity energy function values are obtained, including: From the traffic flow test data, extract the actual values of C traffic flow indicators at the last historical time step, and extract the actual values of C traffic flow indicators at the second-to-last historical time step to determine the final trend of traffic flow test data. From the first traffic flow prediction data, extract the predicted values of C traffic flow indicators at the first prediction time step, and combine them with the actual values of the C traffic flow indicators at the last historical time step to determine the initial trend of change in the first traffic flow prediction data; the first prediction time step and the last historical time step are two adjacent time steps. The boundary continuity energy function value is determined based on the ending trend of traffic flow test data and the starting trend of the first traffic flow prediction data.
4. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 2, wherein, Time-series augmentation is performed on traffic flow test data to obtain augmented traffic flow test data, including: Generate noisy data with time correlation over L historical time steps; Based on the traffic flow test data, determine the scaling factor to be adapted to the traffic flow test data; Based on the scaling factor adapted to the traffic flow test data, the noise data is scaled, and the scaled noise data is superimposed on the traffic flow test data to obtain traffic flow test data with injected time-related noise. Time masking enhancement is performed on traffic flow test data with injected time-related noise to obtain enhanced traffic flow test data.
5. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 1, wherein, Based on the first traffic flow prediction data, the time-series regularized energy function values are obtained, including: Take i from 1 to H and c from 1 to C in sequence. Extract the first index prediction value of the c-th traffic flow index at the L+i-1 prediction time step, the L+i-1 prediction time step, and the L+i+1 prediction time step from the first traffic flow prediction data to determine the second difference value of the c-th traffic flow index at the L+i prediction time step. Based on the second-order difference values of C traffic flow indicators at the L+1 to L+H prediction time steps, the time-series regularized energy function value is obtained.
6. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 1, wherein, Based on the first traffic flow prediction data and traffic flow test data, the frequency domain consistency energy function values are obtained, including: Starting from the last historical time step, extract a traffic flow test data segment of length H from the traffic flow test data; Real-valued Fast Fourier Transform (FSFT) is performed on the traffic flow test data segments and the first traffic flow prediction data along the time dimension. Based on the FFT results of the traffic flow test data segments, the amplitude spectrum and phase spectrum of the traffic flow test data segments are extracted. Also, based on the FFT results of the first traffic flow prediction data, the amplitude spectrum and phase spectrum of the first traffic flow prediction data are extracted. The set of dominant frequencies is obtained by selecting the K frequency indices with the largest amplitude from the amplitude spectrum of the traffic flow test data segments. Based on the amplitude spectra of the traffic flow test data segments and the first traffic flow prediction data, an amplitude consistency term is determined on the dominant frequency set; Based on the phase spectra of the traffic flow test data segments and the first traffic flow prediction data, a phase consistency term is determined on the dominant frequency set; Based on the phase consistency term and the amplitude consistency term, the frequency domain consistent energy function value is obtained.
7. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 2, wherein, The method further includes using the predicted consistent energy function value, the time-series regularized energy function value, and the frequency-domain consistent energy function value as target energy function values, respectively. In the b-th test batch, based on the target energy function value in the b-th test batch, the baseline scale of the target energy function value in the b-th test batch is determined. The baseline scale of the target energy function value in the b-th test batch reflects the typical magnitude of the target energy function value in the b-th test batch. Based on the global scale of the target energy function value in the (b-1)th test batch and the baseline scale of the target energy function value in the bth test batch, the global scale of the target energy function value in the bth test batch is obtained. The global scale of the target energy function value in the bth test batch reflects a smooth estimate of the evolution of the target energy function value over time in the bth test batch. The global scale and baseline scale of the target energy function value in the b-th test batch are mixed to obtain the normalized scale of the target energy function value in the b-th test batch. Based on the normalized scale of the target energy function value in the b-th test batch and the target energy function value, the normalized value of the target energy function value is obtained. Based on the predictive consistency energy function value, the temporal regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test, including: Based on the normalized values of the predictive consistency energy function, the time-series regular energy function, and the frequency-domain consistency energy function, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test.
8. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 7, characterized in that, Based on the normalized values of the predictive consistency energy function, the time-series regularized energy function, and the frequency-domain consistent energy function, the adaptation parameters of the adaptive traffic flow prediction model for testing are updated to obtain the fully adaptive traffic flow prediction model for testing, including: Before the start of each test batch, the initial total energy function value is determined based on the adaptive traffic flow prediction model for the test period; In each test batch, m is sequentially selected from 1 to M. Based on the normalized value of the prediction consistency energy function value, the normalized value of the time-series regularized energy function value, and the normalized value of the frequency domain consistency energy function value in the m-th round, the total energy function value in the m-th round is determined, and the adaptive parameters of the adaptive traffic flow prediction model to be tested are updated in the m-th round. Determine the minimum total energy function value from the total energy function value of round M; If the minimum total energy function value is less than the initial total energy function value, the updated model will be determined as the adaptive traffic flow prediction model for the test, based on the adaptation parameters of the adaptive traffic flow prediction model with the minimum total energy function value. If the minimum total energy function value is not less than the initial total energy function value, then the adaptive traffic flow prediction model during the test will be used as the adaptive traffic flow prediction model during the test.
9. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 7, wherein, The method further includes: In reset mode, before the start of each test batch, the traffic flow prediction model that has been adapted for testing is reset to the traffic flow prediction model that is adapted for testing. In cumulative mode, the traffic flow prediction model that has completed its test time adaptation in the previous test batch is used as the traffic flow prediction model to be tested in the current test batch.
10. The energy-driven online adaptive method for distribution-biased time series forecasting according to claim 2, wherein, The method further includes: Based on traffic flow test data, negative traffic flow test data is generated. Compared with the traffic flow test data, the negative traffic flow test data has unreasonable numerical jumps and / or discontinuous trends. The negative traffic flow test data is input into the adaptive traffic flow prediction model under test to obtain the third traffic flow prediction data. Based on negative traffic flow test data and third traffic flow prediction data, the negative prediction consistency energy function value is obtained; Based on the negative prediction consistency energy function value and the prediction consistency energy function value, the comparative energy value is obtained; Based on the predictive consistency energy function value, the temporal regularization energy function value, and the frequency domain consistency energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test, including: Based on the comparative energy value, the temporal regular energy function value, and the frequency domain consistent energy function value, the adaptation parameters of the adaptive traffic flow prediction model under test are updated to obtain the adaptive traffic flow prediction model under test.