A heavy metal pollution automatic detection method based on a bidirectional long short-term memory neural network

CN122814716APending Publication Date: 2026-09-25NANJING NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610722002.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-05-25
Publication Date
2026-09-25

AI Technical Summary

Technical Problem

[0007]目前尚无将双向长短期记忆神经网络与SMFC传感器相结合用于重金属污染自动检测的技术方案

Benefits of technology

1. 本发明能够自动学习SMFC电压信号的复杂时序特征,无需人工干预即可实现重金属污染事件的智能检测,显著提高了监测效率;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122814716A_ABST
    Figure CN122814716A_ABST
Patent Text Reader

Abstract

The application discloses a heavy metal pollution automatic detection method based on a bidirectional long short-term memory neural network, and belongs to the technical field of environmental monitoring. The method realizes intelligent detection of heavy metal pollution events by monitoring voltage changes of a water body environment in real time through a sediment microbial fuel cell sensor and automatically learning complex time sequence patterns in voltage time sequence data by using a bidirectional long short-term memory neural network model. In order to guarantee detection robustness in a complex field environment, the application simultaneously captures forward and backward time dependence of the voltage signal by using a bidirectional long short-term memory neural network structure, effectively distinguishes real pollution signals from environmental noise, and realizes accurate and continuous monitoring of heavy metal pollution events without manual intervention.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of environmental monitoring technology, specifically relating to an automatic detection method for heavy metal pollution using a sediment microbial fuel cell sensor based on a bidirectional long short-term memory neural network (BiLSTM). Background Technology

[0002] Currently, major pollution sources such as industrial emissions, agricultural runoff, and improper waste disposal are causing increasingly serious problems such as the enrichment of heavy metals, organic pollutants, and nutrients in the aquatic environment. Traditional water quality monitoring methods rely on manual sampling and laboratory analysis, which are labor-intensive, time-consuming, and unable to provide early warnings of pollution incidents. Existing in-situ monitoring technologies (such as optical sensors) rely on external power sources, resulting in high operating costs and short lifespans. Furthermore, these systems generally lack integration with intelligent communication infrastructure, making real-time data transmission and processing difficult.

[0003] Sedimentary microbial fuel cell (SMFC) sensors, as an emerging self-powered environmental monitoring tool, can simultaneously generate energy and detect pollutants under in-situ conditions. An SMFC sensor consists of an anode buried in sediment and a cathode located in the overlying water. Electrogenic microorganisms oxidize organic matter at the anode and release electrons, generating a measurable voltage output. These voltage signals are sensitive to environmental changes and can be used to detect pollutants such as biochemical oxygen demand (BOD), heavy metals, and pH fluctuations.

[0004] However, the identification of voltage signals generated by SMFC sensors typically relies on manual analysis, which limits the robustness of detection under dynamic field conditions. Baseline voltage drift caused by environmental noise such as temperature or precipitation further affects the robustness of manual detection. Thresholds calibrated under laboratory conditions are often unable to adapt to complex and variable field environments, limiting the feasibility of real-time deployment.

[0005] In recent years, artificial intelligence (AI) technology has shown great promise in improving environmental monitoring through automatic pattern recognition and adaptive decision-making. In the field of environmental monitoring, supervised learning algorithms such as Support Vector Machines (SVM), Random Forests (RF), and Artificial Neural Networks (ANN) are widely used. However, these shallow learning models lack the ability to learn long-range dependencies in non-stationary signal flows, struggle to cope with temporal noise and sudden environmental changes, and limit their predictive accuracy on extended water quality time series.

[0006] Recurrent neural networks (RNNs), especially long short-term memory (LSTM) models, have proven effective in water quality prediction by selectively storing information through gated memory units. Bidirectional long short-term memory networks (BiLSTMs) can more comprehensively model time dependencies by introducing two LSTM layers to process forward and backward sequences respectively. The advantages of BiLSTMs in pollution detection include: (1) capturing long-term dependencies: effectively learning voltage fluctuation patterns within an extended time window, and being robust to short-term signal noise; (2) utilizing past and future information: forward LSTMs learn historical trends, and backward LSTMs integrate future time cues, improving the accuracy of pollution event detection; (3) improving robustness to signal noise: combining forward and backward time dependencies helps distinguish real pollution signals from background voltage noise.

