Soil moisture prediction method based on CNS model fusing dynamic spatiotemporal pruning and WOA algorithm

By integrating dynamic spatiotemporal pruning and the WOA algorithm, the CNS model solves the problems of high model complexity and high computational cost in traditional soil moisture prediction methods, and achieves higher accuracy and robustness in soil moisture prediction, which is suitable for agricultural irrigation and water resource management.

CN120046510BActive Publication Date: 2026-05-29ANHUI AGRICULTURAL UNIVERSITY

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
ANHUI AGRICULTURAL UNIVERSITY
Filing Date
2025-04-14
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Traditional soil moisture prediction methods suffer from high model complexity, high computational cost, and low prediction accuracy, especially when dealing with complex spatiotemporal data, making it difficult to achieve real-time prediction.

Method used

A convolutional neural network (CNN), a spatiotemporal graph convolutional network (STGCN), a bidirectional long short-term memory network (BiLSTM), and an attention mechanism module that integrate dynamic spatiotemporal pruning and whale optimization algorithm (WOA) are used to optimize the model structure through dynamic spatiotemporal pruning strategy, thereby improving the model's adaptability and computational efficiency.

Benefits of technology

It significantly improves the accuracy and robustness of soil moisture prediction, better handles large-scale or variable soil moisture data, reduces unnecessary calculations, and improves the model's running speed and adaptability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120046510B_ABST
    Figure CN120046510B_ABST
Patent Text Reader

Abstract

The application is suitable for the field of space-time data prediction, and provides a CNS model soil humidity prediction method fusing dynamic space-time pruning and WOA algorithm, in which, an initial CNS model is constructed based on a multiple convolution module, a BiLSTM module and an attention mechanism module; soil time series data is taken as the input of the initial CNS model, and the initial CNS model is preliminarily trained; a dynamic space-time pruning strategy is adopted to dynamically prune each module of the model after preliminary training; and a model parameter is updated through a back propagation algorithm to obtain a CNS model for soil humidity prediction. The CNS model of the application fuses a convolutional neural network (CNN), a space-time graph convolution network (STGCN), a bidirectional long short-term memory network (BiLSTM) and an attention mechanism layer (Attention), can comprehensively process and analyze multi-modal data from different data sources, and has higher precision and robustness in a soil humidity prediction task; and the combination of dynamic pruning and WOA algorithm optimization enables the model to maintain stable prediction performance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of spatiotemporal data prediction technology, and in particular relates to a soil moisture prediction method for CNS models that integrates dynamic spatiotemporal pruning and WOA algorithm. Background Technology

[0002] Soil moisture is a key parameter in agricultural production, climate research, and environmental monitoring. Therefore, accurate prediction of soil moisture is of great significance for rationally planning irrigation, improving water resource utilization efficiency, and preventing natural disasters such as drought 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 remains unsatisfactory in some complex tasks. This may be due to inadequate model structure design or overfitting during model training, leading to poor performance on test data. Moreover, existing models are computationally inefficient when processing large-scale spatiotemporal data, making real-time prediction difficult. This is because large-scale data has high dimensionality, large volume, and high computational resource requirements, which existing model structures and algorithms may not be able to handle effectively. In addition, the complexity and dynamism of spatiotemporal data also pose challenges to model design and optimization. Summary of the Invention

[0004] The purpose of this invention is to provide a soil moisture prediction method for CNS models 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 objectives, the present invention provides the following technical solution.

[0006] A soil moisture prediction method based on the CNS model integrating dynamic spatiotemporal pruning and the WOA algorithm, the prediction method includes the following steps:

[0007] An initial CNS model is constructed based on a multi-convolution module, a BiLSTM module, and an attention mechanism module.

[0008] Soil time-series data was used as input to the initial CNS model for preliminary training.

[0009] In the multi-convolution module during the initial training of the model, convolutional layers and pooling layers are used to extract feature tensors from the local spatial and temporal information of the input data. The spatiotemporal graph convolutional network STGCN is used to extract spatiotemporal features from the feature tensors by alternately executing spatial graph convolution and temporal convolution, and the feature dimension is formed based on the output four-dimensional tensor.

[0010] In the BiLSTM module during the initial training of the model, the sequential dependencies in the time series are captured by bidirectional processing of time series data.

[0011] In the attention mechanism module of the initial training of the model, 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.

[0012] A dynamic spatiotemporal pruning strategy is used to dynamically prune each module of the model after initial training.

[0013] The model parameters are updated using the backpropagation algorithm to obtain the CNS model for soil moisture prediction.

[0014] Furthermore, in the initial training step of the initial CNS model, the whale optimization algorithm is used to optimize the hyperparameters of the multi-convolutional module, BiLSTM module, and attention mechanism module in the initial CNS model, specifically including:

[0015] When K≥1, the prey search strategy is executed, and the expression is:

[0016] ;

[0017] ;

[0018] Where P represents the distance between the current searched individual and the random individual, and X... rand It is the position vector of the currently following individual;

