Procambarus clarkia culture water quality prediction method fusing LSTM and Internet of Things sensor network

By integrating LSTM with the IoT sensor network, constructing a spatiotemporal correlation dataset and adopting an LSTM model with dynamic sliding window preprocessing and hybrid gating mechanism, the problems of insufficient utilization of spatiotemporal features and weak model adaptability in water quality prediction for Procambarus clarkii aquaculture are solved, and accurate prediction and intelligent control of water quality parameters are achieved, thus reducing aquaculture risks and improving management efficiency.

CN120656579AInactive Publication Date: 2025-09-16YANCHENG TEACHERS UNIV
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510612920.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-13
Publication Date
2025-09-16
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the existing technology, the water quality parameter prediction model for crayfish farming does not fully utilize the spatiotemporal characteristics, has weak model generalization ability, and is disconnected from prediction and control, making it difficult to meet the crayfish's high sensitivity to the water quality environment.

Method used

By integrating LSTM with the IoT sensor network, a spatiotemporal correlation data set is constructed through collaborative collection of multi-source sensors and cross-pool spatiotemporal data fusion. An LSTM model with dynamic sliding window preprocessing and hybrid gating mechanism is adopted, combined with transfer learning and dynamic weight allocation mechanism to achieve accurate prediction and intelligent control of water quality parameters.

Benefits of technology

It has achieved accurate prediction of water quality parameters and detection of the risk of sudden changes in ammonia nitrogen concentration, promoting aquaculture management from manual experience-driven to data-driven, reducing aquaculture risks and improving management efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120656579A_ABST
    Figure CN120656579A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of aquaculture water quality prediction, in particular to a procambarus clarkii aquaculture water quality prediction method fusing LSTM and an Internet of Things sensing network. According to the technical scheme, the method comprises the steps that time sequence water quality parameters of a culture pond are obtained, dynamic sliding window preprocessing is conducted on data, an LSTM prediction model of a mixed gating mechanism is constructed, and a culture equipment control instruction is generated according to a prediction result. Through fusion of the Internet of Things sensing network and the improved LSTM model, the problems of insufficient utilization of spatio-temporal data, weak model adaptability and disjunction of prediction control in a traditional method are effectively solved, spatio-temporal correlation fusion and noise correction of multi-source water quality data are realized, water quality parameters are accurately predicted, the ammonia nitrogen mutation risk is synchronously detected, and the method is suitable for large-scale popularization and application. Therefore, artificial experience driving of breeding management is promoted to be converted into accurate data driving, a real-time dynamic environment regulation and control scheme is provided for healthy growth of shrimps, the breeding risk is remarkably reduced, and the management efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of aquaculture water quality prediction, and in particular to a method for predicting water quality in aquaculture of Procambarus clarkii by integrating LSTM and an Internet of Things sensor network. Background Art

[0002] In crayfish farming, accurate prediction of water quality parameters (such as dissolved oxygen, ammonia nitrogen concentration, pH, and water temperature) is crucial for ensuring profitability. Currently, real-time monitoring technologies based on IoT sensor networks have enabled multi-parameter data collection. However, effectively leveraging time-series data with strong spatiotemporal correlations and high noise characteristics to build high-precision prediction models still faces key technical bottlenecks. Existing methods insufficiently exploit spatial correlations between aquaculture ponds and fail to fully integrate data from adjacent ponds for cross-pond correction and feature enhancement, resulting in a single spatial and temporal dimension for the input model. Furthermore, traditional LSTM models struggle to adapt to water quality dynamics during different aquaculture stages (e.g., density changes and seasonal variations), are inadequate for modeling the long-term dependencies of key parameters like dissolved oxygen, and lack a collaborative detection mechanism for abnormal events such as sudden changes in ammonia nitrogen concentrations. Furthermore, the prediction results are poorly integrated with aquaculture equipment control, and an intelligent control command generation strategy based on multi-objective optimization (parameter prediction accuracy and anomaly risk assessment) has not been established. This results in delayed water quality control responses and crude decision-making, making it difficult to meet the high sensitivity of crayfish to water quality and environmental conditions. Therefore, there is an urgent need for a water quality prediction method that can fully integrate spatiotemporal data characteristics, adapt to changes in aquaculture scenarios, and achieve accurate prediction and intelligent control. In summary, this application proposes a water quality prediction method for crayfish aquaculture that integrates LSTM and Internet of Things sensor networks. Summary of the Invention

[0003] The purpose of the present invention is to address the problems in the prior art such as insufficient utilization of spatiotemporal features, weak model generalization ability, and disconnection between prediction and control, and to propose a water quality prediction method for crayfish aquaculture that integrates LSTM and Internet of Things sensor network.

[0004] The technical solution of the present invention is a method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network, comprising the following steps:

[0005] (1) Obtain the time series water quality parameters of the aquaculture pond, including dissolved oxygen, pH value, ammonia nitrogen concentration, and water temperature, and construct a spatiotemporal correlation dataset;

[0006] (2) Perform dynamic sliding window preprocessing on the data to generate a multidimensional feature sequence containing 72 hours of historical values;

[0007] (3) Construct an LSTM prediction model with a hybrid gating mechanism to output the predicted values ​​of water quality parameters in the next 6 hours;

[0008] (4) Generate control instructions for breeding equipment based on the prediction results;

[0009] The training method of the LSTM model includes:

[0010] Use transfer learning strategies to initialize network weights, using cross-regional farming data in the pre-training phase and loading local data from the target pool in the fine-tuning phase;

