A cumulative time error prediction method based on time window LSTM model

By using the LSTM model based on time window in the sensor network, the sensor time error is predicted and corrected, the cumulative error problem generated by the internal clock of the sensor is solved, and high-precision time synchronization and optimization of computing resources are achieved.

CN119558348BActive Publication Date: 2025-05-13SIMETRIC SEMICON SOLUTIONS CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510112571.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-05-13
Estimated Expiration
2045-01-24

AI Technical Summary

Technical Problem

In sensor networks, the internal clock of the sensor will generate cumulative errors over time, especially in application scenarios where long-term operation or high-precision time synchronization is required, these errors will significantly affect the timeliness of data, accuracy and overall system performance. The prior art is difficult to provide sufficient correction accuracy and reliability, and there is a lot of waste of computing resources.

Method used

The LSTM model based on the time window is adopted, and the sensor's historical data is obtained, time feature processing is performed, and historical data in the time window of a certain length is selected as a time series, and it is modeled and trained, the difference between sensor time and standard time is predicted, and real-time or periodic correction is made based on the prediction results.

Benefits of technology

By introducing the LSTM model, prediction strategies can be adjusted in real time, adapted to changes in the sensor working environment, significantly reduced the consumption of computing resources, and achieved high-precision time synchronization to ensure that the sensor time is consistent with the standard time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119558348B_ABST
    Figure CN119558348B_ABST
Patent Text Reader

Abstract

The present invention provides a cumulative time error prediction method based on a time window LSTM model, the method acquires historical data of a sensor; performs time feature processing on the historical data, and selects historical data within a time window of a certain length as a time series; uses an LSTM model to model and train the time series, the input of the LSTM model is the change of the sensor time error within the time window, and the output is the difference between the current sensor time and the standard time; the sensor time is corrected according to the prediction result of the LSTM model. The actual time is separated from the time on the sensor, which simplifies the time synchronization process; through the selection of the time window, the consumption of computing resources is significantly reduced while ensuring the prediction accuracy; through the correction mechanism, high-precision synchronization is achieved while optimizing computing resources to ensure that the sensor time is consistent with the standard time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of sensor data processing, and in particular relates to a cumulative time error prediction method based on a time window LSTM model. Background Art

[0002] In sensor networks, especially those using ultrasonic transducers, the sensor's internal clock will accumulate errors over time. This error is caused by a small but persistent deviation between the sensor's internal clock and the actual standard time. Over time, these small deviations will gradually accumulate, causing the difference between the time recorded by the sensor and the actual time to become larger and larger. Especially in applications that require long-term operation or high-precision time synchronization, the accumulated errors may become very significant, affecting the timeliness, accuracy and overall performance of the system.

[0003] In the prior art, the time error of the sensor is usually corrected through physical models or simple linear interpolation methods. However, the physical model relies on the idealized assumption of the clock drift mechanism and cannot accurately reflect the complex changes in the actual environment. When the sensor works for a long time, the error growth pattern may be nonlinear, so it is difficult to provide sufficient correction accuracy and reliability. In addition, the existing model has the problem of large amount of data calculation and waste of resources. Summary of the invention

[0004] In order to solve the problems existing in the above-mentioned prior art, the present invention provides a cumulative time error prediction method based on a time window LSTM model, the method comprising:

[0005] Acquire historical data of the sensor, wherein the historical data includes a difference between the sensor time and a reference time and environmental data of the sensor;

[0006] Performing time feature processing on the historical data, and selecting the historical data within a time window of a certain length as a time series, wherein each time window contains W consecutive time steps;

[0007] The time series is modeled and trained using an LSTM model, wherein the input of the LSTM model is the sensor time change within the time window, and the output is the difference between the current sensor time and the standard time;

[0008] The sensor time is corrected according to the prediction results of the trained LSTM model.

[0009] Based on the above solution, the time feature processing includes:

[0010] Calculate the working time of the sensor from the start time to the current time Δt = tsensor -t sensor_start ; Collect actual standard time t actual , and calculate the actual time ΔT = t from the start of the sensor to the current moment actual -t actual_start , the error between sensor time and actual time D=ΔT-Δt;

[0011] Among them, t sensor is the current time of the sensor, t sensor_start is the start time of the sensor, t actual_start The actual start time.

[0012] Based on the above scheme, the actual standard time t actual It is obtained through the NTP protocol.

[0013] Based on the above scheme, the actual duration ΔT is used as input data and the error D is used as output data to train the LSTM model.

[0014] Based on the above scheme, the size of the time window W is selected according to the characteristics of the cumulative error of the sensor changing over time to capture the long-term dependency of the time series, and the window length with the smallest prediction error is selected through experimental verification.