[0019] When A < 1, the prey encirclement strategy is executed, expressed as:

[0020] ;

[0021] 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], and p represents the probability of the predation mechanism, which is a random number from 0 to 1.

[0022] Furthermore, the step of extracting feature tensors from the local spatial and temporal information of the input data using convolutional and pooling layers includes:

[0023] Within the convolutional layer, features are extracted from the local spatial and temporal information in the input temporal data. Each convolutional kernel generates a new feature map, and the outputs of all convolutional kernels are combined into a new feature tensor to obtain the output sequence tensor. Within the pooling layer, the feature tensor output from the convolutional layer is used as input, and a pooling window slides across 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.

[0024] The new feature tensor is then fed into the next convolutional and pooling layer, and the above operations are repeated to extract the final feature tensor.

[0025] Furthermore, in the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers, reducing the feature map size;

[0026] The expression for the output feature map obtained by the convolution operation is: Y = σ(X*W + b);

[0027] Where W represents the convolution kernel, and the shape of the convolution kernel is represented as (F, C, F). H ,F W F is the number of convolutional kernels, C is the number of input channels, and F H It is the height of the convolution kernel, F W Y is the width of the convolution kernel; Y is the output feature map with shape (N, F, H). out W out ); σ is the ReLU activation function; * represents the convolution operation, H out W out The expressions are as follows:

[0028] ;

[0029] ;

[0030] Where P is the padding size, S is the stride; H represents the height of the input feature map, and W represents the width of the input feature map; H out W represents the height of the output feature map after the convolution operation. out This indicates the width of the output feature map after the convolution operation;

[0031] The expression for obtaining the value of the convolution kernel is:

[0032] ;

[0033] Among them, Y n,i,j,k X is the value of the output feature map at position (i,j) and the k-th convolutional kernel. i+m,j+n,cW is the value of the input data at position (i+m, j+n) and the c-th channel. m,n,c,k It is the value of the k-th convolutional kernel at position (m,n) and the c-th channel, b k It is the bias term of the k-th convolutional kernel;

[0034] The pooling layer uses average pooling, which is expressed as:

[0035] ;

[0036] Wherein, the pooling kernel size is (P H ,P W ), step size is (S) H ,S W ).

[0037] Furthermore, the Spatiotemporal Graph Convolutional Network (STGCN) is used to extract spatiotemporal features from the feature tensor by alternately performing spatial graph convolution and temporal convolution. The steps for forming the feature dimension based on the output four-dimensional tensor include:

[0038] The Spatiotemporal Graph Convolutional Network (STGCN) processes spatiotemporal feature tensors by combining Spatial Graph Convolutional Network (GCN) and Temporal Convolutional Network (TCN).

[0039] Spatial graph convolution introduces a learnable weight matrix M, which is multiplied bitwise with the adjacency matrix A to obtain a weighted adjacency matrix.

[0040] The weighted adjacency matrix and the input feature tensor are fed into the graph convolutional layer GCN to perform spatial aggregation of node features at each time step. Temporal convolution (TCN) is applied to the features of each node to capture information in the time dimension.

[0041] STGCN extracts spatiotemporal features step by step by alternately performing spatial graph convolution and temporal convolution;

[0042] STGCN outputs a four-dimensional tensor that merges the Nodes and Channels dimensions to form a new feature dimension, which is then fed into the BiLSTM module of the CNS model.

[0043] Furthermore, in the Spatiotemporal Graph Convolutional Network (STGCN), graph convolution operations are used to capture spatial dependencies, represented 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, i.e., the diagonal matrix composed of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU;

[0044] Temporal convolution operations are used to capture dependencies in time series data, and are represented as follows:

[0045] ;

[0046] Wherein: H t H is the hidden state at time step t. t-1 It is the hidden state at time step t-1, W t and b t These are the learnable weight matrix and bias term at time step t, respectively.

[0047] Spatiotemporal feature fusion combines spatial and temporal features, and is represented as:

[0048] ;

[0049] Where: F is the fused spatiotemporal feature, f is the fusion function, X' is the output of the graph convolution operation, and H... T It is the final output of the temporal convolution operation;

[0050] The prediction results are expressed as follows: ;

[0051] Where Y is the prediction result, and W0 and b0 are the weights and biases of the output layer of the spatiotemporal graph convolutional network, respectively.

[0052] The four-dimensional tensor output by STGCN is represented 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.

[0053] Furthermore, in the BiLSTM module, the flow of information is controlled by forget gates, input gates, and output gates, and a memory unit is also included to store information across time steps;

[0054] The gating mechanism of the BiLSTM module is represented as follows:

[0055] ;

[0056] ;

[0057] ;

[0058] ;

[0059] ;

[0060] ;

[0061] Among them, A t It is the output of the forget gate, σ is the sigmoid activation function, and W is the output of the forget gate. f and b f It consists of weights and biases, E t-1 It is the hidden state of the previous time step, x t This is the current input; B t It is the output of the input gate, G t It is the state of the candidate memory cell; C t It is the memory cell state at the current time step, C t-1 It is the state of the memory unit in the previous time step; D t It is the output of the output gate, h t It is the hidden state of the current time step.