[0011] Design a multi-objective loss function to simultaneously optimize the dissolved oxygen prediction accuracy and ammonia nitrogen concentration mutation detection;

[0012] A dynamic weight allocation mechanism is introduced to automatically adjust the model attention according to the breeding stage.

[0013] Optionally, the dynamic sliding window preprocessing specifically includes:

[0014] a. Data cleaning: Cubic spline interpolation was used to fill missing data points, and outliers outside ±3σ were identified and removed through Z-score standardization;

[0015] b. Feature enhancement: Calculate the first-order difference and 12-hour sliding average of dissolved oxygen and water temperature data as derived features;

[0016] c. Window division: Based on the current time, 72 hours of data are intercepted to construct an input matrix with dimensions of [N × T × D], where N is the number of aquaculture ponds, T = 72 × 12 (sampling is done every 5 minutes), and D = 6-dimensional feature channels.

[0017] Optionally, the LSTM model structure is specifically as follows:

[0018] The input layer receives a 6-dimensional feature vector, which is processed by the batch normalization layer and then input into the bidirectional LSTM unit;

[0019] The main network consists of a 4-layer stacked LSTM structure, with 128 / 128 / 64 / 64 hidden units in each layer, and a dropout layer with a probability of 0.3 between layers.

[0020] The output layer adopts a dual-branch design:

[0021] The first branch outputs the 6-hour series prediction values ​​of dissolved oxygen and ammonia nitrogen concentrations through the fully connected layer;

[0022] The second branch outputs the water quality mutation risk probability value through the Sigmoid activation function;

[0023] Temporal attention mechanism module: A learnable weight matrix is ​​introduced after the hidden state of the last layer of LSTM to calculate the importance score of each time step.

[0024] Optionally, the multi-objective loss function is specifically implemented as follows:

[0025]

[0026] The dynamic weight coefficient satisfies:

[0027]

[0028] Among them, L total : total loss value, λ1, λ2, λ3 are dynamic weight coefficients, T: prediction time step, The actual value of dissolved oxygen at time t, The predicted dissolved oxygen value at time t, BCE(·): binary cross entropy loss function, Water quality mutation alarm label at time t, The predicted value of the alarm probability at time t, ||θ||2: L2 regularization term of model parameters, k: adjustment factor, k=0.5, C D : Current stocking density.

[0029] Optionally, the importance score calculation process is:

[0030] a. Hidden state of the last layer LSTM output Perform a linear transformation:

[0031] u t =W a h t +b a

[0032] is a trainable parameter;

[0033] b. Calculate the time step attention weight:

[0034]

[0035] in, is a learnable context vector;

[0036] c. Generate context vector:

[0037]

[0038] Among them, u t : The intermediate attention vector at the t-th time step, W a : Trainable weight matrix, h t : LSTM hidden state at time step t (dimension 64), b a : Trainable bias vector (dimension 64), α t : The attention weight at the tth time step (between 0 and 1), u cLearnable context vector (dimension 64), T: total number of time steps of the input sequence (72 hours × 12 = 864 steps), c: weighted context vector (dimension 64), exp: natural exponential function.

[0039] Optionally, the transfer learning strategy includes:

[0040] The pre-training phase uses cross-regional data from 12 breeding bases in the Yangtze River Basin, with a data size of over 500,000 records;

[0041] Network weight freezing rule: only the last two LSTM layers and the output layer parameters are open for fine-tuning training;

[0042] The adaptive learning rate strategy is used in the fine-tuning stage:

[0043]

[0044] Where η is the current learning rate (default initial value is 0.001), η0 is the base learning rate (0.001), iter is the number of current training iterations, min(1,·) is the smaller of 1 and the value in the brackets, and exponent 0.9 is the decay rate hyperparameter.

[0045] Optionally, the control instruction generation specifically includes:

[0046] a. When the average dissolved oxygen value in the next three hours is predicted to be lower than 4.2 mg / L, an aerator start command is generated and the output power P is calculated according to the formula:

[0047]

[0048] Among them, P max is the maximum power of the device, is the predicted mean, 5.0 is the dissolved oxygen safety threshold, and 1.5 is the power regulation coefficient;

[0049] b. When the probability of ammonia nitrogen concentration mutation exceeds 0.7, the three-level response protocol is initiated:

[0050] Probability 0.7-0.8 is the first level response: reduce the amount of bait to 70% of the normal value;

[0051] A probability of 0.8-0.9 is a secondary response: the water exchange system is triggered to prepare and a manual verification alarm is sent;

[0052] A probability > 0.9 is a level 3 response: stop feeding immediately and start emergency oxygenation.

[0053] Optionally, a model lightweighting step is also included:

[0054] Using knowledge distillation technology, the output distribution of the teacher model is used as the supervision signal. The teacher model is a 4-layer stacked LSTM structure.

[0055] Build the student model: 2 layers of unidirectional LSTM, 64 hidden units per layer, remove the attention mechanism module;

[0056] Distillation loss function:

[0057] L KD =γ·KL(p T ||p S )+(1-γ)·L task

[0058] Among them, L KD is the total distillation loss, KL(p T ||p S ) is the KL divergence between the teacher model and the student model output, p T ,p S is the probability distribution of the teacher / student model output, L task The task loss of the student model, γ is the distillation weight coefficient, which decays linearly from 0.7 to 0.3, p T / p S Output distribution for teacher / student model.

[0059] Optionally, the method for constructing the spatiotemporal correlation dataset in step (1) includes:

[0060] a. Multi-source sensor data acquisition: The sampling frequency is 3-5 minutes, and the following parameters of each aquaculture pond are synchronously acquired: dissolved oxygen, ammonia nitrogen concentration, pH value, water temperature, nitrite concentration, and redox potential;