[0015] Based on the above solution, the time window is created as follows:

[0016] Select the most recent W time points from the historical data to form a time series as the input of the LSTM model; each time the window moves forward k time steps, multiple input-output pairs are generated for training the LSTM model; the entire time series is traversed by sliding the window to ensure that each time window contains W consecutive time steps, where W and k are positive constants.

[0017] Based on the above scheme, the LSTM model structure is:

[0018] The input layer receives the time window data of length W, each time step contains ΔT, D and other relevant environmental data;

[0019] One or more LSTM layers to capture long-term and short-term dependencies in time series;

[0020] Dense layers are used to map the output of the LSTM layer to the final predicted value.

[0021] On the basis of the above scheme, the amendments include:

[0022] The LSTM model predicts the error D between the current sensor and the standard time based on the input time window data.pred ; Through the prediction error D pred Correct the sensor time: t sensor_corrected = t sensor + D pred .

[0023] On the basis of the above scheme, the correction is a real-time correction. Every time a new timestamp is received, the LSTM model is immediately used to predict the error at the current moment, and an immediate correction is performed based on the prediction result.

[0024] On the basis of the above scheme, the correction is a regular correction. According to the set period, all timestamps and error data in the past period are collected; the LSTM model is used to batch predict the error at each time point, and the sensor time is corrected in batches.

[0025] Compared with the prior art, the present invention has the following beneficial effects: by introducing the LSTM model, the prediction strategy can be adjusted in real time through online learning and incremental updating to adapt to changes in the sensor working environment, and the actual time can be separated from the time on the sensor, simplifying the time synchronization process; by selecting the time window, the consumption of computing resources can be significantly reduced while ensuring the prediction accuracy; by the real-time correction or periodic correction mechanism, high-precision synchronization can be achieved while optimizing computing resources to ensure that the sensor time is consistent with the standard time. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A schematic diagram of the method flow provided for this application;

[0027] Figure 2 A schematic diagram of the data acquisition and processing flow provided in the embodiment of the present application; DETAILED DESCRIPTION

[0028] The invention is further described below in conjunction with specific embodiments.

[0029] The present invention provides a cumulative time error prediction method based on a time window LSTM model for sensor time synchronization. The method uses a long short-term memory network (LSTM) model to model and predict the time deviation of the sensor, correct the sensor time error in real time, and ensure high-precision synchronization of the system time.

[0030] like Figure 1 and Figure 2 As shown, the method comprises the following steps:

[0031] S101, obtaining sensor historical data and performing time feature processing, including:

[0032] Collect the current time of the sensor: Get the current time t of the sensor sensor ;

[0033] According to this application, the timestamp of the sensor at the current moment is obtained through the internal clock of the sensor;

[0034] Recording start time: the start time t of recording sensor sensor_start and the actual start time t actual_start ;

[0035] Calculate the working time: Calculate the working time of the sensor from the start time to the current time Δt = t sensor −t sensor_start ; This value reflects the passage of time as recorded by the sensor's internal clock;

[0036] Collect actual standard time: Get the actual standard time t actual ;

[0037] Calculate the time difference: Calculate the actual time ΔT = t from the start of the sensor to the current moment actual -t actual_start ; This value reflects the passage of actual standard time.

[0038] Preferably, the actual standard time when the sensor starts working can be obtained through the NTP protocol or other standard time sources (such as GPS, PTP, etc.) actual ;

[0039] Based on the above steps, the error D = ΔT - Δt between the sensor time and the actual time is obtained; this error reflects the difference between the sensor's internal clock and the standard time.

[0040] S102, using the actual time length ΔT and error D of the sensor as input and output features of the LSTM model respectively, to construct the LSTM model;

[0041] According to the clock drift characteristics of the sensor and the accuracy requirements of time synchronization in different application scenarios, select the appropriate time window length, and verify through experiments, and select the window length W that minimizes the prediction error according to the model performance. If the clock drift of the sensor is relatively slow, a longer window size can be selected to capture dependencies over a longer time range; if the clock drift is relatively fast, a shorter window size can be selected; for application scenarios with higher real-time requirements, a shorter window size can be selected to reduce prediction delays; for application scenarios with higher accuracy requirements, a longer window size can be selected to improve prediction accuracy.

[0042] In order to improve the accuracy of the prediction, a time window W of a certain length is selected, and the most recent W time points are selected from the historical data to form a time series. Furthermore, a sliding window technique is used to generate multiple input-output pairs from the time series. Each time the window moves forward one or more time steps, a new time window is generated. Each time the window moves forward k time steps (where k≤W), multiple input-output pairs can be generated:

