Aquaculture water quality parameter prediction method based on improved SSA

By introducing the Self-Attention mechanism and improving sparrow algorithm in the LSTM network, the problem of insufficient accuracy and long-term parameter adjustment in the prediction of water quality parameters is solved, and the prediction accuracy and efficiency are improved.

CN119312958APending Publication Date: 2025-01-14CHANGZHOU UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202411175117.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2025-01-14

AI Technical Summary

Technical Problem

The existing LSTM network has problems such as insufficient accuracy and inaccurate manual parameter adjustment and time-consuming in the prediction of water quality parameters.

Method used

The SA-LSTM model based on LSTM and Self-Attention was adopted, and the hyperparameters were optimized using the improved sparrow algorithm. The population was initialized by combining the Tent-Logistic-Cosine composite mapping, and the dynamic step size of the adaptive inertia factor was introduced to balance the global search and Local optimization ability.

Benefits of technology

The global search capability and prediction accuracy of the model are improved, the parameter convergence time is shortened, the ability to explore potential solution space is enhanced, and the accuracy of prediction of water quality parameters is achieved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119312958A_ABST
    Figure CN119312958A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of aquaculture, in particular to an aquaculture water quality parameter prediction method based on improved SSA, and the method comprises the steps: collecting water quality parameters; constructing an SA-LSTM model, extracting time sequence feature information in the water quality parameters by using an LSTM layer, updating output features of the LSTM layer by using a Self-Attention layer, and outputting a predicted water temperature value; and optimizing hyper-parameters of the SA-LSTM model by using a sparrow algorithm. According to the method, a self-attention mechanism is introduced into the LSTM neural network, and the problem that information attenuation or information forgetting may occur on long-sequence data of a model is solved; a composite chaotic mapping initialization population and an adaptive inertia weight factor are introduced into a traditional sparrow algorithm to solve the problems of low parameter convergence speed, poor global search capability and the like in an LSTM neural network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of aquaculture, and in particular to an aquaculture water quality parameter prediction method based on improved SSA. Background Art

[0002] The quality of water in the breeding pond directly affects the growth of aquatic products. Therefore, it is necessary to understand the dynamic changes of water quality parameters in the breeding pond in real time. Timely understanding of the changes in water quality parameters in the breeding pond can help accurately grasp the real-time water quality situation in the breeding pond area, which is of great significance to the healthy breeding of aquatic products in the breeding pond.

[0003] At present, Kumar et al. have verified the prediction of seawater quality by a hybrid model combining LSTM and RNN, and its performance is better than that of a single ANN and SVR positive feedback architecture model; Xiao et al. have constructed a prediction model combining CNN and LSTM (ConvL-STM) to capture the spatiotemporal series characteristics of water temperature, improving the accuracy of medium- and short-term sea temperature series prediction of water quality.

[0004] A method for predicting and treating aquaculture effluent based on an LSTM neural network model, published with publication number CN117875506A, uses an LSTM neural network prediction model to predict parameters such as ammonia nitrogen and pH in the device, controls water quality parameters, and monitors in real time through a water quality collection device to improve effluent quality; Liang Bing et al. conducted a study on water quality parameter prediction based on LSTM-Attention, which used a combination of LSTM neural network and Attention to predict dissolved oxygen; however, the above-mentioned LSTM hyperparameters require a lot of experiments and debugging, and often have problems such as insufficient prediction accuracy, inaccurate manual parameter adjustment, and long time consumption. Summary of the invention

[0005] In view of the shortcomings of the existing methods, the present invention solves the problems of insufficient accuracy, inaccurate manual parameter adjustment and long time consumption when the existing LSTM network is used to predict water quality parameters.

[0006] The technical solution adopted by the present invention is: a method for predicting aquaculture water quality parameters based on improved SSA comprises the following steps:

[0007] Step 1: Collect water quality parameters, and perform feature vector quantization and normalization on the water quality parameters;

[0008] As a preferred embodiment of the present invention, the water quality parameters include: pH, dissolved oxygen, permanganate index, ammonia nitrogen, total phosphorus, total nitrogen, conductivity and turbidity.

[0009] As a preferred embodiment of the present invention, linear interpolation is performed on the water quality parameters.

[0010] Step 2: Construct a SA-LSTM model based on LSTM and Self-Attention, including input layer, LSTM layer, Self-Attention layer and output layer. Use the LSTM layer to extract the time series feature information in the water quality parameters, use the Self-Attention layer to update the output features of the LSTM layer, and output the predicted water temperature value.

[0011] Step 3: Use the sparrow algorithm to optimize the hyperparameters of the SA-LSTM model.