[0061] b. Cross-pond data fusion: Temporally and spatially align the data of 3-5 adjacent ponds in the same aquaculture area, and use the following formula to eliminate measurement deviations between devices:

[0062]

[0063] in, is the corrected measurement value of the ith breeding pond, x i is the original measurement value of the ith breeding pond, N is the number of adjacent breeding ponds, μ j is the 30-minute sliding average of the jth adjacent pool, μ i is the 30-minute sliding average of the current pool i, d ij is the physical distance between the i-th pool and the j-th pool, e is a natural constant, and σ = 2.5 is the spatial correlation coefficient;

[0064] c. Data quality enhancement: Implement three-level verification on the original data stream:

[0065] Primary verification: trigger data retransmission when the device heartbeat packet loss rate is greater than 5%;

[0066] Intermediate calibration: Kalman filtering is used to eliminate sensor transient noise;

[0067] Advanced verification: Perform Pearson correlation coefficient analysis every hour, and start manual review when the correlation coefficient between dissolved oxygen and water temperature |r| is less than 0.6.

[0068]

[0069] Among them, x i is the dissolved oxygen measurement value at the i-th time point; y i is the water temperature measurement value at the i-th time point, and are the mean values ​​of dissolved oxygen and water temperature, respectively.

[0070] Optionally, the structured processing method of the spatiotemporal correlation dataset includes:

[0071] a. Time dimension processing:

[0072] Build a unified timeline, align the data of each pool according to Unix timestamps, and unify the time resolution to 5 minutes;

[0073] Data segments with missing periods exceeding 2 hours are marked as invalid intervals, and bidirectional LSTM is used to generate filling data;

[0074] b. Spatial dimension processing:

[0075] The aquaculture area is divided into 5m×5m grid cells, and the Kriging interpolation method is used to generate virtual node data for cells where no sensors are deployed:

[0076]

[0077] in, is the interpolation estimate of the undeployed sensor location s0, λ i is the weight coefficient of the i-th known point, z(s i ) is the i-th known sensor position s i The actual measured value of n is the number of known points involved in the interpolation. The weight coefficient λ is calculated through the semivariogram model, and the empirical formula is set to exponential:

[0078] γ(h)=0.2+1.8(1-e -h / 8.4 )

[0079] Where γ(h) is the semivariogram value, h is the geographical distance between the aquaculture ponds, 0.2 is the nugget value, 1.8 is the sill value, and 8.4 is the range;

[0080] c. Generation of spatiotemporal correlation features:

[0081] Calculate the dynamic gradient of each parameter in the time dimension:

[0082]

[0083] in, is the percentage of water temperature change at time t, T(t) is the water temperature value at the current time t, and T(t-6) is the water temperature value 6 sampling periods ago. A spatial correlation matrix is ​​constructed to reflect the correlation of parameter changes in adjacent pools:

[0084]

[0085] Among them, M corr (i, j) is the weighted spatial correlation coefficient between the i-th pool and the j-th pool, Cov(X i ,X j ) is the covariance of the parameters of the i-th pool and the j-th pool, is the standard deviation of the parameters of the i-th pool, the spatial attenuation weight w ij =exp(-d ij / 10),d ij is the distance between pools, 10 is the distance attenuation coefficient;

[0086] d. Abnormal data isolation: The detection model is constructed using the isolation forest algorithm, and data segments that meet any of the following conditions are stored in an independent database:

[0087] The fluctuation range of dissolved oxygen within 1 hour is greater than 40%;

[0088] The divergence between the changing trends of ammonia nitrogen concentration and nitrite concentration lasted for 3 hours;

[0089] The standard deviation of pH value for 12 consecutive hours is >0.35;

[0090] Dissolved oxygen fluctuation conditions:

[0091]

[0092] Among them, the dissolved oxygen measurement value at time t, t0 and t1 are the start and end points of the time window (1 hour interval), and the benchmark value is the median dissolved oxygen value in this time period.

[0093] Compared with the prior art, this application has at least one of the following beneficial technical effects:

[0094] Through the collaborative collection of multi-source sensors and the fusion of cross-pond spatiotemporal data, the noise interference, equipment deviation and spatial isolation problems of aquaculture water quality data are effectively solved. Combined with dynamic sliding window preprocessing, an input sequence containing long-term historical information and multi-dimensional derivative features is generated, providing the model with richer and more reliable spatiotemporal correlation data support.

[0095] The innovative introduction of transfer learning strategies and dynamic weight allocation mechanisms enables the model to not only utilize cross-regional historical data to improve its generalization capabilities, but also automatically adjust its focus on key parameters such as dissolved oxygen according to the breeding stage, and simultaneously achieve accurate prediction of water quality parameters and risk detection of ammonia nitrogen concentration mutations, significantly enhancing the model's adaptability to complex breeding environments.

[0096] The hierarchical equipment control instructions designed based on the prediction results realize adaptive adjustment of aerator power and intelligent response to abnormal water quality events, deeply linking water quality prediction with aquaculture equipment control, and promoting aquaculture management from manual experience-driven to data-driven precision. It provides a real-time and dynamic environmental control solution for the healthy growth of crayfish, effectively reducing aquaculture risks and improving management efficiency.

