Soil moisture prediction method and system based on BiLSTM-Transformer dynamic weight hybrid architecture
The BiLSTM-Transformer dynamic weight hybrid architecture solves the problems of incomplete parameters and weak time series modeling in soil moisture prediction, achieves high-precision, real-time soil moisture prediction, supports precision irrigation and agricultural water conservation and yield increase, reduces hardware costs, and expands the application of smart irrigation.
Patent Information
- Application Number
- CN202511100168.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-07
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2045-08-07
AI Technical Summary
Existing soil moisture prediction methods have problems such as incomplete parameter system, static model architecture and weak time series modeling, which lead to large errors in prediction results, especially in extreme weather conditions where the errors increase sharply.
A BiLSTM-Transformer dynamic weight hybrid architecture is adopted. By collecting and processing time series data of factors affecting soil moisture, a hybrid architecture consisting of an input layer, a bidirectional long short-term memory network layer, a transformer encoding layer and a dynamic fusion layer is constructed. Combined with the multi-head attention mechanism and the dynamic weight mechanism, the feature fusion strategy is adaptively adjusted to achieve high-precision prediction.
It significantly improves the time series modeling capability of soil moisture prediction, reduces the error of prediction results, and can achieve real-time high-precision prediction on edge computing devices, guide precise irrigation, save water and increase production, reduce hardware costs, and expand the application scenarios of agricultural intelligent irrigation.
Smart Images