[0062] Furthermore, in the attention mechanism module, a weight is assigned to each element by calculating the degree of correlation between each element in the input sequence, and then these elements are summed in a weighted manner.

[0063] The attention mechanism layer includes queries, keys, and values, expressed as:

[0064] ;

[0065] Where Q represents the query matrix, K represents the key matrix, V represents the value matrix, and D represents the value matrix. 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;

[0066] In the STGCN model, the attention mechanism is weighted by calculating the degree of correlation between points, and graph convolution and attention mechanisms are used to model the soil moisture data of the network structure.

[0067] A spatiotemporal attention mechanism, consisting of spatial and temporal attention mechanisms, is used to capture spatiotemporal correlations.

[0068] Furthermore, in the step of dynamically pruning each module of the initially trained model using a dynamic spatiotemporal pruning strategy, the output after dynamic pruning is represented as follows:

[0069] ;

[0070] Where f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are the weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, and Φ represents the parameters of the gating mechanism, which converts π(x, Φ) into a binary mask. When an element of the mask is 0, the corresponding channel is pruned.

[0071] The weight matrix after dynamic pruning is represented as follows: ;

[0072] Where W is the original weight matrix, is a dynamically generated mask, and W' is the pruned weight matrix;

[0073] Dynamic pruning selects a mask M(x) for each input x such that the pruned weight matrix W' satisfies the following optimization objective: ;

[0074] in, It is a loss function used to measure model performance; The number of non-zero elements in the mask matrix is ​​represented, which controls the pruning intensity; λ is a regularization parameter used to balance model performance and pruning rate.

[0075] Compared with existing technologies, the technical advantages of the CNS model soil moisture prediction method integrating dynamic spatiotemporal pruning and WOA algorithm of this invention are as follows:

[0076] First, the CNS model of this invention integrates Convolutional Neural Network (CNN), Spatiotemporal Graph Convolutional Network (STGCN), Bidirectional Long Short-Term Memory Network (BiLSTM), and Attention mechanism layer. This allows for comprehensive processing and analysis of multimodal data from different data sources, providing more comprehensive data insights and significantly improving the accuracy and robustness of soil moisture prediction.

[0077] Second, the CNS model of this invention, through the combination of CNN and BiLSTM, endows the model with the ability to capture both spatial features and temporal dependencies, 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.

[0078] Third, the present invention employs a dynamic spatiotemporal pruning strategy to dynamically prune each module of the model after initial training. This allows for dynamic adjustment of the model's perception area based on data changes, making the model more adaptable to different spatiotemporal data distributions and improving the model's flexibility and computational efficiency. In particular, when dealing with large-scale or variable soil moisture data, it can significantly reduce unnecessary calculations and improve the model's running speed and adaptability.

[0079] In summary, the CNS model of this invention exhibits 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. Attached Figure Description

[0080] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention.

[0081] Figure 1 This is a system architecture diagram of the CNS model soil moisture prediction method that integrates dynamic spatiotemporal pruning and WOA algorithm according to the present invention.

[0082] Figure 2 This is a schematic diagram of the overall implementation process of the CNS model soil moisture prediction method that integrates dynamic spatiotemporal pruning and WOA algorithm of the present invention.

[0083] Figure 3 This is a flowchart illustrating the dynamic spatiotemporal pruning strategy provided by the present invention. Detailed Implementation

[0084] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0085] The soil moisture prediction method for CNS models that integrates dynamic spatiotemporal pruning and WOA algorithm provided by this 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 determine the timing and amount of irrigation, thereby improving irrigation efficiency and reducing water waste.

[0086] The specific implementation of the present invention will be described in detail below with reference to specific embodiments.

[0087] In one embodiment of the present invention, a soil moisture prediction method for CNS model integrating dynamic spatiotemporal pruning and WOA algorithm is provided. The method first preprocesses the acquired soil time series data.

[0088] Specifically, the soil moisture data is normalized and feature data, including soil temperature, humidity, and meteorological data, are extracted.

[0089] Specifically, during data preprocessing, soil moisture data from different time steps or spatial locations are processed. Spatiotemporal data x generated through a hybrid data cleaning operation that includes denoising and handling missing values Mix First, adjust all input image sequences uniformly. The size, x (N+1) This is represented as the (N+1)th sample; then normalization is performed to scale the data to a new set of sequences within a specified range. Repeated operations are performed on various data to obtain a set of spatiotemporal sequences. ,Right now ;