[0012] As a preferred implementation of the present invention, the hyperparameters include: learning rate, number of iterations, and number of neurons in the first hidden layer and the second hidden layer.

[0013] As a preferred implementation of the present invention, the sparrow algorithm is improved, including:

[0014] Step 31, set the population size, the number of discoverers, joiners and guards, and initialize the population;

[0015] As a preferred embodiment of the present invention, population initialization adopts TLC composite mapping.

[0016] Step 32, obtaining the position of the initial sparrow;

[0017] Step 33, using the error function to calculate the fitness function value of the individual;

[0018] Step 34: introduce an adaptive inertia factor, and update the discoverer position, joiner position, and sentinel position according to the improved dynamic step size;

[0019] As a preferred embodiment of the present invention, the formula of the improved dynamic step length is:

[0020]

[0021] Among them, ω t is the adaptive inertia factor; t is the current iteration value; j is the number of parameters to be optimized; represents the position of the i-th sparrow in the j-th dimension at the t-th iteration; L is a unit row vector; α is a random number between [0,1]; iter max is the final number of iterations; Q is a standard normal distribution random number; R2 is the warning value; T s is a safe value.

[0022] Step 35: Recalculate the fitness function value of the sparrow and stop iterating when the iteration condition is met.

[0023] As a preferred implementation manner of the present invention, the iteration condition is an error.

[0024] As a preferred embodiment of the present invention, an aquaculture water quality parameter prediction system based on improved SSA includes: a memory for storing instructions executable by a processor; a processor for executing instructions to implement an aquaculture water quality parameter prediction method based on improved SSA.

[0025] As a preferred embodiment of the present invention, a computer readable medium stores computer program code, and when the computer program code is executed by a processor, the aquaculture water quality parameter prediction method based on the improved SSA is implemented.

[0026] Beneficial effects of the present invention:

[0027] 1. Introducing the self-attention mechanism into the traditional LSTM neural network, the self-attention mechanism can automatically learn the importance of different positions in the entire sequence, so that the model can understand the input sequence globally, not just local information, and improve the global search ability of the model, that is, it can solve the problem of information attenuation or information forgetting that may occur in the model on long sequence data;

[0028] 2. The traditional sparrow algorithm is improved by using dynamic inertia weight, which has a good balance between global search capability and local optimization capability; in the early stage of iteration, ω t The larger the value of , the discoverer can search in a wider area. As the iteration increases, the inertia weight will decrease nonlinearly, and the contribution of the discoverer will be dynamically adjusted, which will strengthen the search for local positions. This solves the problems of slow parameter convergence and poor global search capability.

[0029] 3. The population of the sparrow algorithm is initialized using the Tent-Logistic-Cosine composite mapping. The Tent function performs strong exploration and convergence in the central area, the Logistic function can provide a more continuous search process, and the Cosine function can help to conduct a wider exploration in the search space; therefore, the composite mapping can effectively enhance the algorithm's search space coverage ability and help to explore the potential solution space more comprehensively. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 It is a flow chart of the method for predicting aquaculture water quality parameters based on improved SSA of the present invention;

[0031] Figure 2 It is a structural diagram of the water quality parameter prediction model of the present invention;

[0032] Figure 3 It is a comparison diagram of the errors of prediction by the method of the present invention and the existing method using different mappings;

[0033] Figure 4It is a comparison chart of water temperature prediction by the method of the present invention and the existing method. DETAILED DESCRIPTION

[0034] The present invention is further described below in conjunction with the accompanying drawings and embodiments. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore it only shows the components related to the present invention.

[0035] like Figure 1 As shown, a method for predicting aquaculture water quality parameters based on improved SSA includes the following steps:

[0036] Step 1: Collect water quality parameters of the aquaculture pond at different times, and perform feature vector quantization and vector normalization on the water quality parameters to obtain a two-dimensional matrix of water quality parameters with time series feature information;

[0037] The sample data of water quality parameters are 0:00 on May 1, 2023 and 0:00 on September 1, 2023. The sample data include pH, dissolved oxygen, permanganate index, ammonia nitrogen, total phosphorus, total nitrogen, conductivity and turbidity. A total of 720 samples were collected at intervals of 4 hours; the first 80% were used as a training set and the last 20% were used as a test set; the water temperature of the breeding pond was predicted based on the sample data.

[0038] Check whether the sample data is missing, use linear interpolation to interpolate the missing data, and perform feature vectorization and vector normalization processing on it to obtain a two-dimensional matrix with time series feature information; the input layer reconstructs the sample data into a data format that can be read by the model.

[0039] Step 2: Build a water quality parameter prediction model based on LSTM neural network and Self-Attention;