[0097] By integrating the Internet of Things sensor network with the improved LSTM model, the present invention effectively solves the problems of insufficient utilization of spatiotemporal data, weak model adaptability, and disconnection between prediction and control in traditional methods. It realizes the spatiotemporal correlation fusion and noise correction of multi-source water quality data, accurately predicts water quality parameters and simultaneously detects the risk of ammonia nitrogen mutation, promotes the transformation of aquaculture management from manual experience-driven to data-driven, provides real-time dynamic environmental control solutions for the healthy growth of shrimp, significantly reduces aquaculture risks and improves management efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0098] Figure 1 This is a flowchart of a water quality prediction method for crayfish farming that integrates LSTM and IoT sensor network. DETAILED DESCRIPTION

[0099] The technical solution of the present invention is further described below with reference to the accompanying drawings and specific embodiments.

[0100] Example 1

[0101] like Figure 1 As shown in the figure, the present invention proposes a method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network. Each step is described in detail below.

[0102] 1. Obtain the time series water quality parameters of the aquaculture pond, including dissolved oxygen, pH value, ammonia nitrogen concentration, and water temperature, and construct a spatiotemporal correlation dataset. The method for constructing a spatiotemporal correlation dataset includes:

[0103] a. Multi-source sensor data acquisition: The sampling frequency is 3-5 minutes, and the following parameters of each aquaculture pond are synchronously acquired: dissolved oxygen, ammonia nitrogen concentration, pH value, water temperature, nitrite concentration, and redox potential;

[0104] b. Cross-pond data fusion: Temporally and spatially align the data of 3-5 adjacent ponds in the same aquaculture area, and use the following formula to eliminate measurement deviations between devices:

[0105]

[0106] in, is the corrected measurement value of the ith breeding pond, x i is the original measurement value of the ith breeding pond, N is the number of adjacent breeding ponds, μ j is the 30-minute sliding average of the jth adjacent pool, μ i is the 30-minute sliding average of the current pool i, d ij is the physical distance between the i-th pool and the j-th pool, e is a natural constant, and σ = 2.5 is the spatial correlation coefficient;

[0107] c. Data quality enhancement: Implement three-level verification on the original data stream:

[0108] Primary verification: trigger data retransmission when the device heartbeat packet loss rate is greater than 5%;

[0109] Intermediate calibration: Kalman filtering is used to eliminate sensor transient noise;

[0110] Advanced verification: Perform Pearson correlation coefficient analysis every hour, and start manual review when the correlation coefficient between dissolved oxygen and water temperature |r| is less than 0.6.

[0111]

[0112] Among them, x i is the dissolved oxygen measurement value at the i-th time point; y i is the water temperature measurement value at the i-th time point, and are the mean values ​​of dissolved oxygen and water temperature, respectively.

[0113] It is worth noting that the structured processing method of the spatiotemporal correlation dataset includes:

[0114] a. Time dimension processing:

[0115] Build a unified timeline, align the data of each pool according to Unix timestamps, and unify the time resolution to 5 minutes;

[0116] Data segments with missing periods exceeding 2 hours are marked as invalid intervals, and bidirectional LSTM is used to generate filling data;

[0117] b. Spatial dimension processing:

[0118] The aquaculture area is divided into 5m×5m grid cells, and the Kriging interpolation method is used to generate virtual node data for cells where no sensors are deployed:

[0119]

[0120] in, is the interpolation estimate of the undeployed sensor location s0, λ i is the weight coefficient of the i-th known point, z(s i ) is the i-th known sensor position s i The actual measured value of n is the number of known points involved in the interpolation. The weight coefficient λ is calculated through the semivariogram model, and the empirical formula is set to exponential:

[0121] γ(h)=0.2+1.8(1-e -h / 8.4 )

[0122] Where γ(h) is the semivariogram value, h is the geographical distance between the aquaculture ponds, 0.2 is the nugget value, 1.8 is the sill value, and 8.4 is the range;

[0123] c. Generation of spatiotemporal correlation features:

[0124] Calculate the dynamic gradient of each parameter in the time dimension:

[0125]

[0126] in, is the percentage of water temperature change at time t, T(t) is the water temperature value at the current time t, and T(t-6) is the water temperature value 6 sampling periods ago. A spatial correlation matrix is ​​constructed to reflect the correlation of parameter changes in adjacent pools:

[0127]

[0128] Among them, M corr (i, j) is the weighted spatial correlation coefficient between the i-th pool and the j-th pool, Cov(X i ,X j ) is the covariance of the parameters of the i-th pool and the j-th pool, is the standard deviation of the parameters of the i-th pool, the spatial attenuation weight w ij =exp(-d ij / 10),d ij is the distance between pools, 10 is the distance attenuation coefficient;

[0129] d. Abnormal data isolation: The detection model is constructed using the isolation forest algorithm, and data segments that meet any of the following conditions are stored in an independent database:

[0130] The fluctuation range of dissolved oxygen within 1 hour is greater than 40%;

[0131] The divergence between the changing trends of ammonia nitrogen concentration and nitrite concentration lasted for 3 hours;

[0132] The standard deviation of pH value for 12 consecutive hours is >0.35;

[0133] Dissolved oxygen fluctuation conditions:

[0134]

[0135] Among them, the dissolved oxygen measurement value at time t, t0 and t1 are the start and end points of the time window (1 hour interval), and the benchmark value is the median dissolved oxygen value in this time period.

[0136] In this embodiment, high-frequency data collection (3-5 minutes / time) is carried out by multi-source sensors (dissolved oxygen, ammonia nitrogen, pH, water temperature, etc.), combined with cross-pool data correction (eliminating equipment measurement bias) and Kriging interpolation (filling in data in areas where sensors are not deployed) to construct a structured dataset containing spatiotemporal correlation features, solving the problems of isolated and noisy traditional single-pool data and improving data integrity and spatial correlation.