[0090] In one implementation, the data preprocessing includes a step of unifying image dimensions. Specifically, assuming the input data is x with shape (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; a bilinear interpolation algorithm is used to unify all images x. s All images are scaled to a size of 64px*64px to make the input image conform to the input specifications of a multi-scale convolutional network; image normalization is also included.

[0091] Specifically, divide all pixel values ​​in an image x of the same size by 255, and then use the formula: The original values ​​(x) of the three RGB channels of the image are normalized to obtain the normalized value X. norm The mean (aver) of the three RGB channels is 0, and the standard deviation (st) is 1. This normalization process prevents gradient explosion during the training of the neural network model.

[0092] Please refer to Figures 1-3 The soil moisture prediction method for the CNS model that integrates dynamic spatiotemporal pruning and WOA algorithm provided by this invention includes the following steps:

[0093] Step S101: Construct the initial CNS model based on the multi-convolution module, BiLSTM module, and attention mechanism module;

[0094] Specifically, the CNS model of this invention integrates Convolutional Neural Network (CNN), Spatiotemporal Graph Convolutional Network (STGCN), Bidirectional Long Short-Term Memory Network (BiLSTM), and Attention mechanism module, 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.

[0095] Step S102: Use soil time-series data as input to the initial CNS model and perform preliminary training on the initial CNS model;

[0096] In steps S101 and S102 of the present invention, the spatiotemporal sequence g t Entering the CNN module of the initial CNS model, the WOA algorithm is used based on the input spatiotemporal sequence g. t Automatically generate the necessary parameters, refine the initial structure of the CNN module, and before entering the convolutional layer, the spatiotemporal sequence g... tThey are usually organized into a tensor, with the shape represented as: (Batch Size, TimeSteps, Height, Width, Channels);

[0097] Step S103: In the multi-convolution module of the initial model training, the convolutional 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 convolutional network STGCN is used to extract spatiotemporal features from the feature tensor by alternately executing spatial graph convolution and temporal convolution. The feature dimension is formed based on the output four-dimensional tensor.

[0098] In step S103, local spatial and temporal information in the input data within the convolutional layer is extracted into a new feature map. Each convolutional kernel generates a new feature map, and the outputs of all convolutional kernels are combined into a new feature tensor. Within the pooling layer, local spatial and temporal information in the input data is extracted into a new feature map, and each pooling window generates a new feature value. The outputs of all pooling windows are combined into a new feature tensor, which is then fed into the second convolutional layer + pooling layer. The same operation as the first convolutional layer + pooling layer is repeated to further extract features. The relevant hyperparameters are automatically generated by the WOA algorithm, including the size and number of convolutional kernels, thereby improving the performance and accuracy of the model.

[0099] The Spatiotemporal Graph Convolutional Network (STGCN) of the CNS model 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 multiplied positionally by the adjacency matrix A to obtain a weighted adjacency matrix. This weighted adjacency matrix, along with the input feature tensor, is fed into the graph convolutional layer (GCN) to spatially aggregate the node features at each time step. Temporal convolution applies temporal convolution (TCN) to the features of each node to capture information in the temporal dimension. STGCN extracts spatiotemporal features progressively by alternately executing spatial graph convolution and temporal convolution. The parameters of STGCN are generated by the WOA algorithm. The output of STGCN is a four-dimensional tensor, represented as:

[0100] (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), and feed it into the BiLSTM layer of the CNS model;

[0101] For further details, please refer to [link / reference]. Figure 1 and Figure 2 The prediction method of this invention further includes:

[0102] Step S104: In the BiLSTM module of the initial model training, the time series data is processed bidirectionally to capture the dependencies between different time series.

[0103] In step S104, the BiLSTM module can capture the sequential dependencies in the time series by processing time series data bidirectionally. The output dimension of BiLSTM is (Batch Size, Time Steps, 2×Hidden Size). The bidirectional structure makes the output feature dimension twice that of unidirectional LSTM.

[0104] Step S105: In the attention mechanism module of the initial training of the model, 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.

[0105] In step S105, the purpose of the attention mechanism module is to weight the output of BiLSTM, highlighting important time-step features while suppressing unimportant information. This layer performs a non-linear transformation on the output of BiLSTM, calculates the weight of each time step through the softmax activation function, and sums the weighted output of BiLSTM according to the calculated weights 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 fed into one or more fully connected layers (Dense Layers) to further extract features and prepare the final output. The fully connected layers combine the input features by learning weights to identify higher-level features, and then predict the output results in the output layer.

[0106] In the attention mechanism module during the initial training of the model, the relevant hyperparameters are also automatically generated by the WOA algorithm based on the input;

[0107] Step S106: Use a dynamic spatiotemporal pruning strategy to dynamically prune each module of the model after initial training;

[0108] Step S107: Update the model parameters using the backpropagation algorithm to obtain the CNS model for soil moisture prediction.

[0109] Steps S106 and S107 provided by this invention are the model training stage. Dynamic spatiotemporal pruning technology is used to further improve the model's accuracy and generalization ability. Before the data is input into the model, unimportant time steps or spatial locations are removed by pruning to reduce the dimensionality 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 makes predictions, pruning reduces the amount of computation and improves the model's running efficiency. After a large number of training iterations and updates, the final CNS model is used for prediction.

[0110] In the CNS model of this invention embodiment, WOA (Whale Optimization Algorithm) is used to optimize hyperparameters to improve model performance, finding the optimal solution through a spiral update strategy and a prey encirclement strategy. Specifically, the WOA optimization algorithm is used to optimize the hyperparameters of the multi-convolutional module, BiLSTM module, and attention mechanism module in the initial CNS model, including:

[0111] When K≥1, the prey search strategy is executed, and the expression is:

[0112] ;

[0113] ;

[0114] Where P represents the distance between the current searched individual and the random individual, and X... rand It is the position vector of the currently following individual;

[0115] When A < 1, the prey encirclement strategy is executed, expressed as:

[0116] ;

[0117] 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 ranging from [-1, 1], p represents the probability of the predation mechanism, which is a random number from 0 to 1; X t Indicates the current position of the individual; K represents the scaling factor; X t+1 X represents the position of an individual at time t+1; t* This indicates the position of the individual with the best current solution;

[0118] This invention employs the Whale Optimization Algorithm (WOA) to automatically optimize the hyperparameters of the initial CNS model. By simulating the foraging behavior of humpback whales, the WOA algorithm effectively performs a global search in the parameter space to determine the optimal combination of hyperparameters, thereby further improving the model's predictive performance and generalization ability.

[0119] Furthermore, the step of extracting feature tensors from the local spatial and temporal information of the input data using convolutional and pooling layers includes:

[0120] Within the convolutional layer, features are extracted from the local spatial and temporal information in the input temporal data. Each convolutional kernel generates a new feature map, and the outputs of all convolutional kernels are combined into a new feature tensor to obtain the output sequence tensor. Within the pooling layer, the feature tensor output from the convolutional layer is used as input, and a pooling window slides across 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.

[0121] The new feature tensor is then fed into the next convolutional and pooling layer, and the above operations are repeated to extract the final feature tensor.

[0122] Furthermore, in the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers, reducing the feature map size and thus reducing the amount of computation.

[0123] The expression for the output feature map obtained by the convolution operation is: Y = σ(X*W + b);

[0124] Where W represents the convolution kernel, and the shape of the convolution kernel is represented as (F, C, F). H ,F W F is the number of convolutional kernels, C is the number of input channels, and F H It is the height of the convolution kernel, F W Y is the width of the convolution kernel; Y is the output feature map with shape (N, F, H). out W out ); σ is the ReLU activation function; * represents the convolution operation, H out W out The expressions are as follows:

[0125] ;

[0126] ;

[0127] Where P is the padding size, S is the stride; H represents the height of the input feature map, and W represents the width of the input feature map; H out W represents the height of the output feature map after the convolution operation. out This indicates the width of the output feature map after the convolution operation;

[0128] The expression for obtaining the value of the convolution kernel is:

[0129] ;

[0130] Among them, Yn,i,j,k X is the value of the output feature map at position (i,j) and the k-th convolutional kernel. i+m,j+n,c W is the value of the input data at position (i+m, j+n) and the c-th channel. m,n,c,k It is the value of the k-th convolutional kernel at position (m,n) and the c-th channel, b k It is the bias term of the k-th convolutional kernel;

[0131] 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 computation. The pooling layer uses average pooling operation, which is expressed as:

[0132] ;

[0133] Wherein, the pooling kernel size is (P H ,P W ), step size is (S) H ,S W );;Y n,f,i,j This represents the value of the output after pooling at position (i,j) and the f-th feature; P H P represents the height of the pooling kernel pooling window. W This indicates the width of the pooling window. This indicates the position of the input data (i·S) H +m,j·S W +n) and the value of the f-th feature.

[0134] Furthermore, the Spatiotemporal Graph Convolutional Network (STGCN) is used to extract spatiotemporal features from the feature tensor by alternately performing spatial graph convolution and temporal convolution. The steps for forming the feature dimension based on the output four-dimensional tensor include:

[0135] The Spatiotemporal Graph Convolutional Network (STGCN) processes spatiotemporal feature tensors by combining Spatial Graph Convolutional Network (GCN) and Temporal Convolutional Network (TCN).

[0136] Spatial graph convolution introduces a learnable weight matrix M, which is multiplied bitwise with the adjacency matrix A to obtain a weighted adjacency matrix.

[0137] The weighted adjacency matrix and the input feature tensor are fed into the graph convolutional layer GCN to perform spatial aggregation of node features at each time step. Temporal convolution (TCN) is applied to the features of each node to capture information in the time dimension.

[0138] STGCN extracts spatiotemporal features step by step by alternately performing spatial graph convolution and temporal convolution;

[0139] STGCN outputs a four-dimensional tensor that merges the Nodes and Channels dimensions to form a new feature dimension, which is then fed into the BiLSTM module of the CNS model.

[0140] Furthermore, in the Spatiotemporal Graph Convolutional Network (STGCN), graph convolution operations are used to capture spatial dependencies, represented 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, i.e., the diagonal matrix composed of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU;

[0141] Temporal convolution operations are used to capture dependencies in time series data, and are represented as follows:

[0142] ;