[0040] The LSTM network can make full use of the time series feature information in historical data and explore the potential regular features in the time dimension; however, the existing water quality parameter prediction model did not take into account the impact of redundant features on model performance when it was designed, so the Self-Attention mechanism was introduced; the attention mechanism can make the model pay more attention to important features during training, reduce the impact of non-important features on the model, improve the model prediction accuracy, and accelerate the model convergence speed.

[0041] like Figure 2 As shown in the figure, the learning process is as follows:

[0042] The water quality parameter prediction model is set to include an input layer, an LSTM layer, a Self-Attention layer, and an output layer. The input layer, the LSTM layer, the Self-Attention layer, and the output layer are respectively the components of the water quality parameter prediction model. The output of the previous layer is the input of the next layer. The sparrow optimization algorithm optimizes the accuracy of the water temperature prediction model by optimizing the model hyperparameters.

[0043] Build the LSTM layer. The LSTM layer is placed after the input layer. The LSTM layer extracts the time series feature information in the water quality parameters. Specifically:

[0044] The forget gate is set to consist of a sigmoid neural network layer and a bitwise multiplication operation; the memory gate is set to consist of an input gate and a tanh neural network layer and a bitwise multiplication operation; the cell state is set to be represented by C t , which is used to save the current LSTM state information and pass it to the LSTM at the next moment; the output gate is set to work together with the tanh function and the bitwise multiplication operation to pass the cell state and input signal to the output gate, and the output gate outputs the vector that is the integration of the current input value and the output value at the previous moment.

[0045] Build the Self-Attention layer and update the features, specifically:

[0046] Define each input as X i , the output O of each time step is calculated through the memory unit in LSTM i =[O1,O2,……,O t ] and the hidden state H at the last time step t , use function g to represent the operation inside the LSTM model, the formula is as follows:

[0047] O t ,H t =g(X i ) (1)

[0048] Using hidden state H t The formula for calculating the query, key, value, and weighted sum is as follows:

[0049]

[0050] Among them, Q stands for Query; K stands for Key; V stands for Value. represents the scaling factor; softmax() is an activation function that is normalized by column; K T is the transposed matrix of K; ω Q ,ω k ,ω vare the linear transformation matrices that generate Q, K, and V respectively.

[0051] After the full connection layer and softmax operation, the final prediction output is obtained. The formula is as follows:

[0052]

[0053] in, Represents the value to be predicted; ω out represents the output weight matrix; b out Represents the output bias vector.

[0054] Step 3: Use the improved sparrow algorithm (SSA) to optimize the learning rate, number of iterations, first hidden layer neurons, and second hidden layer neurons of the SA-LSTM (Self-Attention Long Short-Term Memory) model. The details are as follows:

[0055] Step 31: Set the population size of SSA and the number of discoverers, joiners and sentinels, and initialize the population through Tent-Logistic-Cosine composite mapping (TLC) to obtain a relatively uniform initial population distribution.

[0056] The formula for TLC is as follows:

[0057]

[0058] Among them, y i is the sequence value of the i-th iteration; r is the control parameter.

[0059] When i When ∈[0,1], r∈[0,1], normalize formula (4) and limit the range to [0,1], the formula is as follows:

[0060] z i = abs(ωy i ) (5)

[0061] Where abs(·) is the absolute value function and ω is the normalization constant.

[0062] Step 32: Get the initial sparrow position. The formula is as follows:

[0063]

[0064] in, is the initial coordinate of the i-th sparrow in the j-th dimension, lb j andub jare the upper and lower bounds of the jth dimension, dimension j is the number of parameters to be optimized, and in this embodiment, j=4; the upper and lower bounds are the learning rate value range [0.001,0.1], the number of iterations value range is [10,100], and the number of hidden layer neurons value range is [1,100].

[0065] The learning rate, number of iterations, first hidden layer neurons, and second hidden layer neurons of the SA-LSTM model are optimized. The learning rate range is [0.001, 0.1], the number of iterations range is [10, 100], and the number of hidden layer neurons range is [1, 100].

[0066] Step 33: Calculate the fitness function value of the individual using the error function. The formula is:

[0067]

[0068] Among them, f is the fitness function value of the individual, y n is the measured value of water quality parameter, is the predicted value of water quality parameters, and N is the sample size.

[0069] Collectively select and compare individual extreme values ​​and the global extreme value of the population.

[0070] Step 34: Add adaptive inertia factor ω t , update the discoverer position, joiner position and alerter position according to the improved dynamic step size;

[0071] The dynamic inertia weight is used to improve the SSA algorithm, which balances the global search capability and the local optimization capability. In the early stage of the iteration, ω t The larger the value of , the discoverer can search in a wider area. As the iterations increase, the inertia weight will decrease nonlinearly, and the contribution of the discoverer will be dynamically adjusted, which will strengthen the search for local locations.