Figure CN120597733B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of Internet of Things prediction technology, and in particular relates to a soil moisture prediction method and system based on a BiLSTM-Transformer dynamic weight hybrid architecture. Background Art
[0002] In agricultural production, precision irrigation technology is of great significance for water conservation and increased yields. However, in actual application scenarios, it often faces the problem of insufficient or excessive irrigation: the former leads to stunted crop growth and severe yield reductions, while the latter causes poor root development and even plant death, resulting in a serious waste of water resources. Therefore, establishing a high-precision soil moisture prediction model is the core of precision irrigation. By analyzing historical meteorological data and soil physical and chemical parameters, it can accurately predict future soil moisture trends, providing a scientific basis for irrigation decision-making. According to the "Study on Soil Moisture Forecast in Qidong City Based on Meteorological Factors", although the three core factors of precipitation, sunshine and temperature were screened out through stepwise regression, its empirical formula cannot adapt to dynamic meteorological changes, resulting in a sharp increase in errors under extreme weather conditions. For example, the error suddenly increased to 12% during typhoon season. In addition, the research report "Study on the Accuracy of Soil Moisture Prediction Based on BP Neural Network (Back Propagation Neural Network) - Taking Feidong County as an Example" adopted a BP neural network to incorporate soil moisture and radiation data, but the model only used three hidden layers. Among them, the shallow network had difficulty modeling the nonlinear effects of key factors such as soil temperature and wind field, and relied on manual input of the initial moisture content of the time period. At the same time, the ISO 18123 standard points out that soil thermal conductivity is negatively correlated with moisture content, and the FAO irrigation guidelines clearly state that wind speeds >5m / s increase evaporation by 30%.
[0003] Through the above analysis, the problems and defects of the existing technology are as follows:
[0004] Although existing methods have achieved the prediction of soil moisture changes in the next period of time based on the changes in soil moisture conditions in the past period of time, they have not solved the problems of incomplete parameter system, static model architecture and weak time series modeling in existing methods, resulting in large errors in the prediction results of soil moisture content. Summary of the Invention
[0005] In response to the problems existing in the prior art, the present invention provides a soil moisture prediction method and system based on a BiLSTM (bidirectional long short-term memory network)-Transformer (hybrid neural network architecture) dynamic weight hybrid architecture.
[0006] The present invention is implemented as follows: a soil moisture prediction method based on a BiLSTM-Transformer dynamic weight hybrid architecture includes:
[0007] Collect an observation dataset of factors affecting soil moisture in irrigation areas. The observation dataset includes a sequence of meteorological elements and a sequence of soil parameters.
[0008] Time series data of factors affecting soil moisture content are collected at a frequency of 10 to 15 minutes, and wavelet noise reduction is performed on the time series data to obtain noise-reduced data;
[0009] Linear interpolation is used to fill in the missing sections of the noise reduction data to obtain a continuous data set;
[0010] Through automatic feature engineering, monthly and hourly cycle features are extracted, the monthly cycle features are normalized, and the diurnal cycle regularity value is calculated for the hourly cycle features;
[0011] The continuous data set is divided into a training set and a validation set in chronological order, and the training set and the validation set are standardized to obtain a standard training set and a standard validation set;
[0012] Based on the standard training set and the standard validation set, a bidirectional long short-term memory network-transformer dynamic hybrid architecture is constructed, which includes an input layer, a bidirectional long short-term memory network layer, a transformer encoding layer, a dynamic fusion layer, and an output layer.
[0013] Using an optimizer to perform precision training on the dynamic hybrid architecture to obtain a first training architecture; using an early stopping mechanism to train the first training architecture for no less than 10 rounds to obtain a second training architecture; adjusting the neuron dropout rate and regularization strength of the second training architecture so that the verification loss of the second training architecture is stably less than 0.10, to obtain a third training architecture; wherein the neuron dropout rate ranges from 0.1 to 0.3, and the regularization strength ranges from 1×10-5 to 1×10-4;
[0014] Use the validation set to calculate the mean square error and average relative error of the third training architecture. When the mean square error is less than 0.12 and the average relative error is less than 5%, the target architecture is determined.
[0015] The target architecture is used to output a soil moisture prediction sequence for the next 1-hour period.
[0016] Furthermore, the meteorological element sequence includes air temperature, relative soil moisture content, soil temperature, global radiation, wind direction, wind speed, and rainfall; and the soil parameter sequence includes electrical conductivity and historical soil moisture content.
[0017] Furthermore, the normalization process for the monthly cycle characteristics includes:
[0018] Get the month values from January to December;
[0019] Subtract 1 from each of the 12 month values and divide the result by 11 to obtain a normalized value of the month value in the interval [0, 1], wherein the normalized value retains at least two decimal places;
[0020] Further, calculating the diurnal cycle regularity value of the hourly period feature includes:
[0021] Obtain hour values from 1 to 24, and divide each of the 24 hour values by 24 to obtain a first value;
[0022] The first values are multiplied by the sine value of 2π to obtain second values, wherein the second values are the day-night cycle regularity values.
[0023] Furthermore, the bidirectional long short-term memory network-transformer dynamic hybrid architecture includes an input layer, a bidirectional long short-term memory network layer, a transformer encoding layer, a dynamic fusion layer and an output layer;
[0024] The input layer is connected to the input end of the bidirectional long short-term memory network layer, the output end of the bidirectional long short-term memory network layer is connected to the input end of the transformer coding layer, the output end of the transformer coding layer is connected to the input end of the dynamic fusion layer, and the output end of the dynamic fusion layer is connected to the output layer;
[0025] The input end of the input layer is used to receive the time step data of the hourly periodic feature, the bidirectional long short-term memory network layer is used to bidirectionally capture short-term meteorological mutation data, the transformer encoding layer is used to extract spatial correlation values, the bidirectional long short-term memory network layer includes hidden units, the transformer encoding layer includes a layer structure and an attention head, the dynamic fusion layer is used to calculate the weight coefficient of the time step data, and the output layer is used to generate the predicted value of the soil moisture content;
[0026] Furthermore, the number of hidden units is 256, the number of layer structures is 6, and the number of attention heads is 8.
[0027] Furthermore, the observation data set has a characteristic dimension, which includes the number of monitoring points. When the number of deployed monitoring points is n, the characteristic dimension is:
[0028] D=7n+2, where D is the feature dimension.
[0029] Furthermore, the linear interpolation filling includes:
[0030] ,in, is the current moment value, is the previous moment value, is the later time value, is the time interval, is the position number;
[0031] The bidirectional long short-term memory network layer includes a forward hidden state unit and a backward hidden state unit;
[0032] The forward hidden state unit is : ,in, is the current moment value, LSTM is the long short-term memory network, and t-1 is the forward time step;
[0033] The backward hidden state unit is : ;
[0034] The bidirectional long short-term memory network layer is : ;
[0035] Based on the multi-head attention mechanism, the transformer encoding layer adopts the formula:
[0036] Parse the meteorological element sequence, wherein: is the attention mechanism function, Q is the query matrix, K is the correlation strength coefficient between features, V is the value matrix, is the normalized exponential function, is the dimension scaling factor, T is the transposed matrix;
[0037] The dynamic fusion layer uses the formula The features are fused, where As the fusion result, is the output tensor, is the scaling factor, is a one-dimensional convolution;
[0038] Using attention pooling technology:
[0039] Output the average pooling result of the feature, where is the average pooling function;
[0040] Using attention output function:
[0041] Output attention output results.
[0042] Another object of the present invention is to provide a soil moisture prediction system based on a BiLSTM-Transformer dynamic weight hybrid architecture, comprising:
[0043] Data acquisition module, feature data processing module, dynamic weight hybrid architecture construction module, sequence prediction module;
[0044] A data acquisition module collects an observation data set of factors affecting soil moisture in an irrigation area, wherein the observation data set includes a meteorological element sequence and a soil parameter sequence; collects time series data of factors affecting soil moisture, and uses a wavelet denoising method to perform denoising on the time series data to obtain denoised data; and uses a linear interpolation method to fill missing values in the denoised data to obtain a continuous data set;
[0045] a feature data processing module that obtains monthly and hourly periodic features of the soil moisture influencing factors based on automatic feature engineering, normalizes the monthly periodic features using a normalization method, and calculates the diurnal cycle regularity value of the hourly periodic features; divides the continuous data set into a training set and a validation set in chronological order, and standardizes the training set and the validation set to obtain a standard training set and a standard validation set;
[0046] A dynamic weight hybrid architecture construction module is provided, which constructs a bidirectional long short-term memory network-transformer dynamic hybrid architecture based on the standard training set and the standard validation set, uses an optimizer to perform precision training on the architecture to obtain a first training architecture, uses an early stopping mechanism method to perform multiple rounds of training on the first training architecture for no less than 10 rounds to obtain a second training architecture, and adjusts the neuron drop rate and regularization strength of the second training architecture until the validation loss of the second training architecture is stabilized below 0.10 to obtain a third training architecture;
[0047] The sequence prediction module uses the validation set to calculate the mean square error and mean relative error of the third training architecture to the target mean square error and mean relative error, evaluates the prediction performance of the third training architecture, and when the prediction performance reaches a preset standard, obtains the target architecture and uses the target architecture to output a soil moisture prediction sequence for the next one-hour period.
[0048] In combination with the above technical solutions and the technical problems solved, please analyze the advantages and positive effects of the technical solutions to be protected by the present invention from the following aspects:
[0049] First, by deeply integrating the spatiotemporal correlation characteristics of historical meteorological data, we can fully explore the temporal laws of soil moisture changes and construct a temporal modeling framework that conforms to the characteristics of agricultural meteorological data. We use a bidirectional long short-term memory recursive neural network (LSTM) to capture short-cycle meteorological fluctuation characteristics, combine it with the Transformer architecture to model long-term climate evolution trends, and adaptively adjust the feature fusion strategy through a dynamic weight mechanism, significantly improving the temporal modeling capability of soil moisture prediction. While maintaining the prediction accuracy, the parameter quantity is compressed, making it feasible to be deployed on edge computing devices. The constructed framework improves the stability of the prediction results and can effectively reduce the prediction error of the soil moisture content.
[0050] Second, as auxiliary evidence of the invention's inventiveness, it is also reflected in the following important aspects:
[0051] The originality of the dynamic weight hybrid architecture: Existing technologies may only use LSTM. This invention proposes the BiLSTM-Transformer dynamic weight fusion mechanism for the first time. It adaptively adjusts the contribution rate of long-term and short-term features through the learnable coefficient α (α>0.65 in the dry season, α=0.4 in the rainy season), solving the problem that static weights cannot adapt to climate change. After investigation, no similar technologies have been disclosed at home and abroad.
[0052] Existing studies mostly use daily / weekly scale features. This invention is the first to encode the 24-hour day and night cycle into hourly periodic features through sin(2πt / 24), significantly improving the short-term prediction accuracy (the error of the validation set is reduced by 32%).
[0053] The error of traditional models increases sharply during typhoons / rainstorms (for example, the error during the typhoon season in the background technology reaches 12%). This invention uses BiLSTM to capture sudden meteorological changes within 6 hours (such as sudden changes in evaporation when the wind speed is >5m / s), combined with Transformer modeling of the pressure change trend 72 hours before the typhoon, to control the error within 5% in extreme weather conditions (MAPE of the typhoon sample in the validation set is 4.7%).
[0054] Initial value dependence problem: BP neural network requires manual input of initial moisture content. The present invention eliminates initial value dependence through historical sequence autoregression and achieves "zero intervention" prediction.
[0055] Traditionally, it is believed that Transformer requires a large amount of data. However, this paper uses the local features of BiLSTM as a prior through a dynamic fusion layer, allowing Transformer to converge even with a small sample size of 144 time steps (24 hours) (validation loss < 0.10).
[0056] The industry commonly uses cloud computing. This invention achieves real-time prediction on edge devices for the first time through quantization pruning (parameter compression by 40%) and FP16 (16-bit Floating Point, half-precision floating point) reasoning, breaking the inherent perception that "agricultural AI requires high computing power."
[0057] Agricultural water conservation and increased production: By achieving hourly high-precision soil moisture prediction, precision irrigation can be guided. According to FAO data, precision irrigation can save 20% to 40% of water and increase production by 10% to 15%. Based on China's 1 billion mu (approximately 166 acres) of irrigated area, the annual water-saving potential exceeds 20 billion cubic meters, with direct economic benefits exceeding 100 billion yuan.
[0058] Commercial deployment of edge devices: After model compression, the number of parameters is reduced by 40%, and it can run on edge devices such as NVIDIA Jetson (45 milliseconds / prediction, energy consumption 0.12Wh / time), reducing farmers' hardware costs (traditional cloud solutions require continuous payment of traffic fees, with an annual cost of approximately 500 yuan / mu, while edge solutions have a one-time investment of less than 200 yuan / mu).
[0059] Industrial Chain Extension: The system can be integrated into scenarios such as autonomous driving of agricultural machinery and irrigation valve control, forming a closed loop of "sensor-model-actuator", giving rise to emerging markets such as smart irrigation hardware and data services. The global market size is expected to reach US$3.5 billion in 2027 (MarketsandMarkets data). BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 This is a flow chart of a soil moisture prediction method based on a BiLSTM-Transformer dynamic weight hybrid architecture provided by an embodiment of the present invention.
[0061] Figure 2 This is a structural block diagram of a soil moisture prediction system based on a BiLSTM-Transformer dynamic weight hybrid architecture provided by an embodiment of the present invention.
[0062] Figure 3 This is a simplified flowchart of the soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture provided by an embodiment of the present invention.
[0063] Figure 4 This is a graph of the model training / validation loss curve provided by an embodiment of the present invention.
[0064] Figure 5 This is a single LSTM-Transformer model training / validation loss curve provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0065] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0066] This paper proposes a comprehensive solution for predicting soil moisture in irrigated areas. Its core is to build a BiLSTM-Transformer dynamic weight hybrid architecture to provide moisture content forecasts with hourly temporal resolution. The method first synchronously collects meteorological element sequences (air temperature, relative moisture content, soil temperature, global radiation, wind direction, wind speed, and rainfall) and soil parameter sequences (electrical conductivity and historical moisture content) from multiple monitoring points, generating time series data with a frequency of 10-15 minutes.
[0067] In the data preprocessing stage, wavelet denoising is used to improve the signal-to-noise ratio, and linear interpolation is used to fill in missing segments to obtain a continuous dataset. Subsequently, automatic feature engineering is used to extract monthly cycle features (normalized to 0-1) and hourly cycle features (based on the 24-h diurnal sinusoidal cycle). Finally, the training and validation sets are divided into chronological order and standardized to establish a unified feature space for model training.
[0068] At the model level, a bidirectional LSTM is first used to capture short-term meteorological changes, and then a multi-head attention Transformer encoding layer is used to extract spatial correlations. The two are adaptively weighted through a dynamic fusion layer (one-dimensional convolution + learnable scaling coefficient). The overall structure has 256 hidden units, 6 encoding layers, and 8 attention heads. The overall structure completes initial training under optimizers such as Adam, and then uses an early stopping mechanism to iterate for no less than 10 rounds to obtain a converged model. By adjusting the dropout rate of 0.1-0.3 and the regularization strength of 1e-5-1e-4, the verification loss is steadily reduced to below 0.10.
[0069] During the evaluation phase, the validation set was used to calculate the mean square error (target < 0.12) and mean relative error (target < 5%). When both indicators met the threshold, the target architecture was locked. This architecture can output a soil moisture prediction sequence for the next 1-hour period in real time, covering 7n+2 dimensional features (n is the number of monitoring points), meeting the needs of precise irrigation decision-making.
[0070] The corresponding system consists of four major modules: ① The data acquisition module completes observation and denoising interpolation; ② The feature data processing module generates periodic features and standardizes data; ③ The BiLSTM-Transformer dynamic weight hybrid architecture construction module trains and optimizes the dynamic hybrid network; and ④ The sequence prediction module is responsible for performance evaluation and online inference, realizing end-to-end intelligent prediction of field moisture content.
[0071] like Figure 1 、 Figure 3 As shown, a soil moisture prediction method based on a BiLSTM-Transformer dynamic weight hybrid architecture provided by an embodiment of the present invention includes the following steps:
[0072] S1: Collecting an observation dataset of factors affecting soil moisture in an irrigated area, where the observation dataset includes a sequence of meteorological elements and a sequence of soil parameters;
[0073] S2: Collect time series data of factors affecting soil moisture content, and use wavelet noise reduction method to reduce the noise of the observation data set to obtain reduced noise data. Use linear interpolation method to fill missing values in the reduced noise data to obtain a continuous data set;
[0074] S3: Based on automatic feature engineering, monthly and hourly cycle characteristics of soil moisture influencing factors are obtained, the monthly cycle characteristics are normalized using a normalization method, and the diurnal cycle regularity value of the hourly cycle characteristics is calculated;
[0075] S4: Divide the continuous data set into a training set and a validation set in chronological order, and standardize the training set and the validation set to obtain a standard training set and a standard validation set respectively;
[0076] S5: Construct a bidirectional long short-term memory network-transformer dynamic hybrid architecture based on the standard training set and standard validation set;
[0077] S6: Use the optimizer to perform precision training on the architecture to obtain a first training architecture, use the early stopping mechanism method to train the first training architecture for multiple rounds of no less than 10 rounds to obtain a second training architecture, adjust the neuron drop rate and regularization strength of the second training architecture until the verification loss of the second training architecture is stable below 0.10, and obtain a third training architecture;
[0078] S7: Use the validation set to calculate the mean square error and mean relative error of the third training architecture to the target mean square error and mean relative error, evaluate the prediction performance of the third training architecture, and when the prediction performance reaches the preset standard, obtain the target architecture, and use the target architecture to output the soil moisture prediction sequence for the next one-hour period.
[0079] The meteorological element sequence provided by the embodiment of the present invention includes air temperature, relative soil moisture, soil temperature, global radiation, wind direction, wind speed, and rainfall. The soil parameter sequence includes electrical conductivity and historical soil moisture.
[0080] The embodiment of the present invention provides a normalization method for normalizing monthly cycle characteristics, including:
[0081] Get the month values from January to December;
[0082] Subtract 1 from each of the 12 month values and divide the result by 11 to obtain a normalized value of the month value in the interval [0, 1], wherein the normalized value retains at least two decimal places;
[0083] As a further solution of the present invention: the calculating of the diurnal cycle regularity value of the hourly period characteristic includes:
[0084] Obtain hour values from 1 to 24, and divide each of the 24 hour values by 24 to obtain a first value;
[0085] The first values are multiplied by the sine value of 2π to obtain second values, wherein the second values are the day-night cycle regularity values.
[0086] The bidirectional long short-term memory network-converter dynamic hybrid architecture provided by the embodiment of the present invention includes an input layer, a bidirectional long short-term memory network layer, a converter encoding layer, a dynamic fusion layer and an output layer;
[0087] The input layer is connected to the input end of the bidirectional long short-term memory network layer, the output end of the bidirectional long short-term memory network layer is connected to the input end of the transformer coding layer, the output end of the transformer coding layer is connected to the input end of the dynamic fusion layer, and the output end of the dynamic fusion layer is connected to the output layer;
[0088] The input end of the input layer is used to receive the time step data of the hourly periodic feature, the bidirectional long short-term memory network layer is used to bidirectionally capture short-term meteorological mutation data, the transformer encoding layer is used to extract spatial correlation values, the bidirectional long short-term memory network layer includes hidden units, the transformer encoding layer includes a layer structure and an attention head, the dynamic fusion layer is used to calculate the weight coefficient of the time step data, and the output layer is used to generate the predicted value of the soil moisture content;
[0089] The range of the neuron dropout rate is 0.1~0.3, and the range of the regularization strength is 1×10 -5 ~1×10 -4 , the target mean square error is less than 0.12, the target average relative error is less than 5%; the number of hidden units is 256, the number of layer structures is 6, and the number of attention heads is 8.
[0090] The observation dataset provided by the embodiment of the present invention has a characteristic dimension, which includes the number of monitoring points. When the number of deployed monitoring points is n, the characteristic dimension is:
[0091] D=7n+2, where D is the feature dimension;
[0092] As a further solution of the present invention: the frequency of collecting the time series data of the factors affecting soil moisture content is 10 minutes / time to 15 minutes / time.
[0093] The method of using a linear interpolation method to fill missing values in the noise reduction data provided by an embodiment of the present invention includes:
[0094] The linear interpolation formula is used to fill the missing period of the noise reduction data, and the filling value is:
[0095] ,in, is the current moment value, is the previous moment value, is the later time value, is the time interval, is the position number;
[0096] The bidirectional long short-term memory network layer includes a forward hidden state unit and a backward hidden state unit;
[0097] The forward hidden state unit is : ,in, is the current moment value, LSTM is the long short-term memory network, and t-1 is the forward time step;
[0098] The backward hidden state unit is : ;
[0099] The bidirectional long short-term memory network layer is : ;
[0100] Based on the multi-head attention mechanism, the transformer encoding layer adopts the formula:
[0101] Parse the meteorological element sequence, wherein: is the attention mechanism function, Q is the query matrix, K is the correlation strength coefficient between features, V is the value matrix, is the normalized exponential function, is the dimension scaling factor, T is the transposed matrix;
[0102] The dynamic fusion layer uses the formula The features are fused, where For the fusion result, is the output tensor, is the scaling factor, is a one-dimensional convolution;
[0103] Using attention pooling technology:
[0104] Output the average pooling result of the feature, where is the average pooling function;
[0105] Using attention output function:
[0106] Output the attention output result, where is the attention weight calculation function.
[0107] like Figure 2 As shown, the embodiment of the present invention provides a soil moisture prediction system based on a BiLSTM-Transformer dynamic weight hybrid architecture, including:
[0108] Data acquisition module, feature data processing module, dynamic weight hybrid architecture construction module, sequence prediction module;
[0109] The data acquisition module collects an observation data set of factors affecting soil moisture in the irrigation area, wherein the observation data set includes a meteorological element sequence and a soil parameter sequence; collects time series data of factors affecting soil moisture, and uses a wavelet noise reduction method to reduce noise on the time series data to obtain reduced noise data; and uses a linear interpolation method to fill missing values in the reduced noise data to obtain a continuous data set;
[0110] The feature data processing module obtains the monthly cycle characteristics and hourly cycle characteristics of the soil moisture influencing factors based on automatic feature engineering, normalizes the monthly cycle characteristics using a normalization method, and calculates the diurnal cycle regularity value of the hourly cycle characteristics; divides the continuous data set into a training set and a validation set in chronological order, and standardizes the training set and the validation set respectively to obtain a standard training set and a standard validation set;
[0111] The dynamic weight hybrid architecture construction module constructs a bidirectional long short-term memory network-transformer dynamic hybrid architecture based on the standard training set and the standard validation set, uses an optimizer to perform precision training on the architecture to obtain a first training architecture, uses an early stopping mechanism method to perform multiple rounds of training on the first training architecture for no less than 10 rounds to obtain a second training architecture, and adjusts the neuron drop rate and regularization strength of the second training architecture until the validation loss of the second training architecture is stabilized below 0.10 to obtain a third training architecture;
[0112] The sequence prediction module is configured to use the validation set to calculate the mean square error and mean relative error of the third training architecture to the target mean square error and mean relative error, evaluate the prediction performance of the third training architecture, and when the prediction performance reaches a preset standard, obtain the target architecture, and use the target architecture to output the soil moisture prediction sequence for the next one-hour period.
[0113] An embodiment of the present invention provides a computer device, which includes a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes the steps of the soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture.
[0114] An embodiment of the present invention provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor executes the steps of the soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture.
[0115] An embodiment of the present invention provides an information data processing terminal, which is used to implement the soil moisture prediction system based on the BiLSTM-Transformer dynamic weight hybrid architecture.
[0116] The present invention is specifically implemented:
[0117] In this embodiment, the training set accounts for 70% of the continuous data set, and the validation set accounts for 30% of the continuous data set.
[0118] Preferably, the meteorological element sequence includes air temperature, relative soil moisture, soil temperature, global radiation, wind direction, wind speed, and rainfall, and the soil parameter sequence includes electrical conductivity and historical soil moisture.
[0119] Preferably, a normalization method is used to normalize the monthly cycle characteristics, including:
[0120] Get the month values from January to December;
[0121] Subtract 1 from each of the 12 month values and divide by 11 to obtain a normalized value of the month value in the interval [0, 1], where the normalized value retains at least two decimal places.
[0122] In this embodiment, the obtained month values are 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, and 12, and the normalized values of the 12 months correspond to: 0, 0.09, 0.18, 0.27, 0.36, 0.45, 0.55, 0.64, 0.73, 0.82, 0.91, and 1.
[0123] Preferably, calculating the diurnal cycle regularity value of the hourly period characteristic includes:
[0124] Obtain hour values from 1 to 24, and divide each of the 24 hour values by 24 to obtain a first value;
[0125] The first values are multiplied by the sine value of 2π to obtain second values, wherein the second values are the day-night cycle regularity values.
[0126] Preferably, the bidirectional long short-term memory network-transformer dynamic hybrid architecture includes an input layer, a bidirectional long short-term memory network layer, a transformer encoding layer, a dynamic fusion layer and an output layer;
[0127] The input layer is connected to the input end of the bidirectional long short-term memory network layer, the output end of the bidirectional long short-term memory network layer is connected to the input end of the transformer encoding layer, the output end of the transformer encoding layer is connected to the input end of the dynamic fusion layer, and the output end of the dynamic fusion layer is connected to the output layer;
[0128] Among them, the input end of the input layer is used to receive time step data with hourly periodic characteristics, the bidirectional long short-term memory network layer is used to capture short-term meteorological mutation data in a bidirectional manner, the transformer encoding layer is used to extract spatial correlation values, the bidirectional long short-term memory network layer includes hidden units, the transformer encoding layer includes a layer structure and an attention head, and the dynamic fusion layer is used to calculate the weight coefficient of the time step data.
[0129] In this embodiment, the output layer is used to generate a predicted value of soil moisture content, and the time step data includes 144 time steps.
[0130] In this embodiment, the neuron dropout rate ranges from 0.1 to 0.3, the regularization strength ranges from 1×10-5 to 1×10-4, the target mean square error is less than 0.12, and the target average relative error is less than 5%; the number of hidden units is 256, the number of layer structures is 6, and the number of attention heads is 8.
[0131] In this embodiment, the learning rate of the optimizer is 0.001 and the batch size is 128.
[0132] Preferably, the observation data set has a characteristic dimension, which includes the number of monitoring points. When the number of deployed monitoring points is n, the characteristic dimension is:
[0133] D=7n+2, where D is the feature dimension.
[0134] Preferably, the frequency of collecting the time series data of the factors affecting soil moisture content is 10 minutes / time to 15 minutes / time.
[0135] Preferably, linear interpolation is used to fill missing values in the noise-reduced data, including:
[0136] The linear interpolation formula is: missing value = (latter time value - previous time value) / (time interval number + 1) × position number + previous time value;
[0137] The linear interpolation formula is used to fill the missing period of the noise reduction data, and the filling value is:
[0138] ,in, is the current moment value, is the previous moment value, is the later time value, is the time interval, is the position number.
[0139] In this embodiment, the db4 wavelet basis function is used to eliminate sensor signal noise, and the sensor is used to collect an observation data set.
[0140] In this embodiment, step S4 processes data according to the following specifications:
[0141] Dimensionality Splitting: Reshape a continuous dataset into a [a, b, c] three-dimensional structure where:
[0142] a is the time step (fixed to 144, representing 24 hours); b is the number of features (basic 9 dimensions + derived features); c is the number of samples;
[0143] The dataset was divided into 70% training set and 30% validation set in chronological order to ensure that the data of each season were evenly distributed.
[0144] Preferably, the bidirectional long short-term memory network layer includes a forward hidden state unit and a backward hidden state unit;
[0145] The forward hidden state unit is : ,in, is the current input, LSTM is the long short-term memory network, and t-1 is the forward time step;
[0146] The backward hidden state unit is : ;
[0147] The bidirectional long short-term memory network layer is : ;
[0148] Based on the multi-head attention mechanism, the transformer encoding layer adopts the formula:
[0149] Parse the meteorological element sequence, where is the attention mechanism function, Q is the query matrix, K is the correlation strength coefficient between features, V is the value matrix, is the normalized exponential function, is the dimension scaling factor, T is the transposed matrix;
[0150] The dynamic fusion layer uses the formula The features are fused, where For the fusion result, is the output tensor, is the scaling factor, is a one-dimensional convolution;
[0151] Using attention pooling technology:
[0152] Output the average pooling result of the feature, where Q is the output result of the average pooling, is the average pooling function;
[0153] Using attention output function:
[0154] Output attention output results.
[0155] Preferably, the dynamic hybrid model architecture in step S5 is implemented to construct a BiLSTM-Transformer hybrid architecture: input 144 time steps × 9-dimensional features; the BiLSTM layer (256 units bidirectional) captures short-term meteorological mutations; the Transformer encoder (6 layers and 8 heads) extracts long-range spatial correlations; the dynamic fusion layer adaptively balances the contribution of two-way features through the learnable weight coefficient α (generated in real time by the fully connected layer) (in the dry season, α>0.65 increases the Transformer weight to strengthen the long-term trend, and in the rainy season, α=0.4 enhances the BiLSTM short-term response); the prediction stage adopts the attention pooling mechanism (with 256-channel feature maps as input, the spatial weight calibration is guided by the global mean vector, and the scaling factor Stable training) focuses on key features and suppresses noise interference.
[0156] In this embodiment, preferably, the principle and basic structure of the BiLSTM-Transformer dynamic weight hybrid model in step S5 are:
[0157] The original seven-dimensional meteorological data and the two engineering features (hourly and monthly) from step S3 are integrated into the input matrix. 10 minutes / sample × 144 = 24 hours corresponds to 144 time steps. Next, the BILSTM dual-stream feature collaborative extraction mechanism is used: For time series feature extraction, a bidirectional LSTM layer is used to process meteorological data. The computational process can be expressed as follows:
[0158] (1);
[0159] (2);
[0160] (3);
[0161] The input features The original meteorological data and 32-dimensional engineering features (such as periodic time coding) are combined and finally spliced together. Generates a 512-dimensional time series feature vector. This structure is particularly good at capturing short-term meteorological changes, such as heavy rainfall within 6 hours. In terms of spatial feature modeling, the Transformer encoder uses a multi-head attention mechanism to analyze the global correlation between meteorological elements:
[0162] (4);
[0163] This is the attention mechanism calculation process in formula (4): First, the input features are converted into three matrices: the query matrix Q, the key matrix of the features to be extracted, K representing the strength of the association between features, and the value matrix V, which carries the specific information of the features. Similarity scores are then calculated, and the dot product of the query matrix and the key matrix is scaled. The dot product result is normalized by dividing it by the square root of the key vector dimension. The softmax function is used to convert it into a weighted sum of probability distributions, and the probability distribution is applied to the value matrix. Setting 4-8 attention heads enables the model to analyze the interactive effects of multi-dimensional data such as temperature, soil moisture, and radiation in parallel, effectively capturing long-term climate trends exceeding 24 hours.
[0164] Preferably, step S5 enables a dynamic adaptive fusion mechanism to solve the problem of feature weight drift caused by seasonal changes and introduces a learnable weight regulator:
[0165] (5)
[0166] Dynamic weight coefficient in formula (5) Generated in real time through the fully connected layer, its calculation depends on the current environment characteristics and soil characteristics The joint state.
[0167] In practical applications, research in arid regions using passive microwave remote sensing to infer soil moisture content indicates that 80% of dry season surface moisture variation can be explained by prior climate trends, with only 20% influenced by transient meteorological events. When α > 0.65, the Transformer's contribution to cross-monthly features increases to 75%, reducing error by 32% (compared to a fixed-weight model). A soil moisture model reveals that rainy season irrigation decisions rely on 72-hour precipitation forecasts. BiLSTM's response error to heavy rain events is 18.7% lower than that of the Transformer. When α = 0.4, BiLSTM features contribute 60%, effectively capturing key abrupt changes such as the date of the first rain (negatively correlated with soil moisture). Therefore, this mechanism automatically increases the Transformer weight to 0.7 during the dry season to enhance long-term soil moisture trend analysis, while increasing the BiLSTM weight to 0.4 during the rainy season to enhance short-term soil moisture response.
[0168] Preferably, in step S5, a multi-scale prediction enhancement mechanism is used, and the attention pooling technology is used in the prediction stage to focus on key features:
[0169] (6);
[0170] The core input of the attention pooling mechanism in formula (6) is the fusion feature map obtained after the previous processing , which contains information from different scales. First, by Performs an average pooling operation across the spatial dimensions (typically height and width) , we get a global feature mean vector, which represents the average state or context information of the entire feature map. Then, we use As a guiding signal, calculate it with The correlation or similarity between the feature vectors at each position in is calculated by and The transpose of is matrix multiplied to obtain an unnormalized attention score map. To make the training process more stable, these raw scores are divided by a scaling factor (The 256 here usually corresponds to the eigenvector The channel dimension C, i.e. C=256, is used to prevent the gradient of the Softmax function from vanishing due to the excessive dot product result. 256 is a common channel number design in deep learning models (such as the middle layer of ResNet and VGG). It is large enough to accommodate complex meteorological features without excessively increasing the amount of computation. Subsequently, these scaled scores are applied The function is normalized to generate a spatial attention weight map, where each value (between 0 and 1) represents the importance of the corresponding spatial position feature. Finally, this normalized attention weight map is compared with the original The feature map is weighted summed element by element (i.e. matrix multiplication) to obtain the final attention output feature The core of this process is to dynamically recalibrate input features using global context The spatial weights allow the model to automatically focus on feature areas that are more critical to the current forecasting task (such as meteorological node forecasting), while suppressing interference from noise or irrelevant areas, thereby significantly improving the model's forecasting accuracy and robustness.
[0171] The S6 model training phase preferably utilizes an efficient mixed-precision strategy. The core configuration includes using the Adam optimizer (with a learning rate set to 0.001 and momentum parameters β1 and β2 set to 0.9 and 0.999, respectively) to update network weights. Each batch processes 128 samples to balance training efficiency and memory consumption. To significantly accelerate the training process and reduce graphics memory usage, FP16 half-precision floating-point arithmetic is introduced. The training goal is to minimize the difference between the predicted value and the true value, which is quantified using the mean squared error (MSE) loss function.
[0172] S7 optimally implements a three-step dynamic tuning mechanism during training to optimize model performance and prevent overfitting. First, an early stopping strategy is implemented to continuously monitor the validation loss. If the validation loss does not improve by more than 0.001 over 10 consecutive training epochs, training is terminated early. Secondly, the regularization parameters are dynamically adjusted, including optimizing the ratio of random neuron dropout (Dropout) in the range of 0.1 to 0.3; in the study of improving the Adam optimizer (AdaMod), the research group of Sun Xu of Peking University pointed out that the adaptive optimizer needs to be combined with a dynamic monitoring mechanism to avoid invalid iterations due to unstable learning rate. Similar thresholds (such as 0.001~0.005) are used in the experiment to ensure training efficiency; and the size of the L2 weight decay (regularization) coefficient is adjusted in the range of 1e-5 to 1e-4, because the joint research of Tencent Hunyuan and Peking University found that in the training of large models, the learning rate needs to be reduced synchronously when the BatchSize increases. At this time, the L2 coefficient can be dynamically relaxed to 1e-5 to maintain stability. Finally, the entire tuning process is closely dependent on the monitoring of key performance indicators, including mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), and the trend of training and validation loss curves. These evaluation results directly guide the fine-tuning of the above parameters, such as Figure 4Shown is the training / validation loss curve of the model of the present invention, Figure 5 Shown are the training / validation loss curves for a single LSTM-Transformer model.
[0173] Prioritizing model validation and final prediction in S8, a standardized process is followed. First, the trained and fine-tuned hybrid model is loaded. Then, the standardized preprocessed (normalized) time series data (with a dimension of 144 time steps × 9 feature variables) is input into the model. The model outputs the predicted soil moisture value for the corresponding time series. Because the model output is on a standardized scale, it needs to be denormalized to convert it back to the original value range with actual physical meaning. Finally, the prediction performance is quantitatively verified using rigorous evaluation metrics, requiring performance standards of a mean square error of less than 0.12, an average relative error of less than 5%, and a Pearson correlation coefficient between the predicted value and the actual observation value greater than 0.95.
[0174] Preferably, in step S8, the deployment and performance evaluation are verified. After loading the tuning model, the standardized 144×9 dimensional time series data is input, and the physical quantity soil moisture content sequence is output through Transformer environmental feature extraction, BiLSTM soil feature generation, and dynamic fusion layer prediction. The performance of the validation set must meet the following requirements: mean square error <0.12, average relative error <5%, and correlation coefficient between predicted value and measured value >0.95 to ensure the reliability of model prediction.
[0175] Preferably, when S8 is deployed at the edge, when deploying the lightweight prediction model on the NVIDIA Jetson AGX Xavier embedded platform, the raw sensor data is first standardized, and the conversion process can be expressed as ,in and are the mean vector and standard deviation vector of the training data set, respectively. and They are raw sensor data and standardized data respectively; the standardized data is then input into the pre-trained hybrid model for inference calculation, specifically using the Transformer encoder to extract environmental features ,in and The environmental feature vector extracted by the Transformer encoder and the standardized environmental features input to the Transformer encoder are combined with the BiLSTM network to generate soil features. , The standardized soil features are input to BiLSTM and finally the dynamic fusion formula is used Output predicted value, where dynamic weight coefficient Depend on , calculated in real time, where W and b are the weight matrix and bias vector respectively, Sigmoid activation function; after completing model inference, restore the formula through physical dimension The result is converted into actual soil moisture value, where 、 、 The following are the actual soil moisture content prediction after restoration, the normalized soil moisture content prediction, the standard deviation of the soil moisture content in the training dataset, and the mean soil moisture content in the training dataset. This deployment solution runs efficiently on edge devices with 32TOPS computing power, completing predictions in just 45 milliseconds and keeping memory usage within 420MB. Energy consumption per prediction is as low as 0.12Wh, fully meeting the needs of real-time field decision-making.
[0176] It should be noted that the embodiments of the present invention can be implemented by hardware, software, or a combination of software and hardware. The hardware portion can be implemented using dedicated logic; the software portion can be stored in a memory and executed by an appropriate instruction execution system, such as a microprocessor or dedicated design hardware. Those skilled in the art will appreciate that the above-mentioned devices and methods can be implemented using computer-executable instructions and / or contained in processor control code, for example, such as a carrier medium such as a disk, CD or DVD-ROM, a programmable memory such as a read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuits such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field programmable gate arrays, programmable logic devices, etc., can also be implemented by software executed by various types of processors, or can be implemented by a combination of the above-mentioned hardware circuits and software, such as firmware.
[0177] The above description is only a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with this technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered by the scope of protection of the present invention.
Claims
1. A soil moisture prediction method based on BiLSTM-Transformer dynamic weight hybrid architecture, characterized in that: The following steps are involved: Collect an observation dataset of factors affecting soil moisture in irrigation areas. The observation dataset includes a sequence of meteorological elements and a sequence of soil parameters. Time series data of factors affecting soil moisture were collected at a frequency of 10 to 15 minutes. Wavelet noise reduction was performed on the time series data to obtain noise-reduced data. Linear interpolation was used to fill in missing sections of the noise-reduced data to obtain a continuous data set. The monthly and hourly cycle characteristics of soil moisture influencing factors were extracted through automatic feature engineering. The monthly cycle characteristics were normalized, and the diurnal cycle regularity value was calculated for the hourly cycle characteristics. The continuous data set is divided into a training set and a validation set in chronological order, and the training set and the validation set are standardized to obtain a standard training set and a standard validation set; Based on the standard training set and the standard validation set, a bidirectional long short-term memory network-transformer dynamic hybrid architecture is constructed, which includes an input layer, a bidirectional long short-term memory network layer, a transformer encoding layer, a dynamic fusion layer, and an output layer. Using an optimizer to perform precision training on the dynamic hybrid architecture to obtain a first training architecture; using an early stopping mechanism to perform no less than 10 rounds of training on the first training architecture to obtain a second training architecture; Adjust the neuron dropout rate and regularization strength of the second training architecture so that the verification loss of the second training architecture is stable below 0.10, and obtain the third training architecture; wherein the neuron dropout rate ranges from 0.1 to 0.3, and the regularization strength ranges from 1×10 -5 ~1×10 -4 ; Use the validation set to calculate the mean square error and average relative error of the third training architecture. When the mean square error is less than 0.12 and the average relative error is less than 5%, the target architecture is determined; Use the target architecture to output the soil moisture prediction sequence for the next 1-hour period; The bidirectional long short-term memory network layer includes a forward hidden state unit and a backward hidden state unit; The forward hidden state unit is : ,in, is the current moment value, LSTM is the long short-term memory network, and t-1 is the forward time step; The backward hidden state unit is : ; The bidirectional long short-term memory network layer is : ; Based on the multi-head attention mechanism, the transformer encoding layer adopts the formula: Parse the meteorological element sequence, wherein: is the attention mechanism function, Q is the query matrix, K is the correlation strength coefficient between features, V is the value matrix, is the normalized exponential function, is the dimension scaling factor, T is the transposed matrix; The dynamic fusion layer uses the formula The features are fused, where For the fusion result, is the output tensor, is the scaling factor, is a one-dimensional convolution; Using attention pooling technology: Output the average pooling result of the feature, where is the average pooling function; Using attention output function: Output attention output results.
2. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture as claimed in claim 1, characterized in that: The meteorological element sequence includes air temperature, relative soil moisture, soil temperature, global radiation, wind direction, wind speed and rainfall; the soil parameter sequence includes electrical conductivity and historical soil moisture.
3. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture as claimed in claim 1, characterized in that: The linear interpolation filling method includes: , where x t is the current moment value, is the previous moment value, is the later time value, is the time interval, is the position number.
4. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture as claimed in claim 1, characterized in that: The normalization process of the monthly cycle characteristics includes: Get the month values from January to December; Subtract 1 from each of the 12 month values and then divide by 11 to obtain a normalized value of the month value in the interval [0, 1], wherein the normalized value retains at least two decimal places.
5. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture as claimed in claim 1, characterized in that: The bidirectional long short-term memory network-converter dynamic hybrid architecture includes an input layer, a bidirectional long short-term memory network layer, a converter encoding layer, a dynamic fusion layer and an output layer, wherein the input layer is connected to the input end of the bidirectional long short-term memory network layer, the output end of the bidirectional long short-term memory network layer is connected to the input end of the converter encoding layer, the output end of the converter encoding layer is connected to the input end of the dynamic fusion layer, and the output end of the dynamic fusion layer is connected to the output layer; the input end of the input layer is used to receive the time step data of the hourly period feature, the bidirectional long short-term memory network layer is used to bidirectionally capture short-term meteorological mutation data, the converter encoding layer is used to extract spatial correlation values, the bidirectional long short-term memory network layer includes hidden units, the converter encoding layer includes a layer structure and an attention head, the dynamic fusion layer is used to calculate the weight coefficient of the time step data, and the output layer is used to generate the soil moisture content prediction value.
6. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture according to claim 1 is characterized in that: The bidirectional long short-term memory network layer includes 256 hidden units, and the transformer encoding layer includes a 6-layer structure and 8 attention heads.
7. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture as claimed in claim 1, characterized in that: The observation data set has a characteristic dimension, which includes the number of monitoring points. When the number of deployed monitoring points is n, the characteristic dimension is: D=7n+2, where D is the feature dimension.
8. The soil moisture prediction method based on the BiLSTM-Transformer dynamic weight hybrid architecture according to claim 1, characterized in that: The dynamic fusion layer calculates the time step data weights based on one-dimensional convolution and learnable scaling coefficients to achieve adaptive fusion of the output tensor of the bidirectional long short-term memory network layer and the output tensor of the transformer encoding layer.
9. A soil moisture prediction system implementing the method according to any one of claims 1 to 8, characterized in that: The soil moisture prediction system comprises: The data acquisition module is used to collect an observation data set of factors affecting soil moisture in the irrigation area, wherein the observation data set includes a meteorological element sequence and a soil parameter sequence; perform wavelet noise reduction processing on the collected time series data of factors affecting soil moisture to generate noise-reduced data; perform missing value filling based on linear interpolation on the noise-reduced data to generate a continuous data set; A feature data processing module, which obtains monthly and hourly cycle characteristics of factors affecting soil moisture based on automatic feature engineering; normalizes the monthly cycle characteristics using a normalization method and calculates the diurnal cycle regularity value of the hourly cycle characteristics; divides the continuous data set into a training set and a validation set in chronological order, and standardizes the training set and validation set respectively to obtain a standard training set and a standard validation set; An architecture construction module is provided, which constructs a bidirectional long short-term memory network-transformer dynamic hybrid architecture based on the standard training set and the standard validation set, uses an optimizer to perform precision training on the architecture to obtain a first training architecture, uses an early stopping mechanism method to perform multiple rounds of training on the first training architecture for no less than 10 rounds to obtain a second training architecture, and adjusts the neuron drop rate and regularization strength of the second training architecture until the validation loss of the second training architecture is stabilized below 0.10 to obtain a third training architecture; The sequence prediction module uses the validation set to calculate the mean square error and mean relative error of the third training architecture to the target mean square error and mean relative error, evaluates the prediction performance of the third training architecture, and when the prediction performance reaches a preset standard, obtains the target architecture and uses the target architecture to output a soil moisture prediction sequence for the next one-hour period.
Citation Information
Patent Citations
Space-time bidirectional soil water content interpolation method based on deep learning
CN112287294A
BiLSTM-Transformer flood prediction method for semi-arid basin considering initial rainfall loss of partner house model
CN116579152A