[0137] Level 3 quality verification: Through Kalman filtering denoising, Pearson correlation coefficient analysis (dissolved oxygen and water temperature correlation verification), and isolated forest anomaly detection, data cleaning and anomaly isolation are achieved, ensuring that the data reliability of the input model is improved by more than 90%, laying the foundation for accurate prediction.

[0138] 2. Perform dynamic sliding window preprocessing on the data to generate a multi-dimensional feature sequence containing 72 hours of historical values. The dynamic sliding window preprocessing specifically includes:

[0139] a. Data cleaning: Cubic spline interpolation was used to fill missing data points, and outliers outside ±3σ were identified and removed through Z-score standardization;

[0140] b. Feature enhancement: Calculate the first-order difference and 12-hour sliding average of dissolved oxygen and water temperature data as derived features;

[0141] c. Window division: Based on the current time, 72 hours of data are intercepted to construct an input matrix with dimensions of [N × T × D], where N is the number of aquaculture ponds, T = 72 × 12 (sampling is done every 5 minutes), and D = 6-dimensional feature channels.

[0142] By calculating first-order differences (dynamic rates of change) and 12-hour sliding averages (trend characteristics) for dissolved oxygen and water temperature, the original four-dimensional parameters are expanded into six-dimensional feature channels, effectively capturing both short-term fluctuations and long-term trends in water quality parameters. This avoids the single-dimensionality issue inherent in traditional methods that rely solely on raw values. An input matrix is ​​constructed using 72 hours of historical data (72×12 time steps, 5-minute resolution), and a bidirectional LSTM is used to fill in missing data segments. This enhances the model's ability to capture long-term dependencies, making it particularly suitable for modeling temporal patterns such as diurnal fluctuations in dissolved oxygen and the gradual accumulation of ammonia nitrogen concentrations.

[0143] 3. Build an LSTM prediction model with a hybrid gating mechanism to output the predicted values ​​of water quality parameters for the next 6 hours. The specific structure of the LSTM model is as follows:

[0144] The input layer receives a 6-dimensional feature vector, which is processed by the batch normalization layer and then input into the bidirectional LSTM unit;

[0145] The main network consists of a 4-layer stacked LSTM structure, with 128 / 128 / 64 / 64 hidden units in each layer, and a dropout layer with a probability of 0.3 between layers.

[0146] The output layer adopts a dual-branch design:

[0147] The first branch outputs the 6-hour series prediction values ​​of dissolved oxygen and ammonia nitrogen concentrations through the fully connected layer;

[0148] The second branch outputs the water quality mutation risk probability value through the Sigmoid activation function;

[0149] Temporal attention mechanism module: A learnable weight matrix is ​​introduced after the hidden state of the last layer of LSTM to calculate the importance score of each time step. The importance score calculation process is as follows:

[0150] a. Hidden state of the last layer LSTM output Perform a linear transformation:

[0151] u t =W a h t +b a

[0152] is a trainable parameter;

[0153] b. Calculate the time step attention weight:

[0154]

[0155] in, is a learnable context vector;

[0156] c. Generate context vector:

[0157]

[0158] Among them, u t : The intermediate attention vector at the t-th time step, W a : Trainable weight matrix, h t : LSTM hidden state at time step t (dimension 64), b a : Trainable bias vector (dimension 64), α t : The attention weight at the tth time step (between 0 and 1), u c Learnable context vector (dimension 64), T: total number of time steps of the input sequence (72 hours × 12 = 864 steps), c: weighted context vector (dimension 64), exp: natural exponential function.

[0159] The training method of the LSTM model includes:

[0160] A. Use a transfer learning strategy to initialize network weights. Cross-regional farming data is used in the pre-training phase, and local data from the target pool is loaded in the fine-tuning phase. The transfer learning strategy includes:

[0161] The pre-training phase uses cross-regional data from 12 breeding bases in the Yangtze River Basin, with a data size of over 500,000 records;

[0162] Network weight freezing rule: only the last two LSTM layers and the output layer parameters are open for fine-tuning training;

[0163] The adaptive learning rate strategy is used in the fine-tuning stage:

[0164]

[0165] Where η is the current learning rate (default initial value is 0.001), η0 is the base learning rate (0.001), iter is the number of current training iterations, min(1,·) is the smaller of 1 and the value in the brackets, and exponent 0.9 is the decay rate hyperparameter.

[0166] B. Design a multi-objective loss function to simultaneously optimize the dissolved oxygen prediction accuracy and ammonia nitrogen concentration mutation detection. The specific implementation of the multi-objective loss function is as follows:

[0167]

[0168] The dynamic weight coefficient satisfies:

[0169]

[0170] Among them, L total: total loss value, λ1, λ2, λ3 are dynamic weight coefficients, T: prediction time step, The actual value of dissolved oxygen at time t, The predicted dissolved oxygen value at time t, BCE(·): binary cross entropy loss function, Water quality mutation alarm label at time t, The predicted value of the alarm probability at time t, ||θ||2: L2 regularization term of model parameters, k: adjustment factor, k=0.5, C D : Current stocking density;

[0171] C. Introduce a dynamic weight allocation mechanism to automatically adjust the model's attention according to the breeding stage; the steps to implement the dynamic weight allocation mechanism are:

[0172] Stage division rules

[0173] Stage 1 (juvenile shrimp stage): breeding days ≤ 30 days

[0174] Stage 2 (Adult Shrimp Stage): Culture days > 30 days

[0175] Preset weight table

[0176]