[0072] The formula for adaptive inertia weight factor and finder position is:

[0073]

[0074] Among them, ω t is the adaptive inertia weight factor; t is the current iteration value; j is the number of parameters to be optimized; represents the position of the i-th sparrow in the j-th dimension at the t-th iteration; L is a unit row vector; α is a random number between [0,1]; iter max is the final number of iterations; Q is a standard normal distribution random number; R2 is the warning value and R2∈[0,1]; T s is a safe value and T s∈[0.5,1].

[0075] Step 35, recalculate the fitness function value of the sparrow, and determine whether the error is within the target range. If yes, stop the iteration, otherwise return to step 34;

[0076] The final learning rate, number of iterations, number of neurons in the first hidden layer, and number of neurons in the second hidden layer are mapped to the SA-LSTM model, and the model is trained and constructed to predict and calculate the values ​​of the water quality parameters of the aquaculture pond.

[0077] Table 1 Results of the four model network outputs

[0078] index LSTM SA-LSTM SSA-SA-LSTM The present invention RMSE 0.1961 0.1782 0.1444 0.0727 MAE 0.1841 0.1645 0.1359 0.0629 <![CDATA[R 2 ]]> 0.9385 0.9492 0.9667 0.9915

[0079] like Figure 3 The comparison of MAE, RMSE and MAPE indicators when using different numbers of TLC mapping composites shows that the best effect is achieved when three chaotic mappings are used; Figure 4 As shown in Figure 1, the root mean square error (RMSE), mean absolute error (MAE) and determination coefficient (R2) are used as evaluation indicators to compare the prediction accuracy of the traditional LSTM model, SA-LSTM model, sparrow algorithm optimized SA-LSTM model (SSA-SA-LSTM), and the SA-LSTM model of the improved sparrow algorithm of the present invention. The comparison results are shown in Table 1. It can be seen from the table that the RMSE and MAE of the present invention are the smallest, indicating that the prediction accuracy of the model of the present invention is better than that of the existing model, and R 2 The value close to 1 has the best fitting effect.

[0080] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A method for predicting aquaculture water quality parameters based on improved SSA, characterized in that: The following steps are involved: Step 1: Collect water quality parameters, and perform feature vector quantization and normalization on the water quality parameters; Step 2: Construct a SA-LSTM model based on LSTM and Self-Attention, including input layer, LSTM layer, Self-Attention layer and output layer. Use the LSTM layer to extract the time series feature information in the water quality parameters, use the Self-Attention layer to update the output features of the LSTM layer, and output the predicted water temperature value. Step 3: Use the sparrow algorithm to optimize the hyperparameters of the SA-LSTM model.

2. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 1, characterized in that: Improvements to the sparrow algorithm include: Step 31, set the population size, the number of discoverers, joiners and guards, and initialize the population; Step 32, obtaining the position of the initial sparrow; Step 33, using the error function to calculate the fitness function value of the individual; Step 34: introduce an adaptive inertia factor, and update the discoverer position, joiner position, and sentinel position according to the improved dynamic step size; Step 35: Recalculate the fitness function value of the sparrow and stop iterating when the iteration condition is met.

3. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 2, characterized in that: Hyperparameters include: Learning rate, number of iterations, number of neurons in the first hidden layer and the second hidden layer.

4. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 2, characterized in that: The population is initialized using TLC composite mapping.

5. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 2, characterized in that: The formula for the improved dynamic step size is: Among them, ω t is the adaptive inertia factor; t is the current iteration value; j is the number of parameters to be optimized; represents the position of the i-th sparrow in the j-th dimension at the t-th iteration; L is a unit row vector; α is a random number between [0,1]; iter max is the final number of iterations; Q is a standard normal distribution random number; R2 is the warning value; T s is a safe value.

6. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 2, characterized in that: The iteration condition is the error.

7. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 1, characterized in that: Water quality parameters include: pH, dissolved oxygen, permanganate index, ammonia nitrogen, total phosphorus, total nitrogen, conductivity and turbidity.

8. The method for predicting aquaculture water quality parameters based on improved SSA according to claim 1, characterized in that: Linear interpolation of water quality parameters.

9. The aquaculture water quality parameter prediction system based on improved SSA is characterized by: include: a memory for storing instructions executable by a processor; A processor, used to execute instructions to implement a method for predicting aquaculture water quality parameters based on improved SSA as described in any one of claims 1-8.

10. A computer readable medium storing computer program code, characterized in that: When the computer program code is executed by a processor, the computer program code implements a method for predicting aquaculture water quality parameters based on improved SSA as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Cultivation tail water prediction processing method based on LSTM neural network model

    CN117875506A