[0143] Wherein: H t H is the hidden state at time step t. t-1 It is the hidden state at time step t-1, W t and b t These are the learnable weight matrix and bias term at time step t, respectively.

[0144] Spatiotemporal feature fusion is used to combine spatial and temporal features to form a comprehensive understanding of the data, represented as: Where: F is the fused spatiotemporal feature, f is the fusion function (fusion method can be concatenation or weighted summation, the specific method is not limited), X' is the output of the graph convolution operation, and H... T It is the final output of the temporal convolution operation;

[0145] The prediction results are expressed as follows: Where Y is the prediction result, and W0 and b0 are the weights and biases of the output layer of the spatiotemporal graph convolutional network, respectively.

[0146] The four-dimensional tensor output by STGCN is represented 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.

[0147] Furthermore, the BiLSTM module controls the flow of information through a forget gate, an input gate, and an output gate. It also includes a cell state 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 dependencies.

[0148] Specifically, the gating mechanism of the BiLSTM module is expressed as follows:

[0149] ;

[0150] ;

[0151] ;

[0152] ;

[0153] ;

[0154] ;

[0155] Among them, A t It is the output of the forget gate, σ is the sigmoid activation function, and W is the output of the forget gate. f and b f It consists of weights and biases, E t-1是 The hidden state of the previous time step, x t This is the current input; B t It is the output of the input gate, G. t It is the state of the candidate memory cell; C t It is the memory cell state at the current time step, C t-1 It is the state of the memory unit in the previous time step; D t It is the output of the output gate, h t It is the hidden state at the current time step; b i b c b f and b o Both represent bias terms.

[0156] Furthermore, in the attention mechanism module of the CNS model, the working principle is to calculate the degree of correlation between each element in the input sequence, assign a weight to each element, and then perform a weighted sum of these elements. The attention mechanism can enhance the model's focus on the important parts of the input sequence while ignoring the less important parts. The attention weights can be interpreted as the contribution of each input element to the output, which helps to understand the model's decision-making process. Specifically, the attention mechanism layer includes query, key, and value, expressed as: Where Q represents the query matrix, K represents the key matrix, and V represents the value matrix; Q, K, and V all originate from the output of the previous layer; D k is the dimension of the key vector, used to scale the dot product result and avoid the gradient vanishing problem caused by excessive dimensionality; T represents the matrix transpose operation, and the softmax function is used to convert the dot product result into a probability distribution;

[0157] In the STGCN model, the attention mechanism is weighted by calculating the degree of correlation between points, and graph convolution and attention mechanisms are used to model the soil moisture data of the network structure. A spatiotemporal attention mechanism composed of spatial attention and temporal attention mechanisms is used to capture spatiotemporal correlation.

[0158] The spatial attention mechanism is represented as follows:

[0159] ;

[0160] ;

[0161] in, It is the output of the previous layer, V s b s M1, M2, and M3 are trainable parameters; L is the spatial attention matrix. L represents the spatial dependence between nodes i and j; finally, L is 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.

[0162] By introducing the aforementioned attention mechanism, this invention enables the model to adaptively capture the dynamic correlations between nodes in the spatial dimension.

[0163] Furthermore, this invention employs 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 model's adaptability to different data, and also reduce unnecessary calculations during inference, thereby improving computational efficiency.

[0164] Please refer to Figure 3 In the step of dynamically pruning each module of the initially trained model using a dynamic spatiotemporal pruning strategy, the output after dynamic pruning is represented as follows:

[0165] ;

[0166] Where f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are the weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, and Φ represents the parameters of the gating mechanism, which converts π(x, Φ) into a binary mask. When an element of the mask is 0, the corresponding channel is pruned.

[0167] The weight matrix after dynamic pruning is represented as follows: ;

[0168] Where W is the original weight matrix, is a dynamically generated mask, and W' is the pruned weight matrix;

[0169] Dynamic pruning selects a mask M(x) for each input x such that the pruned weight matrix W' satisfies the following optimization objective:

[0170] ;

[0171] in, It is a loss function used to measure model performance; The number of non-zero elements in the mask matrix controls the pruning intensity; λ is a regularization parameter used to balance model performance and pruning rate.

[0172] Dynamic spatiotemporal pruning is used to further train CNS models. This technique dynamically adjusts the model structure based on the spatiotemporal characteristics of the input data. By pruning the network during the model's runtime phase, it adapts 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.

[0173] In steps S106 and S107 of this invention, during the training process, the model parameters are iteratively updated to minimize the overall loss function, so as to ensure that the model can accurately predict soil moisture 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.

[0174] The model parameters are gradually adjusted during training until the loss function reaches the convergence condition.

[0175] Specifically, the overall loss is calculated using mean squared error (MSE) and mean absolute error (MAE), and combined with structural similarity index (SSIM) and peak signal-to-noise ratio (PSNR) as auxiliary evaluation metrics to further evaluate the model's performance.

[0176] The total loss is expressed as follows:

[0177] ;

[0178] The mean absolute error (MAE) is expressed as:

[0179] ;