[0043] [ΔT1, ΔT2, ΔT3,..., ΔT W ] ->D W+1 ;

[0044] [ΔT2, ΔT3, ΔT4,..., ΔT W+1 ] ->D W+2 ; ...;

[0046] The sliding window generates multiple time windows by gradually moving the time window on the time series. Each window contains W consecutive time steps. A certain overlap is allowed between adjacent windows to increase the number of training samples and improve the learning ability of the model. The sliding step size k determines the degree of overlap between adjacent windows. A smaller sliding step size will result in more input-output pairs because there is a larger overlap between windows; while a larger sliding step size will result in fewer input-output pairs.

[0047] According to one embodiment of the present invention, the time series is [ΔT1, ΔT2, ΔT3, ΔT4, ΔT5, ΔT6, ...], and the window size W=3 is selected, and the window moves forward 1 time step each time. Then, the sliding window will generate the following input-output pairs: the first time window: [ΔT1, ΔT2, ΔT3] -> D4; the second time window: [ΔT2, ΔT3, ΔT4] -> D5; the third time window: [ΔT3, ΔT4, ΔT5] -> D6. Based on the input-output pairs generated by the sliding window, an LSTM model is constructed and trained to help the model better learn the changing rules of the time series.

[0048] By selecting an appropriate time window size W, we can ensure that the model can capture sufficient time dependencies while avoiding the problem of computing resource consumption caused by excessive input data. The sliding window continuously updates the latest data in the time window, allowing the model to adaptively adjust the prediction strategy and maintain a high synchronization accuracy.

[0049] The generated input-output pairs are divided into training set, validation set and test set. The training set is used for model training, the validation set is used for hyperparameter tuning, and the test set is used to evaluate the final performance of the model.

[0050] Specifically, the LSTM model structure includes:

[0051] Input layer: Receives fixed-length time window data (W time steps), each time step contains ΔT, D and other relevant environmental data (such as temperature, humidity, etc.); these environmental data can be collected through external sensors and recorded synchronously with timestamps to enhance the predictive ability of the model.

[0052] One or more LSTM layers to capture the long-term and short-term dependencies in the time series. The number of LSTM layers is selected according to the complexity of the task to enhance the accuracy of the model.

[0053] Dense layer, maps the output of the LSTM layer to the final predicted value. Preferably, a linear activation function is used to operate the output of the LSTM layer to map the time series features extracted by the LSTM layer to the final predicted value D pred .

[0054] When training the model, the loss function of the LSTM model is defined as the mean square error, which is used to measure the difference between the model prediction value and the actual target value. By minimizing the loss function, the model can better fit the historical data. The performance of the model is evaluated using methods such as cross-validation to ensure the stability and consistency of the model on different data sets.

[0055] Furthermore, the LSTM model predicts the error at future time points by learning the changing rules of the time series. now The error D between the current sensor time and the actual time can be predicted pred .

[0056] S103, by D pred Correct the sensor time to make it closer to the standard time;

[0057] Specifically, the actual duration ΔT at the current moment now Input into the trained LSTM model to predict the sensor time error at the current moment: D pred = LSTM(ΔT now );According to the prediction error D pred , adjust the sensor time to make it closer to the standard time: t sensor_corrected = t sensor + D pred .

[0058] According to the present application, as new data arrives, the old window will gradually be replaced by the new window, so that the model can continue to learn the latest pattern and maintain a high synchronization accuracy. Each time a new data point arrives, the sliding window will move forward k time steps to generate a new input-output pair for updating the model.

[0059] In order to further improve the accuracy and efficiency of error correction, the error correction mechanisms using the LSTM model include real-time correction and periodic correction. For applications that require extremely high time synchronization accuracy, a real-time correction mechanism is used to ensure that the sensor time is always consistent with the standard time; for tasks with slower clock drift, a periodic correction mechanism can be used to reduce the consumption of computing resources and adjust the correction strategy according to the specific application scenario.

[0060] Example 1: Every time a new timestamp is received, the system will immediately use the LSTM model to predict the error at the current moment and make immediate corrections based on the prediction results. The specific steps are as follows:

[0061] Get the current timestamp of the sensor, get the current actual standard time through the NTP protocol, and calculate the actual time ΔT = t from the start of the sensor to the current moment actual − t actual_start ;

[0062] Input the actual duration ΔT at the current moment into the trained LSTM model to predict the sensor time error D at the current moment pred = LSTM(ΔT), based on the predicted error D pred , adjust the sensor time;