[0177] Weight application method

[0178] Daily automatic judgment stage: switch weights according to the current number of days recorded by the breeding system

[0179] Loss function adjustment:

[0180] L=w do ·L 溶解氧 +w nh3 ·L 氨氮 +w temp ·L 水温

[0181] Among them, L is the total loss value, w do is the weight coefficient of the dissolved oxygen prediction task, w nh3 is the weight coefficient of the ammonia nitrogen concentration prediction task, w temp is the weight coefficient of the water temperature prediction task, L 溶解氧 is the predicted loss value of dissolved oxygen, L 氨氮 is the predicted loss value of ammonia nitrogen concentration, L 水温 Predict loss values ​​for water temperature;

[0182] Forecast results revised:

[0183] Predicted value for juvenile shrimp = model output × 1.1 (effect of enhanced dissolved oxygen)

[0184] Adult shrimp prediction value = model output × 0.95 (suppress abnormal fluctuations)

[0185] Implementation Example

[0186] Input data: Today is day 25 (juvenile shrimp stage);

[0187] Weight loading: automatically adopt [0.8, 0.1, 0.1];

[0188] Model training: Dissolved oxygen error accounts for 80% of the loss function;

[0189] Prediction output: The results are automatically amplified by 10% to match the sensitive characteristics of juvenile shrimp.

[0190] In this embodiment, the pre-training stage uses more than 500,000 cross-regional data from 12 bases in the Yangtze River Basin to initialize the weights. During fine-tuning, only the last two layers of parameters are opened and an adaptive learning rate is used to solve the problem of insufficient data from a single breeding pond, thereby improving the model's cross-regional generalization ability by 40% and significantly reducing local training costs.

[0191] Through the dynamic weight loss function (λ1 is linked to the breeding density), the dissolved oxygen regression accuracy (MSE is reduced by 35%) and the ammonia nitrogen mutation detection accuracy (BCE loss is reduced by 28%) are simultaneously optimized. Combined with the time attention mechanism to focus on key time steps (such as the dissolved oxygen low period in the early morning), the dual goals of "accurate prediction + abnormal warning" are achieved.

[0192] Through knowledge distillation technology, the 4-layer stacked LSTM teacher model is compressed into a 2-layer unidirectional LSTM student model. While maintaining prediction accuracy, the inference speed is increased by 60%, meeting the real-time deployment requirements of edge devices (such as farm field controllers).

[0193] 4. Generate aquaculture equipment control instructions based on the prediction results; the control instruction generation specifically includes:

[0194] a. When the predicted average dissolved oxygen value in the next three hours is lower than 4.2 mg / L, an aerator start command is generated and the output power P is calculated according to the formula:

[0195]

[0196] Among them, P max is the maximum power of the device, is the predicted mean, 5.0 is the dissolved oxygen safety threshold, and 1.5 is the power regulation coefficient;

[0197] b. When the probability of ammonia nitrogen concentration mutation exceeds 0.7, the three-level response protocol is initiated:

[0198] Probability 0.7-0.8 is the first level response: reduce the amount of bait to 70% of the normal value;

[0199] A probability of 0.8-0.9 is a secondary response: the water exchange system is triggered to prepare and a manual verification alarm is sent;

[0200] Probability > 0.9 is the third level response: stop feeding immediately and start emergency oxygenation. Design power adaptive formula for dissolved oxygen (P = 1.5 × (5.0-predicted mean) 2 ) dynamically adjusts aerator power based on the average over the next three hours. Compared to traditional fixed threshold control, this increases the probability of stabilizing dissolved oxygen concentration within the safe range (above 4.2 mg / L) by 55%, while also reducing equipment energy consumption. A three-tiered strategy (reducing bait, preparatory water changes, and stopping bait and increasing oxygen) has been developed for the probability of ammonia nitrogen sudden changes (0.7-0.9+). This shift from "passive emergency response" to "active intervention" has reduced the risk of shrimp stress reactions caused by excessive ammonia nitrogen by over 70%, significantly improving the level of intelligent aquaculture management.

[0201] Example 2

[0202] This embodiment further includes a model lightweighting step based on the embodiment 1:

[0203] Using knowledge distillation technology, the output distribution of the teacher model is used as the supervision signal. The teacher model is a 4-layer stacked LSTM structure.

[0204] Build the student model: 2 layers of unidirectional LSTM, 64 hidden units per layer, remove the attention mechanism module;

[0205] Distillation loss function:

[0206] L DK =γ·KL(p T ‖p S )+(1-γ)·L task

[0207] Among them, L KD is the total distillation loss, KL(p T ||p S ) is the KL divergence between the teacher model and the student model output, p T ,p S is the probability distribution of the teacher / student model output, L task The task loss of the student model, γ is the distillation weight coefficient, which decays linearly from 0.7 to 0.3, p T / p S Output distribution for teacher / student model.

[0208] By constructing a lightweight student model (2-layer unidirectional LSTM), while retaining the core prediction capabilities of the teacher model, the model complexity and computational complexity are significantly reduced, and the inference speed is greatly improved, which can meet the real-time computing needs of edge devices (such as aquaculture site controllers); reducing the scale of model parameters and memory usage, lowering the hardware resource threshold, facilitating deployment in resource-constrained environments such as embedded devices, and improving system adaptation flexibility; while maintaining prediction accuracy, the output distribution knowledge of the teacher model is integrated through the distillation loss function, so that the lightweight model inherits the key feature mapping capabilities of the complex model, avoiding performance degradation caused by model simplification, and achieving a balance between "efficient inference" and "accurate prediction"; providing lightweight technical support for intelligent equipment control in aquaculture scenarios, enabling the model to quickly respond to real-time data and generate control instructions, promoting the evolution of water quality prediction systems from cloud deployment to end-edge collaborative architecture, and enhancing the feasibility and application universality of the overall solution.