[0180] Structural similarity (SSIM) is represented as:

[0181] ;

[0182] Peak signal-to-noise ratio (PSNR) is expressed as:

[0183] ;

[0184] Where prediction is the model's predicted value, true is the actual value, N is the number of samples, and μ is the actual value. pred and μ true分别 To calculate the mean of the predicted image and the real image, σ pred and σ true These are the variances of the predicted image and the real image, respectively; o1 and o2 are constants, usually set according to the dynamic range of SSIM, used to stabilize the calculation of SSIM.

[0185] In summary, the technical advantages of the CNS model soil moisture prediction method integrating dynamic spatiotemporal pruning and WOA algorithm provided by this invention are reflected in the following aspects:

[0186] Enhanced spatiotemporal feature extraction capability: The CNS model of this invention integrates a spatiotemporal graph convolutional network (STGCN), which can more effectively process spatiotemporal graph data and capture the spatial relationships and temporal changes between nodes compared to using the CNN-BiLSTM-Attention model alone; this enhanced spatiotemporal feature extraction capability makes the model more accurate and robust in predicting soil moisture.

[0187] Optimized hyperparameter selection: This invention uses the WOA algorithm to automatically select the optimal combination of hyperparameters. Compared with traditional methods such as manual adjustment or grid search, it can find hyperparameter settings that improve model performance more efficiently. This not only saves a lot of time on experiments and adjustments, but also further improves the model's predictive performance.

[0188] Dynamic spatiotemporal pruning mechanism: The dynamic spatiotemporal pruning technology proposed in this invention can dynamically adjust the sensing area of ​​the model according to changes in data, making the model more adaptable to different spatiotemporal data distributions. This mechanism improves the flexibility and computational efficiency of the model. In particular, when dealing with large-scale or variable soil moisture data, it can significantly reduce unnecessary calculations and improve the running speed and adaptability of the model.

[0189] In summary, through the above improvements, the model exhibits 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, making it suitable for scenarios such as agricultural irrigation and water resource management.

[0190] The above solutions are merely illustrative examples of preferred embodiments and are not intended to limit the scope of the invention. Appropriate substitutions and / or modifications can be made according to user needs when implementing this invention.

[0191] The number of devices and processing scale described herein are for the purpose of simplifying the description of the invention. Applications, modifications, and variations of the invention will be readily apparent to those skilled in the art.

[0192] Although embodiments of the present invention have been disclosed above, they are not limited to the applications listed in the specification and embodiments. It can be applied to various fields suitable for the present invention. Other modifications can be readily made by those skilled in the art. Therefore, without departing from the general concept defined by the claims and their equivalents, the present invention is not limited to the specific details and examples shown and described herein.

Claims

1. A soil moisture prediction method for CNS models integrating dynamic spatiotemporal pruning and WOA algorithm, characterized in that, The prediction method includes the following steps: An initial CNS model is constructed based on a multi-convolution module, a BiLSTM module, and an attention mechanism module. Soil time-series data, including soil temperature, humidity, and meteorological data, was used as input to the initial CNS model. The initial CNS model was initially trained, and the whale optimization algorithm was used to optimize the hyperparameters of the multi-convolution module, BiLSTM module, and attention mechanism module in the initial CNS model during training. In the initial training of the model, the multi-convolution module utilizes convolutional and pooling layers to extract feature tensors from the local spatial and temporal information of the input data. The Spatiotemporal Graph Convolutional Network (STGCN) then extracts spatiotemporal features from the feature tensors by alternately performing spatial graph convolution and temporal convolution, forming the feature dimension based on the output four-dimensional tensor. Specifically, the STGCN combines spatial graph convolution (GCN) and temporal convolution (TCN) to process the spatiotemporal feature tensors. Spatial graph convolution introduces a learnable weight matrix M, which is multiplied element-wise with the adjacency matrix A to obtain... The weighted adjacency matrix is ​​then fed into the graph convolutional layer (GCN) along with the input feature tensor. Spatial aggregation of node features at each time step is performed, and temporal convolution (TCN) is applied to the features of each node to capture information in the temporal dimension. STGCN extracts spatiotemporal features gradually 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, which is then fed into the BiLSTM module of the CNS model. In the BiLSTM module during the initial training of the model, the sequential dependencies in the time series are captured by bidirectional processing of time series data. In the attention mechanism module of the initial training of the model, 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. A dynamic spatiotemporal pruning strategy is employed to dynamically prune each module of the initially trained model, where the output after dynamic pruning is represented as follows: ; Where f(x, θ, ...) is the convolution operation, x is the input data, θ and φ are the weights, π(x, φ, ...) represents the gating mechanism used to generate the mask, and Φ represents the parameters of the gating mechanism, which converts π(x, ϕ) into a binary mask. When an element of the mask is 0, the corresponding channel is pruned. The weight matrix after dynamic pruning is represented as follows: ; 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 such that the pruned weight matrix W' satisfies the following optimization objective: ; in, It is a loss function used to measure model performance; The number of non-zero elements in the mask matrix controls the pruning intensity; λ is a regularization parameter used to balance model performance and pruning rate. The model parameters are updated using the backpropagation algorithm to obtain the CNS model for soil moisture prediction.

2. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 1, characterized in that, The step of optimizing the hyperparameters of the multi-convolutional module, BiLSTM module, and attention mechanism module in the initial CNS model using the whale optimization algorithm specifically includes: When K≥1, the prey search strategy is executed, and the expression is: ; ; Where P represents the distance between the current searched individual and the random individual, and X... rand It is the position vector of the currently following individual; When A < 1, the prey encirclement strategy is executed, expressed as: ; 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], and p represents the probability of the predation mechanism, which is a random number from 0 to 1.

3. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 2, characterized in that, The steps for extracting feature tensors from the local spatial and temporal information of the input data using convolutional and pooling layers include: Within the convolutional layer, features are extracted from the local spatial and temporal information in the input temporal data. Each convolutional kernel generates a new feature map, and the outputs of all convolutional kernels are combined into a new feature tensor to obtain the output sequence tensor. Within the pooling layer, the feature tensor output from the convolutional layer is used as input, and a pooling window slides across 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 is then fed into the next convolutional and pooling layer, and the above operations are repeated to extract the final feature tensor.

4. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 3, characterized in that, In the multi-convolution module, the convolutional neural network continuously extracts data features through multiple convolutional layers and pooling layers, reducing the feature map size; The expression for the output feature map obtained by the convolution operation is: Y = σ(X*W + b); Where W represents the convolution kernel, and the shape of the convolution kernel is represented as (F, C, F). H ,F W F is the number of convolutional kernels, C is the number of input channels, and F H It is the height of the convolution kernel, F W Y is the width of the convolution kernel; Y is the output feature map with shape (N, F, H). out W out ); σ is the ReLU activation function; * represents the convolution operation, H out W out The expressions are as follows: ; ; Where P is the padding size, S is the stride; H represents the height of the input feature map, and W represents the width of the input feature map; H out W represents the height of the output feature map after the convolution operation. out This indicates the width of the output feature map after the convolution operation; The expression for obtaining the value of the convolution kernel is: ; Among them, Y i,j,k X is the value of the output feature map at position (i,j) and the k-th convolutional kernel. i+m,j+n,c W is the value of the input data at position (i+m, j+n) and the c-th channel. m,n,c,k It is the value of the k-th convolutional kernel at position (m,n) and the c-th channel, b k It is the bias term of the k-th convolutional kernel; The pooling layer uses average pooling, which is expressed as: ; Wherein, the pooling kernel size is (P H ,P W ), step size is (S) H ,S W ).

5. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 4, characterized in that, In the Spatiotemporal Graph Convolutional Network (STGCN), graph convolution operations are used to capture spatial dependencies, represented 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, i.e., the diagonal matrix composed of the degree of each node, W is the learnable weight matrix, and σ is the activation function ReLU; Temporal convolution operations are used to capture dependencies in time series data, and are represented as follows: ; Wherein: H t H is the hidden state at time step t. t-1 It is the hidden state at time step t-1, W t and b t These are the learnable weight matrix and bias term at time step t, respectively. Spatiotemporal feature fusion combines spatial and temporal features, and is represented as: ; Where: F is the fused spatiotemporal feature, f is the fusion function, X' is the output of the graph convolution operation, and H... T It is the final output of the temporal convolution operation; The prediction results are expressed as follows: ; Where Y is the prediction result, and W0 and b0 are the weights and biases of the output layer of the spatiotemporal graph convolutional network, respectively. The four-dimensional tensor output by STGCN is represented 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.

6. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 5, characterized in that, In the BiLSTM module, the flow of information is controlled by forget gates, input gates and output gates, and a memory unit is also included to store information across time steps; The gating mechanism of the BiLSTM module is represented as follows: ; ; ; ; ; ; Among them, A t It is the output of the forget gate, σ is the sigmoid activation function, and W is the output of the forget gate. f and b f It consists of weights and biases, E t-1 It is the hidden state of the previous time step, x t This is the current input; B t It is the output of the input gate, G. t It is the state of the candidate memory cell; C t It is the memory cell state at the current time step, C t-1 It is the state of the memory unit in the previous time step; D t It is the output of the output gate, h t It is the hidden state of the current time step.

7. The soil moisture prediction method for the CNS model integrating dynamic spatiotemporal pruning and WOA algorithm according to claim 6, characterized in that, In the attention mechanism module, the degree of correlation between each element in the input sequence is calculated, a weight is assigned to each element, and then these elements are summed in a weighted manner. The attention mechanism layer includes queries, keys, and values, expressed as: ; Where Q represents the query matrix, K represents the key matrix, V represents the value matrix, and D represents the value matrix. 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 correlation between points, and graph convolution and attention mechanisms are used to model the soil moisture data of the network structure. A spatiotemporal attention mechanism, consisting of spatial and temporal attention mechanisms, is used to capture spatiotemporal correlations.