[0063] The latest timestamp and error data are added to the sliding window to generate new input-output pairs for subsequent model training and prediction.

[0064] Example 2: Every hour, the system collects all timestamps and error data in the past hour, uses the LSTM model to batch predict the error at each time point, and batch corrects the sensor time. The specific steps are as follows:

[0065] In each correction cycle, the system continuously collects the timestamp and error data of the sensor to form a time series;

[0066] At the end of each correction cycle, the system batch processes all timestamps within that cycle and uses the LSTM model to predict the error at each time point;

[0067] Batch correct sensor time according to the predicted error value;

[0068] After each correction, the system updates the LSTM model based on the latest timestamp and error data.

[0069] In addition, the correction of the present application also includes setting an error threshold. When the predicted sensor time error exceeds the threshold, the error elimination mechanism is triggered. Specifically, each time a new timestamp is received, the LSTM model is used to predict the error at the current moment; if the predicted error exceeds the set threshold, correction is performed immediately.

[0070] The present invention provides a cumulative time error prediction method based on a time window LSTM model. The LSTM model is used to accurately capture clock drift, correct sensor time errors, and reduce cumulative errors. The sliding window is used to optimize the amount of input data, and the window size is dynamically adjusted to avoid the problem of computing resource consumption caused by excessive data volume over time, and to improve prediction accuracy. The real-time correction or periodic correction mechanism is also used to timely correct the errors at time points according to needs, thereby improving time accuracy and reducing the consumption of computing resources.

[0071] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0072] Although the above describes the specific implementation methods of the present invention, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.

Claims

1. A cumulative time error prediction method based on a time window LSTM model, characterized in that: The method comprises: Acquire historical data of the sensor, wherein the historical data includes sensor time, actual time, and environmental data of the sensor; Performing time feature processing on the historical data, and selecting the historical data within a time window of a certain length as a time series, wherein each time window contains W consecutive time steps; The time series is modeled and trained using an LSTM model, wherein the input of the LSTM model is the sensor time change within the time window, and the output is the difference between the current sensor time and the standard time; Correct the sensor time based on the prediction results of the trained LSTM model; The time window is created as follows: Select the most recent W time points from the historical data to form a time series as the input of the LSTM model; each time the window moves forward k time steps, multiple input-output pairs are generated for training the LSTM model; the entire time series is traversed by sliding the window to ensure that each time window contains W consecutive time steps, where W and k are positive constants; The size W of the time window is selected based on the characteristics of the cumulative error of the sensor changing over time to capture the long-term dependency of the time series, and the window length with the smallest prediction error is selected through experimental verification; The time feature processing includes: Calculate the working time from the sensor start time to the sensor current time Δt = t sensor -t sensor_start ; Calculate the actual time ΔT = t from the actual start time of the sensor to the actual current time actual -t actual_start ; Calculation error D = ΔT-Δt; Among them, t sensor The current time of the sensor recorded by the sensor's internal clock, t sensor_start is the sensor start time recorded by the sensor internal clock, t actual_start is the actual start time obtained by the NTP protocol, t actual It is the actual current time obtained through the NTP protocol; The actual time ΔT from the actual start time of the sensor to the actual current time and the environmental data of the sensor are used as input data, and the error D is used as output data to train the LSTM model.

2. According to claim 1, a cumulative time error prediction method based on a time window LSTM model is characterized in that: The LSTM model structure is: The input layer receives time window data of length W, where each time step contains ΔT, D, and other relevant environmental data; One or more LSTM layers to capture long-term and short-term dependencies in time series; Dense layers are used to map the output of the LSTM layer to the final predicted value.

3. The cumulative time error prediction method based on the time window LSTM model according to claim 1 is characterized in that: The amendments include: The LSTM model predicts the error D between the current sensor and the standard time based on the input time window data. pred ; Through the prediction error D pred Correct the sensor time: t sensor_corrected = t sensor + D pred .

4. The cumulative time error prediction method based on the time window LSTM model according to claim 1 is characterized in that: The correction is real-time correction. Every time a new timestamp is received, the LSTM model is immediately used to predict the error at the current moment, and immediate correction is performed based on the prediction result.

5. The cumulative time error prediction method based on the time window LSTM model according to claim 1 is characterized in that: The correction is a regular correction. According to the set period, all timestamps and error data in the past period are collected; the LSTM model is used to batch predict the error at each time point, and the sensor time is corrected in batches.

Citation Information

Patent Citations

  • Predicting clock drift

    CN116266945A

  • Software time synchronization implementation method of sensor

    CN119311079A