[0007] Currently, there is no technical solution that combines bidirectional long short-term memory neural networks with SMFC sensors for automatic detection of heavy metal pollution. Therefore, it is of great significance to develop a method that can automatically learn the timing characteristics of SMFC voltage signals and achieve intelligent identification of pollution events without human intervention. Summary of the Invention

[0008] This invention provides an automated detection method for heavy metal pollution in sediment microbial fuel cells based on BiLSTM. It monitors voltage changes in the aquatic environment in real time using an SMFC sensor and automatically learns complex temporal patterns in voltage time-series data using a bidirectional long short-term memory neural network model, achieving intelligent detection of heavy metal pollution events. To improve detection accuracy and robustness, the BiLSTM model simultaneously processes forward and backward time-series information, effectively capturing voltage characteristic changes caused by pollution events.

[0009] The method includes the following steps: Step 1: Construct and deploy SMFC sensors in different wetland environments and collect voltage data in real time; Step 2 involves preprocessing the acquired real-time voltage data, including missing value imputation, data normalization, moving average filtering for noise reduction, contamination event labeling, time series sample construction, class balancing, and dataset partitioning. Step 3: Construct a BiLSTM model, which includes two bidirectional LSTM layers, a fully connected layer, and a sigmoid output layer. Train the model using a weighted binary cross-entropy loss function. Step 4: Input real-time voltage data into the trained BiLSTM model, output the contamination probability and determine the contamination event.

[0010] Furthermore, in step 1, the method for constructing and deploying the SMFC sensor is as follows: a stainless steel tube is used as the anode, a platinum mesh is used as the cathode, the anode and cathode are connected by an external resistor, the anode is buried in the sediment, the cathode floats on the water surface, and a data acquisition module is used to collect voltage data in real time to simulate heavy metal pollution events of different concentrations to construct a training dataset.

[0011] Specifically, alkaline, acidic, and neutral paddy soils from the intertidal zone were used as representative wetland environments. K₂CrO₄ solutions of different concentrations (5, 10, 20, 40, 80, 120, 160, 200 mg / L) were used to simulate Cr content. 6 ⁺ A pollution impact experiment was conducted during the pollution event to obtain real-time voltage data.

[0012] Furthermore, in step 2, the data preprocessing process is as follows: missing values ​​are filled using forward and backward methods to maintain data continuity; each voltage channel is normalized using Min-Max; a moving average filter is used to smooth voltage fluctuations and reduce high-frequency noise; pollution event time points are labeled (label 1 indicates pollution, label 0 indicates no pollution); time series samples are constructed according to a sliding window; synthetic minority oversampling (SMOTE) technique is used to handle class imbalance; and the time series samples are divided into training and test sets.

[0013] Specifically, the data preprocessing methods are as follows: (1) Missing value filling: For missing data points in the voltage sequence, forward fill and backward fill methods are used to maintain data continuity; (2) Data normalization: Min-Max normalization is performed on each voltage channel separately. The calculation formula is as follows: , in, This is the original voltage value. and These are the minimum and maximum values ​​of the channel, respectively. The value is the normalized value; (3) Moving average filtering: A moving average filter with a window size of w is used to smooth voltage fluctuations and reduce high-frequency noise. The calculation formula is as follows: ; (4) Pollution event labeling: Label 1 indicates that pollution existed at that time point, and label 0 indicates that there was no pollution; (5) Time Series Sample Construction: The sliding window method is used to convert continuous voltage time series data into fixed-length training samples. The sliding window length is set to L=200, that is, each sample contains voltage data of 200 consecutive time points. The sliding step size is set to S. Starting from the beginning of the time series, the sliding window moves forward by S time points each time, and a voltage sequence segment of length L is extracted as a sample. For each sample, its label is determined by the label information in the window: if there is a time point with label 1 in the window, the label of the sample is 1 (contamination event); otherwise, the label is 0 (normal state). The sliding process is repeated until the entire time series is covered, and finally the sample set is obtained. ,in Let L be the voltage sequence matrix of the i-th sample, L be the time step, and D be the feature dimension. For the corresponding labels, M is the total number of samples; (6) Class balancing: Since the number of pollution event samples is significantly less than the number of normal state samples, SMOTE is used to oversample the minority class samples to generate synthetic samples to balance the training dataset. (7) Data set partitioning: The constructed sample set is divided into training set and test set in chronological order, with a partition ratio of 80:20, to ensure that samples of the same contamination event do not appear in the training set and test set at the same time, so as to avoid data leakage; the specific method is: the first 80% of the samples are used as the training set and the last 20% of the samples are used as the test set in chronological order, so as to maintain the continuity of the time series and the temporal characteristics of the real scene.