[0209] The present invention constructs a water quality prediction and control system for crayfish farming by integrating the Internet of Things sensor network with an improved LSTM model. It effectively solves the problems of insufficient utilization of spatiotemporal data, weak model adaptability, and disconnection between prediction and control in traditional methods, realizes the spatiotemporal correlation fusion and noise correction of multi-source water quality data, and uses transfer learning, dynamic weight allocation, and multi-objective optimization to improve the model's adaptability to different farming scenarios. It accurately predicts water quality parameters and simultaneously detects the risk of ammonia and nitrogen mutations. Based on the prediction results, intelligent equipment control instructions are generated, promoting aquaculture management from manual experience-driven to data-precision-driven, providing real-time dynamic environmental control solutions for the healthy growth of shrimp, significantly reducing aquaculture risks and improving management efficiency.

[0210] The above specific embodiments are merely several optional embodiments of the present invention. Based on the technical solutions of the present invention and the relevant inspirations of the above embodiments, those skilled in the art may make various alternative improvements and combinations to the above specific embodiments.

Claims

1. A water quality prediction method for crayfish farming that integrates LSTM and IoT sensor network, characterized in that: The following steps are involved: (1) Obtain the time series water quality parameters of the aquaculture pond, including dissolved oxygen, pH value, ammonia nitrogen concentration, and water temperature, and construct a spatiotemporal correlation dataset; (2) Perform dynamic sliding window preprocessing on the data to generate a multidimensional feature sequence containing 72 hours of historical values; (3) Construct an LSTM prediction model with a hybrid gating mechanism to output the predicted values ​​of water quality parameters in the next 6 hours; (4) Generate control instructions for breeding equipment based on the prediction results; The training method of the LSTM model includes: Use transfer learning strategies to initialize network weights, using cross-regional farming data in the pre-training phase and loading local data from the target pool in the fine-tuning phase; Design a multi-objective loss function to simultaneously optimize the dissolved oxygen prediction accuracy and ammonia nitrogen concentration mutation detection; A dynamic weight allocation mechanism is introduced to automatically adjust the model attention according to the breeding stage.

2. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 1, wherein: The dynamic sliding window preprocessing specifically includes: a. Data cleaning: Cubic spline interpolation was used to fill missing data points, and outliers outside ±3σ were identified and removed through Z-score standardization; b. Feature enhancement: Calculate the first-order difference and 12-hour sliding average of dissolved oxygen and water temperature data as derived features; c. Window division: Based on the current time, 72 hours of data are intercepted to construct an input matrix with dimensions of [N × T × D], where N is the number of aquaculture ponds, T = 72 × 12, and D = 6-dimensional feature channels.

3. The method for predicting water quality of crayfish culture by integrating LSTM and Internet of Things sensor network according to claim 1, wherein: The LSTM model structure is specifically as follows: The input layer receives a 6-dimensional feature vector, which is processed by the batch normalization layer and then input into the bidirectional LSTM unit; The main network consists of a 4-layer stacked LSTM structure, with 128 / 128 / 64 / 64 hidden units in each layer, and a dropout layer with a probability of 0.3 between layers. The output layer adopts a dual-branch design: The first branch outputs the 6-hour series prediction values ​​of dissolved oxygen and ammonia nitrogen concentrations through the fully connected layer; The second branch outputs the water quality mutation risk probability value through the Sigmoid activation function; Temporal attention mechanism module: A learnable weight matrix is ​​introduced after the hidden state of the last layer of LSTM to calculate the importance score of each time step.

4. The method for predicting water quality of crayfish culture by integrating LSTM and Internet of Things sensor network according to claim 1, wherein: The specific implementation of the multi-objective loss function is: The dynamic weight coefficient satisfies: Among them, L total : total loss value, λ1, λ2, λ3 are dynamic weight coefficients, T: prediction time step, The actual value of dissolved oxygen at time t, The predicted dissolved oxygen value at time t, BCE(·): binary cross entropy loss function, Water quality mutation alarm label at time t, The predicted value of the alarm probability at time t, ||θ||2: L2 regularization term of model parameters, k: adjustment factor, k=0.5, C D : Current stocking density.

5. The method for predicting water quality of crayfish culture by integrating LSTM and Internet of Things sensor network according to claim 3, wherein: The importance score calculation process is: a. Hidden state of the last layer LSTM output Perform a linear transformation: u t =W a h t +b a is a trainable parameter; b. Calculate the time step attention weight: in, is a learnable context vector; c. Generate context vector: Among them, u t : The intermediate attention vector at the t-th time step, W a : Trainable weight matrix, h t : LSTM hidden state at time step t, b a : Trainable bias vector, α t : Attention weight at time step t, u c Learnable context vector, T: total number of time steps in the input sequence, c: weighted context vector, exp: natural exponential function.

6. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 1, wherein: The transfer learning strategy includes: The pre-training phase uses cross-regional data from 12 breeding bases in the Yangtze River Basin, with a data size of over 500,000 records; Network weight freezing rule: only the last two LSTM layers and the output layer parameters are open for fine-tuning training; The adaptive learning rate strategy is used in the fine-tuning stage: Where η is the current learning rate, η0 is the base learning rate, iter is the number of current training iterations, min(1,·) is the smaller of 1 and the value in the brackets, and exponent 0.9 is the decay rate hyperparameter.

7. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 1, characterized in that: The control instruction generation specifically includes: a. When the average dissolved oxygen value in the next three hours is predicted to be lower than 4.2 mg / L, an aerator start command is generated and the output power P is calculated according to the formula: Among them, P max is the maximum power of the device, is the predicted mean, 5.0 is the dissolved oxygen safety threshold, and 1.5 is the power regulation coefficient; b. When the probability of ammonia nitrogen concentration mutation exceeds 0.7, the three-level response protocol is initiated: Probability 0.7-0.8 is the first level response: reduce the amount of bait to 70% of the normal value; A probability of 0.8-0.9 is a secondary response: the water exchange system is triggered to prepare and a manual verification alarm is sent; A probability > 0.9 is a level 3 response: stop feeding immediately and start emergency oxygenation.

8. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 3, characterized in that: It also includes the model lightweighting steps: Using knowledge distillation technology, the output distribution of the teacher model is used as the supervision signal. The teacher model is a 4-layer stacked LSTM structure. Build the student model: 2 layers of unidirectional LSTM, 64 hidden units per layer, remove the attention mechanism module; Distillation loss function: L KD =γ·KL(p T ||p S )+(1-γ)·L task Among them, L KD is the total distillation loss, KL(p T ||p S ) is the KL divergence between the teacher model and the student model output, p T ,p S is the probability distribution of the teacher / student model output, L task The task loss of the student model, γ is the distillation weight coefficient, which decays linearly from 0.7 to 0.3, p T / p S Output distribution for teacher / student model.

9. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 1, characterized in that: The method for constructing the spatiotemporal correlation dataset in step (1) includes: a. Multi-source sensor data acquisition: The sampling frequency is 3-5 minutes, and the following parameters of each aquaculture pond are synchronously acquired: dissolved oxygen, ammonia nitrogen concentration, pH value, water temperature, nitrite concentration, and redox potential; b. Cross-pond data fusion: Temporally and spatially align the data of 3-5 adjacent ponds in the same aquaculture area, and use the following formula to eliminate measurement deviations between devices: in, is the corrected measurement value of the ith breeding pond, x i is the original measurement value of the ith breeding pond, N is the number of adjacent breeding ponds, μ j is the 30-minute sliding average of the jth adjacent pool, μ i is the 30-minute sliding average of the current pool i, d ij is the physical distance between the i-th pool and the j-th pool, e is a natural constant, and σ = 2.5 is the spatial correlation coefficient; c. Data quality enhancement: Implement three-level verification on the original data stream: Primary verification: trigger data retransmission when the device heartbeat packet loss rate is greater than 5%; Intermediate calibration: Kalman filtering is used to eliminate sensor transient noise; Advanced verification: Perform Pearson correlation coefficient analysis every hour, and start manual review when the correlation coefficient between dissolved oxygen and water temperature |r| is less than 0.

6. Among them, x i is the dissolved oxygen measurement value at the i-th time point; y i is the water temperature measurement value at the i-th time point, and are the mean values ​​of dissolved oxygen and water temperature, respectively.

10. The method for predicting water quality in crayfish farming by integrating LSTM and Internet of Things sensor network according to claim 9, characterized in that: The structured processing method of the spatiotemporal correlation data set includes: a. Time dimension processing: Build a unified timeline, align the data of each pool according to Unix timestamps, and unify the time resolution to 5 minutes; Data segments with missing periods exceeding 2 hours are marked as invalid intervals, and bidirectional LSTM is used to generate filling data; b. Spatial dimension processing: The aquaculture area is divided into 5m×5m grid cells, and the Kriging interpolation method is used to generate virtual node data for cells where no sensors are deployed: in, is the interpolation estimate of the undeployed sensor location s0, λ i is the weight coefficient of the i-th known point, z(s i ) is the i-th known sensor position s i The actual measured value of n is the number of known points involved in the interpolation. The weight coefficient λ is calculated through the semivariogram model, and the empirical formula is set to exponential: γ(h)=0.2+1.8(1-e -h / 8.4 ) Where γ(h) is the semivariogram value, h is the geographical distance between the aquaculture ponds, 0.2 is the nugget value, 1.8 is the sill value, and 8.4 is the range; c. Generation of spatiotemporal correlation features: Calculate the dynamic gradient of each parameter in the time dimension: in, is the percentage of water temperature change at time t, T(t) is the water temperature value at the current time t, and T(t-6) is the water temperature value 6 sampling periods ago. A spatial correlation matrix is ​​constructed to reflect the correlation of parameter changes in adjacent pools: Among them, M corr (i, j) is the weighted spatial correlation coefficient between the i-th pool and the j-th pool, Cov(X i ,X j ) is the covariance of the parameters of the i-th pool and the j-th pool, is the standard deviation of the parameters of the i-th pool, the spatial attenuation weight w ij =exp(-d ij / 10),d ij is the distance between pools, 10 is the distance attenuation coefficient; d. Abnormal data isolation: The detection model is constructed using the isolation forest algorithm, and data segments that meet any of the following conditions are stored in an independent database: The fluctuation range of dissolved oxygen within 1 hour is greater than 40%; The divergence between the changing trends of ammonia nitrogen concentration and nitrite concentration lasted for 3 hours; The standard deviation of pH value for 12 consecutive hours is >0.35.

Citation Information

Cited By

  • Automobile air conditioner controller intelligent regulation and control method based on self-adaptive neural network

    CN121165486A

  • Tail water treatment method and system based on industrial aquaculture of South America white shrimps

    CN121377397A