CNS model soil humidity prediction method fusing dynamic space-time pruning and WOA algorithm
By fusing the CNS model of dynamic spatiotemporal pruning and WOA algorithm, the problems of high complexity and low prediction accuracy of traditional soil moisture prediction methods are solved, and higher prediction accuracy and calculation efficiency are achieved.
Patent Information
- Application Number
- CN202510460946.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-05-27
- Estimated Expiration
- 2045-04-14
AI Technical Summary
Traditional soil moisture prediction methods have problems such as high model complexity, high calculation cost and low prediction accuracy.
The CNS model that integrates dynamic spatiotemporal pruning and WOA algorithm is used to build the initial model through multiple convolution modules, BiLSTM modules and attention mechanism modules, and dynamic pruning and hyperparameter optimization are performed after preliminary training.
It significantly improves the accuracy and robustness of soil moisture prediction, reduces computational costs, and improves the flexibility and adaptability of the model.
Smart Images

Figure CN120046510A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of spatiotemporal data prediction, and in particular to a soil moisture prediction method of a CNS model integrating dynamic spatiotemporal pruning and a WOA algorithm. Background Art
[0002] Soil moisture is a key parameter in agricultural production, climate research and environmental monitoring. Therefore, accurate soil moisture prediction is of great significance for rationally arranging irrigation, improving water resource utilization efficiency, and preventing natural disasters such as droughts and floods. Traditional soil moisture prediction methods mainly rely on physical models and statistical methods, but these methods have limitations when dealing with complex spatiotemporal data, such as high model complexity, high computational cost, and low prediction accuracy.
[0003] In recent years, deep learning methods have made significant progress in processing spatiotemporal data. Although existing models have achieved remarkable results in many fields, their prediction accuracy is still unsatisfactory in some complex tasks. This may be due to the unreasonable design of the model structure or the overfitting phenomenon in the model training process, which leads to poor performance of the model on the test data. In addition, when processing large-scale spatiotemporal data, the existing models have low computational efficiency and are difficult to achieve real-time prediction. This is because large-scale data has high dimensions, large data volume, and high demand for computing resources, and the existing model structure and algorithm may not be able to effectively process this data. In addition, the complexity and dynamics of spatiotemporal data also bring challenges to the design and optimization of the model. Summary of the invention
[0004] The purpose of the embodiment of the present invention is to provide a CNS model soil moisture prediction method that integrates dynamic spatiotemporal pruning and WOA algorithm, aiming to solve the technical problems of high model complexity, high computational cost and low prediction accuracy in traditional soil moisture prediction technology.
[0005] To achieve the above object, the present invention provides the following technical solutions.
[0006] The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm includes the following steps: Construct the initial CNS model based on multiple convolution modules, BiLSTM modules and attention mechanism modules; The soil time series data is used as the input of the initial CNS model to perform preliminary training on the initial CNS model; In the multiple convolution modules of the initial model training, the convolution layer and pooling layer are used to extract the feature tensor from the local spatial and temporal information of the input data. The spatiotemporal graph convolution network STGCN is used to extract the spatiotemporal features of the feature tensor by alternately performing spatial graph convolution and temporal convolution, and the feature dimension is formed based on the output four-dimensional tensor. In the BiLSTM module of the initial model training, the time series data is processed bidirectionally to capture the previous and next dependencies in the time series; In the attention mechanism module of the initial training of the model, the spatiotemporal features are nonlinearly transformed, and the weight of each time step is calculated through the activation function softmax. According to the calculated weight, the spatiotemporal features are weighted and summed, and the weighted feature representation is sent to the fully connected layer for processing; A dynamic spatiotemporal pruning strategy is used to dynamically prune each module of the model after preliminary training; The model parameters are updated through the back propagation algorithm to obtain the CNS model for soil moisture prediction.
[0007] Furthermore, in the step of preliminary training of the initial CNS model, the whale optimization algorithm is used to optimize the hyperparameters of the multi-convolution module, BiLSTM module and attention mechanism module in the initial CNS model, including: When K≥1, the prey search strategy is executed, and the expression is: ; ; Among them, P represents the distance between the current search individual and the random individual, X rand is the position vector of the current follower; When A < 1, the strategy of surrounding the prey is executed, and the expression is: ; Among them, P′ represents the distance vector between the current search individual and the current optimal solution, b is a finite constant used to determine the spiral shape, l is a random and uniformly distributed number with a value range of [-1,1]; p represents the probability of the predation mechanism, which is a random number from 0 to 1.
[0008] Furthermore, the step of extracting feature tensors from local spatial and temporal information of input data using convolutional layers and pooling layers includes: In the convolution layer, the local spatial and temporal information in the input time series data is feature extracted. Each convolution kernel generates a new feature map. The outputs of all convolution kernels are combined into a new feature tensor to obtain the output sequence tensor. In the pooling layer, the feature tensor output by the convolution layer is received as input, and the pooling window slides on the feature tensor. Each pooling window generates a new feature value, and the outputs of all pooling windows are combined into a new feature tensor. The new feature tensor then enters the next convolution layer and pooling layer, and the above operations are repeated to extract the final feature tensor.
[0009] Furthermore, in the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers to reduce the size of the feature map; Among them, the expression of the output feature map obtained by the convolution operation is: Y=σ(X*W+b); Among them, W represents the convolution kernel, and the shape of the convolution kernel is expressed as (F, C, F H ,F W ); F is the number of convolution kernels, C is the number of input channels, F H is the height of the convolution kernel, F W is the width of the convolution kernel; Y is the output feature map, with a shape of (N, F, H out , W out ); σ is the activation function ReLU; * represents the convolution operation, H out , W out The expressions are: ; ; Among them, P is the padding size, S is the step size; H represents the height of the input feature map, and W represents the width of the input feature map; H out Represents the height of the output feature map after the convolution operation; W out Represents the width of the output feature map after the convolution operation; The expression of the convolution kernel value obtained by the convolution operation is: ; Among them, Y n,i,j,k is the value of the output feature map at position (i, j) and the kth convolution kernel, X i+m,j+n,c is the value of the input data at position (i+m,j+n) and the cth channel, W m,n,c,k is the value of the kth convolution kernel at position (m, n) and the cth channel, b k is the bias term of the kth convolution kernel; The pooling layer uses an average pooling operation, which is expressed as: ; Among them, the pooling kernel size is (P H ,P W ), the step length is (S H ,S W ).
[0010] Furthermore, the spatiotemporal graph convolution network STGCN is used to extract spatiotemporal features from the feature tensor by alternately performing spatial graph convolution and temporal convolution, and the step of forming feature dimensions based on the output four-dimensional tensor includes: The spatiotemporal graph convolutional network STGCN processes spatiotemporal feature tensors by combining spatial graph convolution GCN and temporal convolution TCN; Spatial graph convolution introduces a learnable weight matrix M, which is bitwise multiplied with the adjacency matrix A to obtain a weighted adjacency matrix; The weighted adjacency matrix is fed into the graph convolution layer GCN together with the input feature tensor to spatially aggregate the node features at each time step. The temporal convolution layer applies temporal convolution (TCN) to the features of each node to capture information in the time dimension. STGCN gradually extracts spatiotemporal features by alternately performing spatial graph convolution and temporal convolution; STGCN outputs a four-dimensional tensor, merging the Nodes and Channels dimensions to form a new feature dimension and feeds it into the BiLSTM module of the CNS model.
[0011] Furthermore, in the spatiotemporal graph convolutional network STGCN, the graph convolution operation is used to capture spatial dependencies, expressed as: ; Where Z is the input feature matrix, Z' is the output feature matrix, A=A+I is the adjacency matrix of the graph plus the identity matrix, A is the original adjacency matrix, I is the identity matrix used to add self-connections, D is the degree matrix of A, that is, the diagonal matrix of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU; The temporal convolution operation is used to capture the dependencies in the time series and is expressed as: ; Where: H t is the hidden state at time step t, H t-1 is the hidden state at time step t-1, W t and b t are the learnable weight matrix and bias term at time step t respectively; Spatiotemporal feature fusion is used to combine spatial features and temporal features, expressed as: ; Among them: F is the fused spatiotemporal feature, f is the fusion function, X' is the output of the graph convolution operation, H T is the final output of the temporal convolution operation; The prediction results are expressed as: ; Among them, Y is the prediction result, W 0 and b 0 The weights and biases of the output layer of the spatiotemporal graph convolutional network respectively; The four-dimensional tensor output by STGCN is expressed as [Batch Size, Channels, Time Steps, Nodes], where Batch Size represents the batch size, Channels represents the number of feature channels after graph convolution and time convolution, TimeSteps represents the length of the time series, and Nodes represents the number of nodes in the graph.
[0012] Furthermore, in the BiLSTM module, the flow of information is controlled by forget gate, input gate and output gate, and a memory unit is also included to save information across time steps; The gating mechanism of the BiLSTM module is expressed as: ; ; ; ; ; ; Among them, A t is the output of the forget gate, σ is the sigmoid activation function, W f and b f are weights and biases, E t-1 is the hidden state of the previous time step, x t is the current input; B t is the output of the input gate, G t is the candidate memory cell state; C t is the memory cell state at the current time step, C t-1 is the memory cell state at the previous time step; D t is the output of the output gate, h t is the hidden state at the current time step.
[0013] Furthermore, in the attention mechanism module, by calculating the degree of association between each element in the input sequence, a weight is assigned to each element, and then these elements are weighted summed; The attention mechanism layer includes query, key and value, and the expression is: ; Among them, Q represents the query matrix, K represents the key matrix, V represents the value matrix, and D k is the dimension of the key vector, T represents the matrix transpose operation, and the softmax function is used to convert the dot product result into a probability distribution; In the STGCN model, the attention mechanism is weighted by calculating the degree of association between points, and graph convolution and attention mechanism are used to model the soil moisture data of the network structure; A spatiotemporal attention mechanism consisting of a spatial attention mechanism and a temporal attention mechanism is adopted to capture spatiotemporal correlations.
[0014] Furthermore, in the step of dynamically pruning each module of the model after preliminary training using a dynamic spatiotemporal pruning strategy, the output after dynamic pruning is expressed as: ; Among them, f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, Φ represents the parameter of the gating mechanism, and π(x, Φ) is converted into a binary mask. When an element of the mask is 0, the corresponding channel is pruned; The weight matrix after dynamic pruning is expressed as: ; Where W is the original weight matrix, is a dynamically generated mask, and W' is the pruned weight matrix; Dynamic pruning selects a mask M(x) for each input x so that the pruned weight matrix W' satisfies the following optimization goal: ; in, is the loss function used to measure model performance; It represents the number of non-zero elements in the mask matrix and controls the intensity of pruning. λ is a regularization parameter used to balance model performance and pruning rate.
[0015] Compared with the prior art, the technical advantages of the soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm in the present invention are: First, the CNS model of the present invention integrates convolutional neural network CNN, spatiotemporal graph convolutional network STGCN, bidirectional long short-term memory network BiLSTM and attention mechanism layer Attention, which can comprehensively process and analyze multimodal data from different data sources, thereby providing more comprehensive data insights and significantly improving the accuracy and robustness of soil moisture prediction. Second, the CNS model of the present invention enables the model to capture both spatial features and time series dependencies through the combination of CNN and BiLSTM, while the attention mechanism further enhances the model's ability to identify and respond to key information. The introduction of STGCN effectively processes spatiotemporal graph data and can accurately capture the spatial correlation and temporal dynamics between nodes. Third, the present invention adopts a dynamic spatiotemporal pruning strategy to dynamically prune each module of the model after preliminary training, and can dynamically adjust the perception area of the model according to the change of data, so that the model is more adaptable to different spatiotemporal data distributions, and improves the flexibility and computational efficiency of the model. In particular, when processing large-scale or variable soil moisture data, it can significantly reduce unnecessary calculations and improve the running speed and adaptability of the model. In summary, the CNS model of the present invention shows higher accuracy and robustness in the soil moisture prediction task; the combination of dynamic pruning and WOA algorithm optimization enables the model to maintain stable prediction performance under different environments and conditions. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention.
[0017] Figure 1 This is a system architecture diagram of the soil moisture prediction method of the CNS model that integrates dynamic spatiotemporal pruning and WOA algorithm in the present invention; Figure 2 It is a schematic diagram of the overall implementation process of the CNS model soil moisture prediction method integrating dynamic spatiotemporal pruning and WOA algorithm of the present invention; Figure 3 A schematic diagram of the flow of the dynamic spatiotemporal pruning strategy provided by the present invention. DETAILED DESCRIPTION
[0018] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and 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.
[0019] The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm provided in the present invention aims to improve the prediction accuracy of the model, and can more accurately capture the dependencies and dynamic changes between large-scale spatiotemporal data, so as to help farmers and decision makers decide the timing and amount of irrigation, thereby improving irrigation efficiency and reducing water waste.
[0020] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.
[0021] In one embodiment of the present invention, a soil moisture prediction method of a CNS model integrating dynamic spatiotemporal pruning and WOA algorithm is provided. The method first preprocesses the acquired soil time series data; Specifically, the soil moisture data is normalized and feature data is extracted, including soil temperature, humidity, meteorological data, etc.; Specifically, during data preprocessing, soil moisture data from different time steps or spatial locations are , the spatiotemporal data x generated by a hybrid data cleaning operation including denoising and handling missing values Mix ; First, uniformly adjust all input image sequences Dimensions, x (N+1) Represented as the N+1th sample; then normalization is performed to scale the data to a new sequence within the specified range , repeat the operation, operate on multiple data to obtain a set of spatiotemporal sequences ,Right now ; In one implementation, the data preprocessing process includes a step of unifying the image size. Specifically, assuming that the input data is x, the shape is (N, T, H, W), where N is the batch size, T is the number of channels, H is the height, and W is the width; use a bilinear interpolation algorithm to unify all images x s All are scaled to images of size 64px*64px; so that the input image meets the input specifications of the multi-scale convolutional network; and also includes image normalization operations; Specifically, divide all pixel values in image x of the same size by 255, and then use the formula: , normalize the original values (x) of the three channels of the image RGB to obtain the normalized value X norm , where the mean (aver) of the three RGB channels is 0 and the standard deviation (st) is 1; normalization is used to prevent gradient explosion during the training of the neural network model.
[0022] Please refer to Figure 1-Figure 3 The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm provided by the present invention comprises the following steps: Step S101: constructing an initial CNS model based on a multi-convolution module, a BiLSTM module and an attention mechanism module; Specifically, the CNS model of the present invention integrates convolutional neural network CNN, spatiotemporal graph convolutional network STGCN, bidirectional long short-term memory network BiLSTM and attention mechanism module Attention, which can comprehensively process and analyze multimodal data from different data sources, thereby providing more comprehensive data insights and significantly improving the accuracy and robustness of soil moisture prediction; Step S102: using the soil time series data as the input of the initial CNS model to perform preliminary training on the initial CNS model; In step S101 and step S102 of the present invention, the spatiotemporal sequence g t Enter the CNN module of the initial CNS model and use the WOA algorithm to input the spatiotemporal sequence g t Automatically generate the required parameters and improve the initial structure of the CNN module. Before entering the convolutional layer, the spatiotemporal sequence g t It is usually organized into a tensor with the shape of (Batch Size, TimeSteps, Height, Width, Channels). Step S103: In the multiple convolution modules of the preliminary training of the model, the convolution layer and the pooling layer are used to extract the feature tensor from the local spatial and temporal information of the input data, and the spatiotemporal graph convolution network STGCN is used to extract the spatiotemporal features of the feature tensor by alternately performing spatial graph convolution and temporal convolution, and the feature dimension is formed based on the output four-dimensional tensor; In step S103, the local space and time information in the input data in the convolution layer is extracted as a new feature map. Each convolution kernel generates a new feature map. The outputs of all convolution kernels are combined into a new feature tensor. The local space and time information in the input data of the output sequence tensor in the pooling layer is extracted as a new feature map. Each pooling window generates a new feature value. The outputs of all pooling windows are combined into a new feature tensor. The feature tensor enters the second convolution layer + pooling layer, and the same operation of the first convolution layer + pooling layer is repeated to further extract features. The relevant hyperparameters are automatically generated by the WOA algorithm. The hyperparameters include the size and number of convolution kernels, so as to improve the performance and accuracy of the model. The spatiotemporal graph convolutional network (STGCN) of the CNS model processes spatiotemporal feature tensors by combining spatial graph convolution (GCN) and temporal convolution (TCN). The spatial graph convolution introduces a learnable weight matrix M, which is bitwise multiplied with the adjacency matrix A to obtain a weighted adjacency matrix. The weighted adjacency matrix is sent to the graph convolution layer (GCN) together with the input feature tensor to perform spatial aggregation on the node features at each time step. The temporal convolution applies temporal convolution (TCN) to the features of each node to capture information in the time dimension. STGCN gradually extracts spatiotemporal features by alternating spatial graph convolution and temporal convolution. The relevant parameters of STGCN are generated by the WOA algorithm. The output of STGCN is a four-dimensional tensor, expressed as: (Batch Size, Channels, Time Steps, Nodes); then merge the Nodes and Channels dimensions to form a new feature dimension: (Batch Size, Time Steps, Nodes×Channels), which is sent to the BiLSTM layer of the CNS model; For further information, please refer to Figure 1 and Figure 2 , the prediction method of the embodiment of the present invention further includes: Step S104: in the BiLSTM module of the initial model training, the time series data is processed bidirectionally to capture the previous and next dependencies in the time series; In step S104, the BiLSTM module can capture the front-end dependency in the time series by bidirectionally processing the time series data. The output dimension of BiLSTM is: (Batch Size, Time Steps, 2×Hidden Size). The bidirectional structure makes the output feature dimension twice that of the unidirectional LSTM.
[0023] Step S105: In the attention mechanism module of the initial model training, the spatiotemporal features are nonlinearly transformed, the weight of each time step is calculated by the activation function softmax, the spatiotemporal features are weighted and summed according to the calculated weights, and the weighted feature representation is sent to the fully connected layer for processing; Among them, in step S105, the purpose of the attention mechanism module is to weight the output of BiLSTM, highlight the important time step features, and suppress unimportant information. This layer performs nonlinear transformation on the output of BiLSTM, calculates the weight of each time step through the activation function softmax, and performs weighted summation on the output of BiLSTM according to the calculated weight to obtain a weighted feature representation. The output shape is still (Batch Size, Time Steps, 2×HiddenSize), but the features of each time step are weighted; the output sequence is sent to one or more fully connected layers (Dense Layer) to further extract features and prepare the final output. The fully connected layer combines the input features by learning weights to identify higher-level features, and then predicts the output results in the output layer; In the attention mechanism module of the initial model training, the relevant hyperparameters are also automatically generated by the WOA algorithm based on the input; Step S106: Dynamically pruning each module of the model after preliminary training using a dynamic spatiotemporal pruning strategy; Step S107: updating the model parameters through the back propagation algorithm to obtain the CNS model for soil moisture prediction.
[0024] Step S106 and step S107 provided by the present invention are the model training stage, and the model accuracy and generalization ability are further improved through dynamic spatiotemporal pruning technology. Before the data is input into the model, unimportant time steps or spatial positions are removed through pruning to reduce the dimension of the input data. During the model training process, the pruning strategy is dynamically adjusted to adapt to different data and task requirements. When the model is predicted, the amount of calculation is reduced through pruning to improve the operating efficiency of the model. After a large number of training iterations and updates, the final CNS model is used for prediction.
[0025] In the CNS model of the embodiment of the present invention, WOA (Whale Optimization Algorithm) is used to optimize hyperparameters to improve the performance of the model, and to find the optimal solution through the spiral update strategy and the prey encirclement strategy; specifically, the whale optimization algorithm is used to optimize the hyperparameters of the multiple convolution modules, BiLSTM modules and attention mechanism modules in the initial CNS model, specifically including: When K≥1, the prey search strategy is executed, and the expression is: ; ; Among them, P represents the distance between the current search individual and the random individual, X rand is the position vector of the current follower; When A < 1, the strategy of surrounding the prey is executed, and the expression is: ; Where P′ represents the distance vector between the current search individual and the current optimal solution, b is a finite constant used to determine the spiral shape, l is a random and uniformly distributed number with a value range of [-1,1]; p represents the probability of the predation mechanism, which is a random number from 0 to 1; X t represents the current individual position; K represents the scaling factor; X t+1 represents the position of the individual at time t+1; X t* Indicates the optimal individual position of the current solution; The present invention uses the whale optimization algorithm (WOA) to automatically optimize the hyperparameters of the CNS initial model. The WOA algorithm simulates the predation behavior of humpback whales and effectively performs a global search in the parameter space to determine the optimal hyperparameter combination, thereby further improving the model's predictive performance and generalization ability.
[0026] Furthermore, the step of extracting feature tensors from local spatial and temporal information of input data using convolutional layers and pooling layers includes: In the convolution layer, the local spatial and temporal information in the input time series data is feature extracted. Each convolution kernel generates a new feature map. The outputs of all convolution kernels are combined into a new feature tensor to obtain the output sequence tensor. In the pooling layer, the feature tensor output by the convolution layer is received as input, and the pooling window slides on the feature tensor. Each pooling window generates a new feature value, and the outputs of all pooling windows are combined into a new feature tensor. The new feature tensor then enters the next convolution layer and pooling layer, and the above operations are repeated to extract the final feature tensor.
[0027] Furthermore, in the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers, reducing the size of the feature map, thereby reducing the amount of calculation; Among them, the expression of the output feature map obtained by the convolution operation is: Y=σ(X*W+b); Among them, W represents the convolution kernel, and the shape of the convolution kernel is expressed as (F, C, F H ,F W ); F is the number of convolution kernels, C is the number of input channels, F H is the height of the convolution kernel, F W is the width of the convolution kernel; Y is the output feature map, with a shape of (N, F, H out , W out ); σ is the activation function ReLU; * represents the convolution operation, H out , W out The expressions are: ; ; Among them, P is the padding size, S is the step size; H represents the height of the input feature map, and W represents the width of the input feature map; H out Represents the height of the output feature map after the convolution operation; W out Represents the width of the output feature map after the convolution operation; The expression of the convolution kernel value obtained by the convolution operation is: ; Among them, Y n,i,j,k is the value of the output feature map at position (i, j) and the kth convolution kernel, X i+m,j+n,c is the value of the input data at position (i+m,j+n) and the cth channel, W m,n,c,k is the value of the kth convolution kernel at position (m, n) and the cth channel, b k is the bias term of the kth convolution kernel; Furthermore, the pooling layer of the present invention is used to reduce the size of the feature map, retain important features, and reduce the amount of calculation. The pooling layer adopts an average pooling operation, which is expressed as: ; Among them, the pooling kernel size is (P H ,P W ), the step length is (S H ,S W );;Y n,f,i,j represents the value of the pooled output at position (i, j) and the fth feature; P H Indicates the height of the pooling core pooling window, P W Indicates the width of the pooling window of the pooling kernel; Indicates that the input data is at position (i·S H +m,j·S W +n) and the value of the f-th feature.
[0028] Furthermore, the spatiotemporal graph convolution network STGCN is used to extract spatiotemporal features from the feature tensor by alternately performing spatial graph convolution and temporal convolution, and the step of forming feature dimensions based on the output four-dimensional tensor includes: The spatiotemporal graph convolutional network STGCN processes spatiotemporal feature tensors by combining spatial graph convolution GCN and temporal convolution TCN; Spatial graph convolution introduces a learnable weight matrix M, which is bitwise multiplied with the adjacency matrix A to obtain a weighted adjacency matrix; The weighted adjacency matrix is fed into the graph convolution layer GCN together with the input feature tensor to spatially aggregate the node features at each time step. The temporal convolution layer applies temporal convolution (TCN) to the features of each node to capture information in the time dimension. STGCN gradually extracts spatiotemporal features by alternately performing spatial graph convolution and temporal convolution; STGCN outputs a four-dimensional tensor, merging the Nodes and Channels dimensions to form a new feature dimension and feeds it into the BiLSTM module of the CNS model.
[0029] Furthermore, in the spatiotemporal graph convolutional network STGCN, the graph convolution operation is used to capture spatial dependencies, expressed as: ; Where Z is the input feature matrix, Z' is the output feature matrix, A=A+I is the adjacency matrix of the graph plus the identity matrix, A is the original adjacency matrix, I is the identity matrix used to add self-connections, D is the degree matrix of A, that is, the diagonal matrix of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU; The temporal convolution operation is used to capture the dependencies in the time series and is expressed as: ; Where: H t is the hidden state at time step t, H t-1 is the hidden state at time step t-1, W t and b t are the learnable weight matrix and bias term at time step t respectively; Spatiotemporal feature fusion is used to combine spatial features and temporal features to form a comprehensive understanding of the data, expressed as: , where: F is the fused spatiotemporal feature, f is the fusion function, the fusion method can be concatenation or weighted summation, which is not limited, X' is the output of the graph convolution operation, H T is the final output of the temporal convolution operation; The prediction results are expressed as: ; Among them, Y is the prediction result, W 0 and b 0 The weights and biases of the output layer of the spatiotemporal graph convolutional network respectively; The four-dimensional tensor output by STGCN is expressed as [Batch Size, Channels, Time Steps, Nodes], where Batch Size represents the batch size, Channels represents the number of feature channels after graph convolution and time convolution, TimeSteps represents the length of the time series, and Nodes represents the number of nodes in the graph.
[0030] Furthermore, in the BiLSTM module, the flow of information is controlled by the forget gate, input gate, and output gate. A cell state is also included to store information across time steps. Through these gating mechanisms, the BiLSTM module can flexibly store and delete information between time steps, thereby effectively solving the problem of long-term dependency. Specifically, the gating mechanism of the BiLSTM module is expressed as: ; ; ; ; ; ; Among them, A t is the output of the forget gate, σ is the sigmoid activation function, W f and b f are weights and biases, Et-1是 The hidden state at the previous time step, x t is the current input; B t is the output of the input gate, G t is the candidate memory cell state; C t is the memory cell state at the current time step, C t-1 is the memory cell state at the previous time step; D t is the output of the output gate, h t is the hidden state of the current time step; b i 、b c 、b f and b o Both represent bias terms.
[0031] Furthermore, in the attention mechanism module of the CNS model, the working principle is to calculate the degree of association between each element in the input sequence, assign a weight to each element, and then perform weighted summation of these elements; the attention mechanism can enhance the model's attention to the important parts of the input sequence and ignore the less important parts; the attention weight can be interpreted as the contribution of each input element to the output, which helps to understand the decision-making process of the model; specifically, the attention mechanism layer includes query, key, and value, and the expression is: ; Where Q represents the query matrix, K represents the key matrix, and V represents the value matrix. Q, K, and V all come from the output of the previous layer; D k is the dimension of the key vector, which is used to scale the dot product result to avoid the gradient vanishing problem caused by too large a dimension; T represents the matrix transpose operation, and the softmax function is used to convert the dot product result into a probability distribution; In the STGCN model, the attention mechanism is weighted by calculating the degree of association between points, and graph convolution and attention mechanism are used to model the soil moisture data of the network structure; the spatiotemporal attention mechanism composed of spatial attention mechanism and temporal attention mechanism is used to capture spatiotemporal correlation; Among them, the spatial attention mechanism is expressed as: ; ; in, is the output of the previous layer, V s 、b s 、M 1 、M 2 、M 3 is a trainable parameter; L is the spatial attention matrix, Represents the degree of spatial dependence between node i and node j; L is finally normalized by the softmax function; the temporal attention mechanism is similar to the spatial attention mechanism, except that the input is transposed into a vector multiplication in the time dimension to calculate the correlation between different times; The present invention introduces the above-mentioned attention mechanism, so that the model can adaptively capture the dynamic correlation between nodes in the spatial dimension.
[0032] Furthermore, the present invention uses dynamic spatiotemporal pruning technology to further train the CNS model, so as to adaptively adjust the model structure according to different input data, improve the adaptability of the model to different data, and also enable the model to reduce unnecessary calculations during reasoning, thereby improving calculation efficiency; Please refer to Figure 3 , in the step of dynamically pruning each module of the model after preliminary training using the dynamic spatiotemporal pruning strategy, the output after dynamic pruning is expressed as: ; Among them, f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, Φ represents the parameter of the gating mechanism, and π(x, Φ) is converted into a binary mask. When an element of the mask is 0, the corresponding channel is pruned; The weight matrix after dynamic pruning is expressed as: ; Where W is the original weight matrix, is a dynamically generated mask, and W' is the pruned weight matrix; Dynamic pruning selects a mask M(x) for each input x so that the pruned weight matrix W' satisfies the following optimization goal: ; in, is the loss function used to measure model performance; It represents the number of non-zero elements in the mask matrix, which controls the intensity of pruning. λ is a regularization parameter used to balance model performance and pruning rate. Dynamic spatiotemporal pruning technology is used to further train the CNS model. This technology can dynamically adjust the model structure according to the spatiotemporal characteristics of the input data, and prune the network during the runtime of the model to adapt to different data distributions and environmental conditions. This dynamic adjustment mechanism not only improves the model's adaptability to spatiotemporal data changes, but also optimizes the model's computational efficiency and resource utilization.
[0033] In step S106 and step S107 of the present invention, during the training process, the model parameters are iteratively updated to minimize the overall loss function to ensure that the model can achieve accurate soil moisture prediction under different soil conditions; the overall loss includes the mean square error (MSELoss) between the predicted image and the real image, which is used to measure the difference in pixel values between the predicted image and the real image; The model parameters are gradually adjusted through training until the loss function reaches convergence conditions; Specifically, the overall loss is calculated by the mean square error (MSE) and mean absolute error (MAE), and the structural similarity index (SSIM) and peak signal-to-noise ratio (PSNR) are combined as auxiliary evaluation indicators to further evaluate the performance of the model; Among them, the overall loss is expressed as: ; The mean absolute error (MAE) is expressed as: ; The structural similarity (SSIM) is expressed as: ; The peak signal-to-noise ratio (PSNR) is expressed as: ; Among them, prediction is the model prediction value, true is the real value, N is the number of samples, μ pred and μ true分别 is the mean of the predicted image and the real image, σ pred and σ true are the variances of the predicted image and the real image respectively; o 1 and 2 It is a constant, usually set according to the dynamic range of SSIM, and is used to stabilize the calculation of SSIM.
[0034] In summary, the technical advantages of the CNS model soil moisture prediction method integrating dynamic spatiotemporal pruning and WOA algorithm provided by the present invention are reflected in the following aspects: Enhanced spatiotemporal feature extraction capability: The CNS model of the present invention can process spatiotemporal graph data more effectively and capture the spatial relationship and temporal changes between nodes by integrating the spatiotemporal graph convolutional network (STGCN) compared to the CNN-BiLSTM-Attention model alone; this enhanced spatiotemporal feature extraction capability makes the model more accurate and robust in predicting soil moisture.
[0035] Optimized hyperparameter selection: The present invention uses the WOA algorithm to automatically select the optimal hyperparameter combination. Compared with traditional methods such as manual adjustment or grid search, it can more efficiently find hyperparameter settings that improve model performance; this not only saves a lot of experimentation and adjustment time, but also can further improve the predictive performance of the model.
[0036] Dynamic spatiotemporal pruning mechanism: The dynamic spatiotemporal pruning technology proposed in the present invention can dynamically adjust the perception area of the model according to the changes in data, making the model more adaptable to different spatiotemporal data distributions; this mechanism improves the flexibility and computational efficiency of the model, especially when processing large-scale or variable soil moisture data, it can significantly reduce unnecessary calculations and improve the running speed and adaptability of the model.
[0037] In summary, through the above improvements, the present invention enables the model to show higher accuracy and robustness in soil moisture prediction tasks; the combination of dynamic pruning and WOA algorithm optimization enables the model to maintain stable prediction performance under different environments and conditions, and is suitable for agricultural irrigation and water resources management scenarios.
[0038] The above solutions are only an illustration of a preferred example, but are not limited thereto. When implementing the present invention, appropriate replacement and / or modification can be performed according to user needs.
[0039] The number of devices and processing scales described here are used to simplify the description of the present invention. Applications, modifications and variations of the present invention will be obvious to those skilled in the art.
[0040] Although the embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and the embodiments. It can be fully applied to various fields suitable for the present invention. For those familiar with the art, additional modifications can be easily realized. Therefore, without departing from the general concept defined by the claims and equivalent scope, the present invention is not limited to the specific details and the illustrations shown and described here.
Claims
1. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm is characterized by: The prediction method includes the following steps: Construct the initial CNS model based on multiple convolution modules, BiLSTM modules and attention mechanism modules; The soil time series data is used as the input of the initial CNS model to perform preliminary training on the initial CNS model; In the multiple convolution modules of the initial model training, the convolution layer and pooling layer are used to extract the feature tensor from the local spatial and temporal information of the input data. The spatiotemporal graph convolution network STGCN is used to extract the spatiotemporal features of the feature tensor by alternately performing spatial graph convolution and temporal convolution, and the feature dimension is formed based on the output four-dimensional tensor. In the BiLSTM module of the initial model training, the time series data is processed bidirectionally to capture the previous and next dependencies in the time series; In the attention mechanism module of the initial training of the model, the spatiotemporal features are nonlinearly transformed, and the weight of each time step is calculated through the activation function softmax. According to the calculated weight, the spatiotemporal features are weighted and summed, and the weighted feature representation is sent to the fully connected layer for processing; A dynamic spatiotemporal pruning strategy is used to dynamically prune each module of the model after preliminary training; The model parameters are updated through the back propagation algorithm to obtain the CNS model for soil moisture prediction.
2. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 1 is characterized in that: In the step of preliminary training of the initial CNS model, the whale optimization algorithm is used to optimize the hyperparameters of the multi-convolution module, BiLSTM module and attention mechanism module in the initial CNS model, including: When K≥1, the prey search strategy is executed, and the expression is: ; ; Among them, P represents the distance between the current search individual and the random individual, X rand is the position vector of the current follower; When A < 1, the strategy of surrounding the prey is executed, and the expression is: ; Among them, P′ represents the distance vector between the current search individual and the current optimal solution, b is a finite constant used to determine the spiral shape, l is a random and uniformly distributed number with a value range of [-1,1]; p represents the probability of the predation mechanism, which is a random number from 0 to 1.
3. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 2 is characterized in that: The steps of extracting feature tensors from local spatial and temporal information of input data using convolutional layers and pooling layers include: In the convolution layer, the local spatial and temporal information in the input time series data is feature extracted. Each convolution kernel generates a new feature map. The outputs of all convolution kernels are combined into a new feature tensor to obtain the output sequence tensor. In the pooling layer, the feature tensor output by the convolution layer is received as input, and the pooling window slides on the feature tensor. Each pooling window generates a new feature value, and the outputs of all pooling windows are combined into a new feature tensor. The new feature tensor then enters the next convolution layer and pooling layer, and the operation is repeated to extract the final feature tensor.
4. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 3 is characterized in that: In the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers to reduce the size of the feature map; Among them, the expression of the output feature map obtained by the convolution operation is: Y=σ(X*W+b); Among them, W represents the convolution kernel, and the shape of the convolution kernel is expressed as (F, C, F H ,F W ); F is the number of convolution kernels, C is the number of input channels, F H is the height of the convolution kernel, F W is the width of the convolution kernel; Y is the output feature map, with a shape of (N, F, H out , W out ); σ is the activation function ReLU; * represents the convolution operation, H out , W out The expressions are: ; ; Among them, P is the padding size, S is the step size; H represents the height of the input feature map, and W represents the width of the input feature map; H out Represents the height of the output feature map after the convolution operation; W out Represents the width of the output feature map after the convolution operation; The expression of the convolution kernel value obtained by the convolution operation is: ; Among them, Y n,i,j,k is the value of the output feature map at position (i, j) and the kth convolution kernel, X i+m,j+n,c is the value of the input data at position (i+m,j+n) and the cth channel, W m,n,c,k is the value of the kth convolution kernel at position (m, n) and the cth channel, b k is the bias term of the kth convolution kernel; The pooling layer uses an average pooling operation, which is expressed as: ; Among them, the pooling kernel size is (P H ,P W ), the step length is (S H ,S W ).
5. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 4 is characterized in that: The spatiotemporal graph convolution network STGCN extracts spatiotemporal features from the feature tensor by alternately performing spatial graph convolution and temporal convolution. The steps of forming feature dimensions based on the output four-dimensional tensor include: The spatiotemporal graph convolutional network STGCN processes spatiotemporal feature tensors by combining spatial graph convolution GCN and temporal convolution TCN; Spatial graph convolution introduces a learnable weight matrix M, which is bitwise multiplied with the adjacency matrix A to obtain a weighted adjacency matrix; The weighted adjacency matrix and the input feature tensor are sent to the graph convolution layer GCN to spatially aggregate the node features at each time step, and the temporal convolution TCN is applied to the features of each node to capture information in the time dimension; STGCN gradually extracts spatiotemporal features by alternately performing spatial graph convolution and temporal convolution; STGCN outputs a four-dimensional tensor, merging the Nodes and Channels dimensions to form a new feature dimension and feeds it into the BiLSTM module of the CNS model.
6. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 5 is characterized in that: In the spatiotemporal graph convolutional network STGCN, the graph convolution operation is used to capture spatial dependencies, expressed as: , where Z is the input feature matrix, Z' is the output feature matrix, A=A+I is the adjacency matrix of the graph plus the identity matrix, A is the original adjacency matrix, I is the identity matrix used to add self-connections, D is the degree matrix of A, that is, the diagonal matrix of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU; The temporal convolution operation is used to capture the dependencies in the time series and is expressed as: ; Where: H t is the hidden state at time step t, H t-1 is the hidden state at time step t-1, W t and b t are the learnable weight matrix and bias term at time step t respectively; Spatiotemporal feature fusion is used to combine spatial features and temporal features, expressed as: ; Among them: F is the fused spatiotemporal feature, f is the fusion function, X' is the output of the graph convolution operation, H T is the final output of the temporal convolution operation; The prediction results are expressed as: ; Among them, Y is the prediction result, W0 and b0 are the weight and bias of the output layer of the spatiotemporal graph convolutional network respectively; The four-dimensional tensor output by STGCN is expressed as [Batch Size, Channels, Time Steps, Nodes], where Batch Size represents the batch size, Channels represents the number of feature channels after graph convolution and time convolution, TimeSteps represents the length of the time series, and Nodes represents the number of nodes in the graph.
7. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 6 is characterized in that: In the BiLSTM module, the flow of information is controlled by the forget gate, input gate, and output gate, and a memory unit is also included to save information across time steps; The gating mechanism of the BiLSTM module is expressed as: ; ; ; ; ; ; Among them, A t is the output of the forget gate, σ is the sigmoid activation function, W f and b f are weights and biases, E t-1 is the hidden state of the previous time step, x t is the current input; B t is the output of the input gate, G t is the candidate memory cell state; C t is the memory cell state at the current time step, C t-1 is the memory cell state at the previous time step; D t is the output of the output gate, h t is the hidden state at the current time step.
8. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 7 is characterized in that: In the attention mechanism module, by calculating the degree of correlation between each element in the input sequence, a weight is assigned to each element, and then these elements are weighted summed; The attention mechanism layer includes query, key and value, and the expression is: ; Among them, Q represents the query matrix, K represents the key matrix, V represents the value matrix, and D k is the dimension of the key vector, T represents the matrix transpose operation, and the softmax function is used to convert the dot product result into a probability distribution; In the STGCN model, the attention mechanism is weighted by calculating the degree of association between points, and graph convolution and attention mechanism are used to model the soil moisture data of the network structure; A spatiotemporal attention mechanism consisting of a spatial attention mechanism and a temporal attention mechanism is adopted to capture spatiotemporal correlations.
9. The soil moisture prediction method of the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 8 is characterized in that: In the step of dynamically pruning each module of the model after preliminary training using the dynamic spatiotemporal pruning strategy, the output after dynamic pruning is expressed as: ; Among them, f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, Φ represents the parameter of the gating mechanism, and π(x, Φ) is converted into a binary mask. When an element of the mask is 0, the corresponding channel is pruned; The weight matrix after dynamic pruning is expressed as: ; Where W is the original weight matrix, is a dynamically generated mask, and W' is the pruned weight matrix; Dynamic pruning selects a mask M(x) for each input x so that the pruned weight matrix W' satisfies the following optimization goal: ; in, is the loss function used to measure model performance; It represents the number of non-zero elements in the mask matrix and controls the intensity of pruning. λ is a regularization parameter used to balance model performance and pruning rate.
Citation Information
Patent Citations
Adaptive pruning model compression algorithm based on grouping attention mechanism
CN114118402A
Composite microstructure surface contact angle modeling method based on WOA optimization CNN-BiLSTM-Attention combination model
CN118780161A
Ozone concentration prediction method based on GCN-BiLSTM-Attention space-time neural network
CN119150118A
Soil humidity high-precision prediction method based on space-time convolutional neural network coupling model
CN119595548A
Cited By
Distribution network equipment fault discrimination model training method, discrimination method and related equipment
CN120257187A
Soil moisture content prediction method and system based on BiLSTM-Transform dynamic weight hybrid architecture
CN120597733A
Water supply network global water quality prediction method based on double flow-graph convolutional network
CN120873478A
Offshore wind turbine generator fault defect identification system based on multi-source data fusion
CN121024839A
A marine wind turbine fault defect identification system based on multi-source data fusion
CN121024839B