[0014] Further, in step 3, the BiLSTM model includes: an input layer receiving the preprocessed voltage time series; a forward LSTM layer processing the sequence from front to back; a backward LSTM layer processing the sequence from back to front; concatenating the forward and backward hidden states at each time step; extracting features through a fully connected layer of 256 neurons and the ReLU activation function; and outputting the contamination probability using the Sigmoid activation function. The model is trained using the Adam optimizer with a learning rate of 0.0001, a batch size of 16, and 40 training epochs, using a weighted binary cross-entropy loss function to handle class imbalance.

[0015] Specifically, the construction and training methods of the BiLSTM model are as follows: (1) Input layer: Receives preprocessed voltage time series data ,in For time step; (2) Forward LSTM layer: Two stacked layers, each with 128 hidden units. (In chronological order from...) arrive Processing the input sequence. Each LSTM unit contains four gating mechanisms: forget gate, input gate, cell state update gate, and output gate, which operate at time steps. The calculation process is as follows: Forget gate (controls the proportion of the cell state retained from the previous moment): , Input gate (controls the amount of new information written): , Candidate cell states (generating new information to be written): , Cell state update (merging forgotten old information with written new information): , Output gate (controls the hidden state of the output): , Final forward hidden state (dimension 128): , in, It is the Sigmoid activation function. This is element-wise multiplication; and These are the input weight matrix (dimension 128×1) and the cyclic weight matrix (dimension 128×128) for each gate. This is the corresponding bias vector. The gating calculation described above is performed independently in each layer (two layers in total) of the forward and backward LSTM. Information is passed between layers through hidden states, and Dropout (with a ratio of 0.2) is set between layers to prevent overfitting. (3) Backward LSTM layer: The structure is the same as the forward layer, with two stacked layers, each containing 128 hidden units. (In reverse chronological order...) arrive The input sequence is processed, and the gating mechanisms are calculated as follows (the subscript b indicates the back layer parameter): Forgotten Gate: , Input Gate: , Candidate cell status: , Cell status update: , Output gate: , Final backward hidden state (dimension 128): , Among them, the subscript b of the backward layer parameter (e.g. , The parameters of the feedforward layer are independent of those of the feedforward layer, and the dimensions of each weight matrix and bias vector are the same as those of the feedforward layer. (4) Feature fusion: Concatenate the forward and backward hidden states of each time step: ; (5) Fully connected layer: A fully connected layer with 256 neurons and the ReLU activation function are used to further extract features; (6) Output layer: Use the Sigmoid activation function to output the contamination probability. A value close to 1 indicates a pollution event, while a value close to 0 indicates a normal state. (7) Through continuous iteration, new hyperparameter combinations are continuously realized and corresponding surrogate models are built based on them. This optimization loop continues until the loss function meets the expected convergence criterion or reaches the maximum number of iterations. The loss function uses weighted binary cross-entropy: , in, The total number of test samples, For real labels, To predict probabilities, Class weights; to address the class imbalance problem, contamination class weights are used. Greater than the weight of non-polluting classes ,Right now To improve the model's sensitivity to detecting pollution events; (8) The combination of hyperparameters with the minimum loss function value in the proxy model is determined as the optimal combination, and the BiLSTM network model built based on this combination is determined as the optimal model.

[0016] Further, in step 4, real-time voltage data is input into the trained model and the contamination probability is output. A threshold is set (usually 0.5), and a probability higher than the threshold is considered a contamination event. The method for contamination detection using the trained model is as follows: (1) Collect real-time voltage data and perform the same preprocessing operations as in step 2, including normalization and filtering; (2) Input the preprocessed voltage time series data into the trained BiLSTM optimal model; (3) The model outputs the pollution probability value for the current time window. ; (4) Set pollution detection threshold (Usually a value of 0.5), when the predicted probability When it is determined that a pollution event exists at the current moment, It is judged to be in a normal state at this time.

[0017] Furthermore, the method also includes a model optimization step, specifically: periodically collecting new voltage data and incrementally training the model; updating the model if its performance improves. The model optimization method is as follows: (1) Regularly collect new voltage data and corresponding pollution event tags; (2) Preprocess the new data according to the method in step two; (3) Use new data to incrementally train or completely retrain the existing model and update the model parameters; (4) Evaluate the performance of the updated model on the validation set. If the performance is improved, replace the original model; otherwise, keep the original model. (5) Repeat the above process to enable the model to adapt to changes in environmental conditions such as different seasons, temperatures, and water quality, thereby improving the model's generalization ability and long-term stability.

[0018] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention can automatically learn the complex timing characteristics of SMFC voltage signals, enabling intelligent detection of heavy metal pollution events without manual intervention, thus significantly improving monitoring efficiency; 2. This invention employs a BiLSTM bidirectional structure to simultaneously capture forward and backward time dependencies, which significantly improves accuracy, precision, recall, and F1 score compared to a unidirectional LSTM model. 3. This invention can effectively distinguish between real pollution signals and environmental noise (such as voltage drift caused by temperature and precipitation), improves the robustness of detection in complex field environments, and reduces false positive alarms; 4. The present invention has verified the universality and adaptability of the model in three representative wetland environments with intertidal alkaline soil, acidic paddy soil and neutral paddy soil as sediments, and is applicable to water quality monitoring in different geographical environments. 5. This invention is based on a self-powered SMFC sensor, which does not require an external power source, making it suitable for long-term field deployment, reducing operating costs, and extending the service life of the monitoring system; 6. This invention can be integrated with wireless sensor networks (WSN) to achieve large-scale deployment and real-time data transmission, providing technical support for the development of intelligent environmental monitoring networks. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the SMFC sensor operating under field conditions in an embodiment of the present invention. The cathode floats on the water surface, the anode is buried in the sediment, and the voltage signal is transmitted to the data acquisition module through a wire.

[0020] Figure 2 The figures show the voltage response curves of the SMFC sensor for three different sediment types in this embodiment of the invention. (Cr was added.) 6 Before contamination, the voltage signal was relatively stable; after adding Cr... 6 After ⁺, the voltage signal rises rapidly, reaching its peak within 30 seconds, and then falls back to the baseline. The voltage increment varies with Cr. 6 The increase is due to the increase in ⁺ concentration.

[0021] Figure 3 This is a network architecture diagram of the BiLSTM contamination detection model in an embodiment of the present invention. It includes an input layer, two BiLSTM layers (forward LSTM + backward LSTM), a fully connected layer, and a Sigmoid output layer.

[0022] Figure 4 This is a flowchart illustrating the steps of an embodiment of the present invention.

[0023] Figure 5 This is a comparison of the training loss curves of the BiLSTM model and the conventional LSTM model in this embodiment of the invention. (a) shows the training loss curve of the BiLSTM model, and (b) shows the training loss curve of the LSTM model. Detailed Implementation

[0024] The preferred embodiments of the present invention will now be described in detail with reference to specific examples. It should be understood that the following examples are given for illustrative purposes only and are not intended to limit the scope of the invention. Those skilled in the art can make various modifications and substitutions to the present invention without departing from its spirit and essence.

[0025] Figure 1 This is a schematic diagram illustrating the operation of the sediment microbial fuel cell sensor under field conditions in an embodiment of the present invention. Figure 1 As shown, the SMFC sensor consists of an anode and a cathode. The anode is a stainless steel tube (4.5 cm in diameter × 11 cm in height) buried in the sediment; the cathode is a platinum mesh (4.5 cm in diameter) fixed on a piece of foam and floating on the water surface. The anode and cathode are connected by a 20 kΩ external resistor, and the voltage signal is transmitted to the data acquisition module through wires, recording voltage data at 3-second intervals.

[0026] In this embodiment of the invention, three sediment types—intertidal alkaline soil, acidic paddy soil, and neutral paddy soil—were sampled from Yancheng (YC), Yingtan (YT), and Nanjing (NJ), respectively. Each sampling point was taken from three 0.25 m... 2Soil samples were collected from plots at a depth of 0–20 cm, with a spacing of approximately 10 m between plots. After sealing, the soil samples were transported to the laboratory within 8 hours. Plant debris, roots, and stones were manually removed, and the samples were homogenized through a 3 mm sieve and divided into three portions. Each portion weighed 14 kg and was placed in a PE container (25 cm in diameter × 12 cm in height). Seawater was filled into the YC soil container, while tap water was filled into the YT and NJ soil containers to simulate different wetland environments.

[0027] Figure 2 The images show the SMFC sensor voltage response curves for three different sediment types (YC, YT, and NJ) in this embodiment of the invention. The experiments used eight concentration gradients (5, 10, 20, 40, 80, 120, 160, 200 mg / L Cr). 6+ A K₂CrO₄ solution was used to simulate a heavy metal pollution event. 100 mL of solution was poured onto the cathode surface each time, added in ascending order of concentration, with a one-hour interval between adjacent additions. The daily impact experiments were conducted from 9:00 AM to 4:00 PM. All experiments were repeated three times to minimize error. Figure 2 As shown, add Cr 6+ Before contamination, the voltage signal was relatively stable; after adding Cr... 6+ Afterward, the voltage signal rises rapidly, reaching its peak within 30 seconds, and then drops back to the baseline voltage. The voltage increment varies with Cr. 6+ The increase is due to the increase in concentration.

[0028] In this embodiment of the invention, the BiLSTM-based method for automatic detection of heavy metal pollution using SMFC sensors requires multiple steps. For example... Figure 4 As shown, the specific implementation process of the BiLSTM-based automatic detection method for heavy metal pollution includes the following steps: Step 1: Deploy SMFC sensors in different wetland environments to collect voltage data. SMFC sensors were deployed in three representative wetland environments with intertidal alkaline soil, acidic paddy soil, and neutral paddy soil as sediments. Voltage data was recorded in real-time at 3-second intervals using a data acquisition module. Cr was simulated using K₂CrO₄ solutions of different concentrations. 6+ For pollution events, build a dataset that includes both polluted and unpolluted states.

[0029] Step 2: Data Preprocessing The following preprocessing operations were performed on the acquired voltage time series data: (2.1) Missing value imputation: For missing data points in the voltage sequence, forward imputation and backward imputation methods are used to maintain data continuity and avoid model training errors caused by missing data.

[0030] (2.2) Data Normalization: Min-Max normalization is performed on each voltage channel to scale the data to the [0,1] interval, ensuring that all channels have comparable numerical ranges and reducing bias caused by different magnitudes. The normalization formula is: .

[0031] (2.3) Moving average filtering: Applying a moving average filter smooths voltage fluctuations, reduces high-frequency noise, and helps the model better capture significant voltage changes caused by pollution events.

[0032] (2.4) Pollution event labeling: Label each time point in the dataset. Label 1 indicates that there is pollution at that time point, and label 0 indicates that there is no pollution.

[0033] (2.5) Time Series Sample Construction: The sliding window method is used to convert continuous voltage time series data into fixed-length training samples. The sliding window length is set to L=200, meaning each sample contains voltage data from 200 consecutive time points. The sliding step size is set to S. Starting from the beginning of the time series, the sliding window moves forward by S time points each time, extracting a voltage sequence segment of length L as a sample. For each sample, its label is determined by the annotation information within the window: if there is a time point with label 1 within the window, the sample is labeled 1 (contamination event); otherwise, the label is 0 (normal state). The sliding process is repeated until the entire time series is covered, finally obtaining the sample set. ,in Let L be the voltage sequence matrix of the i-th sample, L be the time step, and D be the feature dimension. For the corresponding label, M is the total number of samples.

[0034] (2.6) Class balancing: Since the number of pollution event samples is significantly less than the number of normal state samples, the synthetic minority oversampling technique (SMOTE) is used to oversample the minority class samples to generate synthetic samples to balance the training dataset.

[0035] (2.7) Dataset partitioning: The constructed sample set is divided into a training set and a test set in chronological order, with a partition ratio of 80:20, to ensure that samples of the same contamination event do not appear in both the training set and the test set at the same time, so as to avoid data leakage; the specific method is: the first 80% of the samples are used as the training set and the last 20% of the samples are used as the test set in chronological order, so as to maintain the continuity of the time series and the temporal characteristics of the real scene.

[0036] Step 3: Construct and train the BiLSTM neural network model Training a BiLSTM model involves the following steps: (3.1) Input layer: Receives preprocessed voltage time series data ,in For time step.

[0037] (3.2) Forward LSTM layer: Forward LSTM layers: 2 stacked layers, each with 128 hidden units. (In chronological order from...) arrive Processing the input sequence. Each LSTM unit contains four gating mechanisms: forget gate, input gate, cell state update gate, and output gate, which operate at time steps. The calculation process is as follows: Forget gate (controls the proportion of the cell state retained from the previous moment):

[0038] Input gate (controls the amount of new information written):

[0039] Candidate cell states (generating new information to be written):

[0040] Cell state update (merging forgotten old information with written new information):

[0041] Output gate (controls the hidden state of the output):

[0042] Final forward hidden state (dimension 128):

[0043] in, It is the Sigmoid activation function. This is element-wise multiplication; and These are the input weight matrix (dimension 128×1) and the cyclic weight matrix (dimension 128×128) for each gate. This is the corresponding bias vector. The gating calculation described above is performed independently in each layer (two layers in total) of the forward and backward LSTM. Information is passed between layers through hidden states, and Dropout (with a ratio of 0.2) is set between layers to prevent overfitting.

[0044] (3.3) Backward LSTM layer: The structure is the same as the forward layer, consisting of two stacked layers, each with 128 hidden units. (The last part is a repetition of the previous sentence and can be omitted.) arrive The input sequence is processed, and the gating mechanisms are calculated as follows (the subscript b indicates the back layer parameter): Forgotten Gate:

[0045] Input Gate:

[0046] Candidate cell status:

[0047] Cell status update:

[0048] Output gate:

[0049] Final backward hidden state (dimension 128):

[0050] Among them, the subscript b of the backward layer parameter (e.g. , The parameters of the feedforward layer are independent of those of the feedforward layer, and the dimensions of each weight matrix and bias vector are the same as those of the feedforward layer.

[0051] (3.4) Feature fusion: Concatenate the forward and backward hidden states of each time step: .

[0052] (3.5) Fully connected layer: The fused feature representation is input into a fully connected layer with an input dimension of 256 (128 dimensions concatenated from the forward and backward layers), resulting in an output of 256 neurons. A non-linear transformation is performed using the ReLU activation function. ,in The dimension is 256×256, and the output feature dimension is 256, further extracting high-level semantic features related to pollution detection.

[0053] (3.6) Output layer: The feature vector output by the fully connected layer. (Dimension 256) is mapped to a scalar through a linear transformation, and then the contamination probability at the current time step is output through the Sigmoid activation function:

[0054] in, Its dimension is 1×256. For scalar bias, This is the Sigmoid activation function. Output. This represents the probability of contamination at the current time step, where a value close to 1 indicates a contamination event and a value close to 0 indicates a normal state.

[0055] (3.7) Through continuous iteration, new combinations of hyperparameters are continuously implemented and corresponding surrogate models are built based on them. This optimization loop continues until the loss function meets the expected convergence criterion or reaches the maximum number of iterations; the loss function adopts weighted binary cross-entropy:

[0056] in, The total number of test samples, For real labels, To predict probabilities, Class weights; to address the class imbalance problem, contamination class weights are used. Greater than the weight of non-polluting classes ,Right now This is to improve the model's sensitivity in detecting pollution events.

[0057] (3.8) The combination of hyperparameters with the minimum loss function value in the surrogate model is determined as the optimal combination, and the BiLSTM network model built based on this combination is determined as the optimal model.

[0058] Figure 5 This illustrates a comparison of the training loss curves between the BiLSTM model and the conventional LSTM model in an embodiment of the present invention. Figure 5 As shown, (a) is the training loss curve of the BiLSTM model, and (b) is the training loss curve of the LSTM model. The comparison results show that the BiLSTM model has a faster training loss convergence speed and a lower final loss value, indicating that the bidirectional structure can more effectively learn the contamination features in voltage time series and has stronger fitting ability and generalization performance.

[0059] Step 4: Real-time pollution event detection The real-time pollution detection process includes: (4.1) Collect real-time voltage data and perform preprocessing (normalization, filtering, etc.).

[0060] (4.2) Input the preprocessed data into the trained BiLSTM model.

[0061] (4.3) The model outputs the pollution probability value at the current time. .

[0062] (4.4) Set pollution detection threshold (Usually a value of 0.5), when the predicted probability When it is determined that a pollution event exists at the current moment, It is judged to be in a normal state at this time.

[0063] Step 5: Continuous Model Optimization (5.1) Regularly collect new voltage data and corresponding pollution event labels.

[0064] (5.2) Preprocess the new data according to the method in step two.

[0065] (5.3) Use new data to incrementally train or completely retrain the existing model and update the model parameters.

[0066] (5.4) Evaluate the performance of the updated model on the validation set. If the performance is improved, replace the original model; otherwise, keep the original model.

[0067] (5.5) Repeat the above process to enable the model to adapt to changes in environmental conditions such as different seasons, temperatures, and water quality, thereby improving the model's generalization ability and long-term stability.

Claims

1. An automatic detection method for heavy metal pollution in sediment microbial fuel cells based on a bidirectional long short-term memory neural network, characterized in that, Includes the following steps: Step 1: Construct and deploy SMFC sensors in different wetland environments and collect voltage data in real time; Step 2 involves preprocessing the acquired real-time voltage data, including missing value imputation, data normalization, moving average filtering for noise reduction, contamination event labeling, time series sample construction, class balancing, and dataset partitioning. Step 3: Construct a bidirectional long short-term memory neural network model, which includes two bidirectional LSTM layers, a fully connected layer, and a sigmoid output layer. Train the model using a weighted binary cross-entropy loss function. Step 4: Input real-time voltage data into the trained bidirectional long short-term memory neural network model, output the contamination probability and determine the contamination event.

2. The method according to claim 1, characterized in that, In step 1, the method for constructing and deploying the SMFC sensor is as follows: a stainless steel tube is used as the anode and a platinum mesh is used as the cathode. The anode and cathode are connected by an external resistor. The anode is buried in the sediment and the cathode floats on the water surface. A data acquisition module is used to collect voltage data in real time to simulate heavy metal pollution events of different concentrations to construct a training dataset.

3. The method according to claim 2, characterized in that, In step 1, alkaline intertidal soil, acidic paddy soil, and neutral paddy soil were used as representative wetland environments, and K2CrO4 solution was used to simulate Cr. 6+ Pollution impact experiments were conducted during the pollution incident to obtain real-time voltage data.

4. The method according to claim 1, characterized in that, In step 2, the data preprocessing process is as follows: missing values ​​are filled using forward and backward methods to maintain data continuity; each voltage channel is normalized using Min-Max; a moving average filter is used to smooth voltage fluctuations and reduce high-frequency noise; pollution event time points are labeled; time series samples are constructed according to a sliding window; the SMOTE technique is used to handle class imbalance; and the time series samples are divided into training and test sets.

5. The method according to claim 1, characterized in that, In step 3, the bidirectional long short-term memory neural network model includes: the input layer receiving the preprocessed voltage time series; the forward LSTM layer processing the sequence from front to back; the backward LSTM layer processing the sequence from back to front; the forward and backward hidden states being concatenated at each time step; and features being extracted through a fully connected layer of 256 neurons and the ReLU activation function. Use the Sigmoid activation function to output the contamination probability.

6. The method according to claim 1, characterized in that, In step 4, real-time voltage data is input into the trained model and the pollution probability is output. A threshold is set, and a probability higher than the threshold is judged as a pollution event.

7. The method according to claim 1, characterized in that, It also includes steps for model optimization, specifically: periodically collecting new voltage data and incrementally training the model, and updating the model if the model performance improves.