Water quality parameter trend prediction method and system based on full spectrum and attention mechanism

By employing a full-spectrum and attention mechanism-based water quality parameter trend prediction method, this approach utilizes convolutional neural networks and long short-term memory networks to extract water quality spectral features. Combined with a multi-scale attention mechanism, it addresses the issues of spatiotemporal continuity and early warning adaptability in water quality monitoring, achieving high-precision water quality parameter trend prediction and real-time early warning.

CN120910619APending Publication Date: 2025-11-07BO RUI SI SHU ZHI KE JI (SHEN ZHEN) YOU XIAN GONG SI
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511026167.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-24
Publication Date
2025-11-07

AI Technical Summary

Technical Problem

Existing water quality monitoring technologies cannot reflect the continuous spatiotemporal evolution of pollutant concentrations in water bodies. Spectral feature extraction suffers from noise interference and redundant feature information. Early warning models lack adaptability, making it difficult to achieve real-time and accurate prediction and early warning of water quality parameter trends.

Method used

A water quality parameter trend prediction method using full spectrum and attention mechanism is adopted. By acquiring historical full spectrum absorption data of water bodies, spectral features are extracted using convolutional neural networks and long short-term memory networks, and weighted by multi-scale attention mechanism to train the water quality parameter trend prediction model, and the predicted values ​​and alarm signals are output in real time.

Benefits of technology

It improves the accuracy of water quality parameter trend prediction and real-time early warning capabilities, accurately captures abrupt changes in the migration and transformation of pollutants, reduces false alarm rates, and achieves highly sensitive detection and rapid response to water quality anomalies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120910619A_ABST
    Figure CN120910619A_ABST
Patent Text Reader

Abstract

The invention discloses a water quality parameter trend prediction method and system based on a full spectrum and an attention mechanism, and belongs to the technical field of water quality detection. Historical water body full-spectrum absorption data are obtained, time sequence information of the water body full-spectrum absorption data is fully utilized, historical full-spectrum dynamic fusion is carried out, the trend perception and prediction precision of the finally trained water quality parameter trend prediction model is improved, and meanwhile, the prediction accuracy of the water quality parameter trend prediction model is improved. In the model training process, a convolutional neural network and a long-short-term memory network are selected for model building, and local wavelength features and global time sequence features are considered, so that prediction is more accurate. In addition, an attention enhancement mechanism is introduced, so that the attention of the water quality parameter trend prediction model on key wavelengths and key time slices is improved, and the water quality abnormity detection and real-time early warning capability is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of water quality monitoring, and particularly relates to a water quality parameter trend prediction method and system based on full spectrum and attention mechanism. BACKGROUND

[0002] With the deepening of ecological civilization construction and the continuous upgrading of water environment supervision requirements, the real-time, accuracy and forward-looking of water quality monitoring are put forward higher requirements in the scenes of sewage treatment plant operation efficiency evaluation, river pollution discharge port dynamic supervision, etc.

[0003] At present, the traditional water quality monitoring technology mainly relies on single-point discrete sampling data, and obtains instantaneous index values through laboratory analysis or online sensors. However, this "point-to-area" monitoring mode has significant limitations: in the time and space dimensions, single-point data cannot reflect the time and space continuous evolution law of pollutant concentration in water body, especially for dynamic water body affected by hydrological conditions and pollution source emission fluctuation, the time series modeling capability is insufficient to capture the mutation characteristics and cumulative effect in the process of pollutant migration and transformation; in the aspect of spectral feature extraction, the existing technology mainly adopts full-band analysis or empirical band selection, and does not establish an automatic identification mechanism based on pollutant spectral fingerprint characteristics, resulting in significant noise band interference and high feature information redundancy, especially in the low-concentration pollutant detection scene, the effective signal is easy to be overwhelmed by background noise; in the aspect of early warning model construction, the fixed threshold setting mechanism lacks adaptability to the dynamic change of water body baseline concentration, and it is difficult to distinguish between natural fluctuation and abnormal emission, resulting in high false alarm rate, and the early warning response has a time lag of 15-30 minutes, and the model has a significant decline in generalization ability when migrating across regions and seasons.

[0004] Therefore, how to provide a water quality parameter trend prediction method and system based on full spectrum and attention mechanism, which can integrate spectral spatio-temporal information, improve water quality parameter trend prediction accuracy and have real-time early warning function, has become a problem to be solved. SUMMARY

[0005] The purpose of the present application is to provide a water quality parameter trend prediction method based on full spectrum and attention mechanism to solve the above problems existing in the prior art.

[0006] In order to achieve the above purpose, the present application adopts the following technical scheme:

[0007] In a first aspect, the present application provides a water quality parameter trend prediction method based on full spectrum and attention mechanism, which comprises:

[0008] The historical water full-spectrum absorption data is acquired to form a historical time-series spectrum matrix, and the historical time-series spectrum matrix is taken as an input quantity to input a convolutional neural network to extract local band features to obtain a historical spectrum feature vector sequence;

[0009] The historical spectrum feature vector sequence is input into a long short-term memory network to extract time-series features to obtain a historical space-time spectrum feature vector sequence, and a multi-scale attention mechanism is used to perform attention weighting on the historical time-series spectrum feature vector sequence according to different scales to generate a historical weighted space-time spectrum feature vector;

[0010] The historical weighted space-time spectrum feature vector is input into a full connection layer, and a water quality parameter concentration prediction value is taken as an output quantity to train a water quality parameter trend prediction model;

[0011] Real-time water full-spectrum absorption data is acquired, the real-time water full-spectrum absorption data is input into the water quality parameter trend prediction model, and a real-time water quality parameter concentration prediction value is output;

[0012] A plurality of preset concentration level thresholds are acquired, the real-time water quality parameter concentration prediction value is compared with each of the preset concentration level thresholds, and when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold, an alarm signal of a corresponding level is sent.

[0013] In a possible design, historical water full-spectrum absorption data is acquired to form a historical time-series spectrum matrix, including:

[0014] A preset sampling period is acquired, and water full-spectrum collection is performed on a target water body according to the preset sampling period to obtain historical full-spectrum absorbance data, wherein the historical full-spectrum absorbance data includes wavelength point sampling data of 325 wavelength points, and each wavelength point is distributed in a wavelength range of 200-1000 nm;

[0015] A plurality of historical full-spectrum absorbance data sampled at preset sampling periods are acquired, the historical full-spectrum absorbance data is subjected to smoothing and denoising, baseline correction, and normalization processing, and a historical time-series spectrum matrix is constructed by using the processed historical full-spectrum absorbance data, wherein each row in the historical time-series spectrum matrix corresponds to a sampling period, and each column in the time-series spectrum matrix corresponds to wavelength point sampling data of a wavelength point at different sampling periods;

[0016] Correspondingly, the historical time-series spectrum matrix is taken as an input quantity to input a convolutional neural network to extract local band features to obtain a historical spectrum feature vector sequence, and the historical spectrum feature vector sequence includes:

[0017] inputting the historical time-series spectral matrix into a one-dimensional convolutional neural network, and sliding a convolution kernel in a wavelength dimension to generate a multi-channel spectral feature map by using each convolution kernel in the one-dimensional convolutional neural network;

[0018] performing batch normalization processing on the multi-channel spectral feature map to obtain a historical spectral feature vector;

[0019] sequentially sorting and reorganizing the historical spectral feature vectors to obtain a historical spectral feature vector sequence.

[0020] In a possible design, the historical spectral feature vector sequence is input into a long short-term memory network to extract time-series features and obtain a historical spatio-temporal spectral feature vector, including:

[0021] inputting the historical spectral feature vector sequence into the long short-term memory network, and simultaneously learning long short-term time-series dependencies in a forward time sequence and a reverse time sequence, and outputting a forward hidden state and a reverse hidden state for the historical spectral feature vector sequence;

[0022] concatenating the forward hidden state and the reverse hidden state to form a global time-series feature, and taking the global time-series feature as a historical spatio-temporal spectral feature vector sequence;

[0023] Correspondingly, using a multi-scale attention mechanism to perform attention weighting on the historical spatio-temporal spectral feature vector sequence in different scales to generate a historical weighted spatio-temporal spectral feature vector sequence, including:

[0024] obtaining a preset time scale, and dividing the historical spatio-temporal spectral feature vector sequence according to the preset time scale to generate a short-time-scale historical spatio-temporal spectral feature vector branch, a medium-time-scale historical spatio-temporal spectral feature vector branch, and a long-time-scale historical spatio-temporal spectral feature vector branch, wherein the preset time scale includes a short-time scale, a medium-time scale, and a long-time scale;

[0025] using a multi-scale attention mechanism to calculate corresponding attention weights for the short-time-scale historical spatio-temporal spectral feature vector branch, the medium-time-scale historical spatio-temporal spectral feature vector branch, and the long-time-scale historical spatio-temporal spectral feature vector branch, respectively;

[0026] performing weighted processing on the short-time-scale historical spatio-temporal spectral feature vector branch, the medium-time-scale historical spatio-temporal spectral feature vector branch, and the long-time-scale historical spatio-temporal spectral feature vector branch by using the attention weights to obtain a short-time-scale historical weighted spatio-temporal spectral feature vector branch, a medium-time-scale historical weighted spatio-temporal spectral feature vector branch, and a long-time-scale historical weighted spatio-temporal spectral feature vector branch;

[0027] The short-time scale history weighted spatio-temporal spectral feature vector branch, the medium-time scale history weighted spatio-temporal spectral feature vector branch and the long-time scale history weighted spatio-temporal spectral feature vector branch are concatenated to form a history weighted spatio-temporal spectral feature vector.

[0028] In a possible design, the fully connected layer includes a first fully connected layer and a second fully connected layer.

[0029] Correspondingly, the history weighted spatio-temporal spectral feature vector is input into the fully connected layer, and a water quality parameter concentration prediction value is taken as an output quantity, so as to train a water quality parameter trend prediction model, and the water quality parameter trend prediction model includes the following steps:

[0030] The history weighted spatio-temporal spectral feature vector is input into the first fully connected layer, and dimension compression processing is performed on the history weighted spatio-temporal spectral feature vector in the first fully connected layer to obtain a compressed weighted spatio-temporal spectral feature vector.

[0031] The compressed weighted spatio-temporal spectral feature vector is input into the second fully connected layer, and feature mapping is performed on the compressed weighted spatio-temporal spectral feature vector in the second fully connected layer to obtain a water quality parameter concentration prediction value, so as to complete training of the water quality parameter trend prediction model.

[0032] In a possible design, real-time water body full-spectrum absorption data is acquired, the real-time water body full-spectrum absorption data is input into the water quality parameter trend prediction model, and a real-time water quality parameter concentration prediction value is output, and the method includes the following steps:

[0033] The real-time water body full-spectrum absorption data is acquired, and the real-time water body full-spectrum absorption data includes water body full-spectrum absorption data at a current time and water body full-spectrum absorption data in the past 23 hours.

[0034] The real-time water body full-spectrum absorption data is preprocessed and integrated into a real-time time-series spectral matrix.

[0035] The real-time time-series spectral matrix is input into the water quality parameter trend prediction model for calculation to obtain a real-time water quality parameter concentration prediction value output by the water quality parameter trend prediction model, and the real-time water quality parameter concentration prediction value includes at least three prediction values, and each prediction value corresponds to a water quality parameter concentration prediction value in the future for at least three hours.

[0036] In a possible design, a plurality of preset concentration level thresholds are acquired, the real-time water quality parameter concentration prediction value is compared with each preset concentration level threshold, and when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold, an alarm signal of a corresponding level is sent, and the method includes the following steps:

[0037] obtaining a plurality of preset concentration level thresholds, wherein the preset concentration level thresholds comprise a first-level concentration threshold, a second-level concentration threshold and a third-level concentration threshold, and the first-level concentration threshold, the second-level concentration threshold and the third-level concentration threshold are arranged in ascending order of numerical value;

[0038] comparing each of the prediction values in the real-time water quality parameter concentration prediction values with the first-level concentration threshold, the second-level concentration threshold and the third-level concentration threshold respectively to obtain a concentration comparison result;

[0039] if each of the prediction values does not exceed the first-level concentration threshold, visualizing each of the prediction values and the corresponding time, and not issuing an alarm signal;

[0040] if a prediction value that exceeds the first-level concentration threshold and does not exceed the second-level concentration threshold appears in each of the prediction values, visualizing the prediction value and the corresponding time, and issuing a first-level alarm signal;

[0041] if a prediction value that exceeds the second-level concentration threshold and does not exceed the third-level concentration threshold appears in each of the prediction values, visualizing the prediction value and the corresponding time, and issuing a second-level alarm signal;

[0042] if a prediction value that exceeds the third-level concentration threshold appears in each of the prediction values, visualizing the prediction value and the corresponding time, and issuing a third-level alarm signal.

[0043] In a possible design, the water quality parameter corresponding to the water quality parameter concentration prediction value comprises at least one of water quality chemical oxygen demand, water quality total nitrogen content, water quality ammonia nitrogen content, water quality total phosphorus content and water quality turbidity.

[0044] In a second aspect, the present application provides a water quality parameter trend prediction system based on full spectrum and attention mechanism, which is used for the water quality parameter trend prediction method based on full spectrum and attention mechanism as described in the first aspect or any possible design of the first aspect, and comprises:

[0045] a historical data acquisition unit configured to obtain historical water body full spectrum absorption data to form a historical time series spectrum matrix;

[0046] The composite model training unit is configured to input the historical time-series spectral matrix as an input quantity into a convolutional neural network to extract local band features, so as to obtain a historical spectral feature vector sequence; then input the historical spectral feature vector sequence into a long short-term memory network to extract time-series features, so as to obtain a historical space-time spectral feature vector sequence, and utilize a multi-scale attention mechanism to perform attention weighting on the historical time-series spectral feature vector sequence according to different scales, so as to generate a historical weighted space-time spectral feature vector; and the composite model training unit is further configured to input the historical weighted space-time spectral feature vector into a fully connected layer, and take a water quality parameter concentration prediction value as an output quantity, so as to train a water quality parameter trend prediction model.

[0047] The real-time data processing unit is configured to acquire real-time water body full-spectrum absorption data, input the real-time water body full-spectrum absorption data into the water quality parameter trend prediction model, and output a real-time water quality parameter concentration prediction value.

[0048] The automatic alarm triggering unit is configured to acquire a plurality of preset concentration level thresholds, compare the real-time water quality parameter concentration prediction value with each preset concentration level threshold, and send an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold.

[0049] In a third aspect, the present application provides an electronic device, comprising a memory, a processor and a transceiver connected in sequence and in communication, wherein the memory is configured to store a computer program, the transceiver is configured to receive and send messages, and the processor is configured to read the computer program and execute the water quality parameter trend prediction method based on full spectrum and attention mechanism according to the first aspect or any possible design of the first aspect.

[0050] In a fourth aspect, the present application provides a computer readable storage medium, wherein the computer readable storage medium stores instructions, and when the instructions are run on a computer, the water quality parameter trend prediction method based on full spectrum and attention mechanism according to the first aspect or any possible design of the first aspect is executed.

[0051] In a fifth aspect, the present application provides a computer program product comprising instructions, and when the instructions are run on a computer, the computer is caused to execute the water quality parameter trend prediction method based on full spectrum and attention mechanism according to the first aspect or any possible design of the first aspect.

[0052] Beneficial effects: The application provides a water quality parameter trend prediction method and system based on full spectrum and attention mechanism, wherein: first, historical water body full spectrum absorption data is acquired to form a historical time series spectrum matrix, and the historical time series spectrum matrix is taken as an input quantity to input a convolutional neural network for local waveband feature extraction to obtain a historical spectrum feature vector sequence; second, the historical spectrum feature vector sequence is input into a long short-term memory network to extract time series features to obtain a historical spatiotemporal spectrum feature vector sequence, and a multi-scale attention mechanism is used to perform attention weighting on the historical time series spectrum feature vector sequence according to different scales to generate a historical weighted spatiotemporal spectrum feature vector; then, the historical weighted spatiotemporal spectrum feature vector is input into a full connection layer, and a water quality parameter concentration prediction value is taken as an output quantity to train a water quality parameter trend prediction model; real-time water body full spectrum absorption data is acquired to input the real-time water body full spectrum absorption data into the water quality parameter trend prediction model, and output a real-time water quality parameter concentration prediction value; finally, a plurality of preset concentration level thresholds are acquired, the real-time water quality parameter concentration prediction value is compared with each preset concentration level threshold, and when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold, an alarm signal of the corresponding level is sent. By acquiring historical water body full spectrum absorption data and fully utilizing the time series information of the water body full spectrum absorption data, not only historical full spectrum dynamic fusion is performed, but also the trend perception and prediction accuracy of the finally trained water quality parameter trend prediction model are improved, and the convolutional neural network and the long short-term memory network are selected for model building in the process of training the model, so that the local wavelength features and the global time series features are considered, and the prediction is more accurate. In addition, an attention enhancement mechanism is introduced to improve the attention of the water quality parameter trend prediction model to the key wavelengths and the key time slices, and the water quality anomaly detection and real-time early warning capability are improved. BRIEF DESCRIPTION OF DRAWINGS

[0053] Figure 1 A flowchart of a water quality parameter trend prediction method based on full spectrum and attention mechanism is provided for the embodiments of the application.

[0054] Figure 2 A network connection structure diagram of a water quality parameter trend prediction model is provided for the embodiments of the application.

[0055] Figure 3 A functional structure diagram of a water quality parameter trend prediction system based on full spectrum and attention mechanism is provided for the embodiments of the application.

[0056] Figure 4 A structure diagram of an electronic device is provided for the embodiments of the application. DETAILED DESCRIPTION

[0057] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the present application will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the drawings is only some embodiments of the present application, and for those skilled in the art, other drawings can also be obtained without creative labor on the basis of these drawings. It should be noted that the description of these embodiments is used to help understand the present application, but does not constitute a limitation on the present application.

[0058] It should be understood that although the terms first, second, etc. may be used herein to describe various elements, these elements should not be limited by these terms. These terms are only used to distinguish one element from another. For example, a first element can be called a second element, and similarly, a second element can be called a first element without departing from the scope of the example embodiments of the present application.

[0059] It should be understood that for the term "and / or" that may appear herein, it is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which means that there are three cases of A alone, B alone, and A and B together; for the term " / and" that may appear herein, it is another description of the association relationship of another associated object, which means that there can be two relationships, for example, A / and B, which means that there are two cases of A alone and A and B together; in addition, for the character " / " that may appear herein, it generally means that the associated objects before and after are an "or" relationship.

[0060] Embodiments:

[0061] As shown in Figure 1 The first aspect of the present embodiment provides a water quality parameter trend prediction method based on full spectrum and attention mechanism, which can include but is not limited to the following steps:

[0062] S1. Obtain historical water full spectrum absorption data to form a historical time series spectrum matrix, and input the historical time series spectrum matrix as an input quantity into a convolutional neural network for local band feature extraction to obtain a historical spectrum feature vector sequence;

[0063] In one possible implementation, in step S1, the historical water full spectrum absorption data is obtained to form a historical time series spectrum matrix, which can be but not limited to decomposed into steps S11-S12, including:

[0064] S11. Obtain a preset sampling period, and collect water body full spectrum of the target water body according to the preset sampling period to obtain historical full spectrum absorbance data, wherein the historical full spectrum absorbance data includes wavelength point sampling data of 325 wavelength points, and each wavelength point is distributed in a wavelength range of 200-1000 nm;

[0065] S12. Obtain historical full spectrum absorbance data sampled in multiple preset sampling periods, perform smoothing denoising and baseline correction on the historical full spectrum absorbance data, and complete normalization processing, so as to construct a historical time series spectrum matrix by using the processed historical full spectrum absorbance data, wherein each row in the historical time series spectrum matrix corresponds to a sampling period, and each column in the time series spectrum matrix corresponds to wavelength point sampling data of a wavelength point in different sampling periods;

[0066] Correspondingly, in step S1, the historical time series spectrum matrix is taken as an input quantity, and is input into a convolutional neural network to extract local band features, so as to obtain a historical spectrum feature vector sequence, which can be but is not limited to decomposed into steps S13-S15, including:

[0067] S13. Input the historical time series spectrum matrix into a one-dimensional convolutional neural network, and slide a convolution kernel according to a wavelength dimension, so as to generate a multi-channel spectrum feature map by using each convolution kernel in the one-dimensional convolutional neural network;

[0068] S14. Perform batch normalization processing on the multi-channel spectrum feature map to obtain a historical spectrum feature vector;

[0069] S15. Sort and recombine the historical spectrum feature vectors in time sequence to obtain a historical spectrum feature vector sequence.

[0070] In a specific application, the historical water body full spectrum absorbance data can be obtained by using a full spectrum water quality sensor to periodically sample at 1 h / time (preset sampling period) to collect absorbance data of the target water body in the ultraviolet-visible-near infrared range (200-1000 nm), and there are 325 wavelength points in this range, and a wavelength point sampling data is formed at each wavelength point; at least 24 hours of data (to ensure sufficient training samples) are obtained, and 24 groups of historical full spectrum absorbance data are subjected to Savitzky-Golay smoothing, polynomial baseline correction and normalization processing, so as to obtain a historical time series spectrum matrix of 24 rows and 325 columns.

[0071] Preferably, the one-dimensional convolutional neural network used in this embodiment introduces a multi-resolution convolutional layer to perform detailed analysis on the historical time-series spectral matrix, so as to obtain more wavelength features (local spatial features) for different wavelength bands (each wavelength band includes multiple wavelength points), making the feature information richer and improving the accuracy of model prediction.

[0072] S2. Input the historical spectral feature vector sequence into a long short-term memory network to extract temporal features, obtain a historical spatiotemporal spectral feature vector sequence, and use a multi-scale attention mechanism to perform attention weighting on the historical temporal spectral feature vector sequence according to different scales to generate a historical weighted spatiotemporal spectral feature vector.

[0073] like Figure 2 As shown, the water quality parameter trend prediction model provided in this embodiment, in order to fully integrate spectral spatiotemporal features and improve the model's prediction accuracy, employs a composite neural network model, including: a one-dimensional convolutional neural network, a long short-term memory network, a multi-scale attention network, and a fully connected network. Specifically: Figure 2 In this model, `Inputs` represents the input layer of the water quality parameter trend prediction model, using historical spectral feature vector sequences as input. `1D-Conv` represents a one-dimensional convolutional neural network used to extract local band features from the historical spectral feature vector sequences (i.e., extracting corresponding features for different wavelength bands) and outputting a historical spectral feature vector sequence. `LSTM` represents a long short-term memory network used to extract temporal features from the historical spectral feature vector sequences (i.e., capturing long- and short-term dependencies in the historical spectral feature vector sequences) and generate historical spatiotemporal spectral feature vectors (completing feature spatiotemporal fusion). `Atte`... `ntion` represents a multi-scale attention network, used to perform attention weighting on the historical spatiotemporal spectral feature vector sequence (i.e., to increase the attention to key wavelength points and key sampling times in the historical spatiotemporal spectral feature vector sequence), and generate a historical weighted spatiotemporal spectral feature vector sequence. `Dense` represents the fully connected layers (two layers) of the fully connected network, used for feature compression and feature mapping to generate predicted values ​​of water quality parameter concentrations. `Outputs` represents the output layer of the water quality parameter trend prediction model, used to output the generated predicted values ​​of water quality parameter concentrations (preferably three predicted values ​​in this embodiment).

[0074] In one possible implementation, step S2, inputting the historical spectral feature vector sequence into a long short-term memory network to extract temporal features and obtain historical spatiotemporal spectral feature vectors, can be decomposed, but is not limited to, the following steps S21-S22, including:

[0075] S21. inputting the historical spectrum feature vector sequence into a long short-term memory network, and simultaneously learning long short-term time sequence dependence in accordance with forward time sequence and reverse time sequence, and outputting forward hidden states and reverse hidden states for the historical spectrum feature vector sequence;

[0076] S22. splicing the forward hidden states and the reverse hidden states to form global time sequence features, and taking the global time sequence features as a historical spatiotemporal spectrum feature vector sequence;

[0077] Correspondingly, in step S2, the historical spatiotemporal spectrum feature vector sequence is attention weighted in accordance with different scales by using a multi-scale attention mechanism to generate a historical weighted spatiotemporal spectrum feature vector sequence, which can be but is not limited to decomposed into steps S23-S26, including:

[0078] S23. obtaining a preset time scale, and dividing the historical spatiotemporal spectrum feature vector sequence in accordance with the preset time scale to generate a short-time-scale historical spatiotemporal spectrum feature vector branch, a medium-time-scale historical spatiotemporal spectrum feature vector branch, and a long-time-scale historical spatiotemporal spectrum feature vector branch, wherein the preset time scale includes a short-time scale, a medium-time scale, and a long-time scale;

[0079] S24. calculating corresponding attention weights for the short-time-scale historical spatiotemporal spectrum feature vector branch, the medium-time-scale historical spatiotemporal spectrum feature vector branch, and the long-time-scale historical spatiotemporal spectrum feature vector branch by using a multi-scale attention mechanism;

[0080] S25. performing weighted processing on the short-time-scale historical spatiotemporal spectrum feature vector branch, the medium-time-scale historical spatiotemporal spectrum feature vector branch, and the long-time-scale historical spatiotemporal spectrum feature vector branch by using the attention weights to obtain a short-time-scale historical weighted spatiotemporal spectrum feature vector branch, a medium-time-scale historical weighted spatiotemporal spectrum feature vector branch, and a long-time-scale historical weighted spatiotemporal spectrum feature vector branch;

[0081] S26. performing feature splicing on the short-time-scale historical weighted spatiotemporal spectrum feature vector branch, the medium-time-scale historical weighted spatiotemporal spectrum feature vector branch, and the long-time-scale historical weighted spatiotemporal spectrum feature vector branch to form a historical weighted spatiotemporal spectrum feature vector.

[0082] It should be noted that the long short-term memory (LSTM) is a special recurrent neural network (RNN) designed to solve the gradient vanishing and gradient explosion problems faced by traditional RNN when processing long sequence data. It can effectively capture and utilize long-distance dependencies by introducing memory cells (Cell State) and gate mechanisms (Gate Mechanism). In the embodiment, the one-dimensional convolutional neural network history spectrum feature vector sequence is transmitted into the long short-term memory network for time series modeling. The long short-term memory network has memory capability, can capture the trend, periodicity or mutation mode of absorbance change over time, and its gate mechanism can effectively solve the long-term dependency problem, which is helpful to extract the potential time series pollutant fluctuation rule. In practical application, a multi-layer LSTM structure can be preferably used, and forward and reverse time series learning is introduced to learn long short-term time series dependencies, so as to improve the integrity of time series feature capture, generate more accurate historical spatio-temporal spectrum feature vector sequence, and improve the sensitivity of the trained water quality parameter trend prediction model to sudden pollution events.

[0083] Meanwhile, in the preferred use scenario, the multi-scale attention mechanism can separate the historical spatio-temporal spectrum feature vector sequence into short-time scale historical spatio-temporal spectrum feature vector branch (4-6h), medium-time scale historical spatio-temporal spectrum feature vector branch (12h) and long-time scale historical spatio-temporal spectrum feature vector branch (24h) according to the preset time scale, so as to ensure that the model can process different time scales by weighted fusion, reflect different periodic water quality changes, and improve the importance of key time features, so that the model can achieve more accurate trend prediction.

[0084] S3. inputting the historical weighted spatio-temporal spectrum feature vector into the full connection layer and taking the water quality parameter concentration prediction value as the output quantity to train the water quality parameter trend prediction model;

[0085] In a possible implementation, in step S3, the full connection layer includes a first full connection layer and a second full connection layer, and correspondingly, the historical weighted spatio-temporal spectrum feature vector is input into the full connection layer, and the water quality parameter concentration prediction value is taken as the output quantity to train the water quality parameter trend prediction model, which can be but not limited to decomposed into steps S31-S32, including:

[0086] S31. inputting the historical weighted spatio-temporal spectrum feature vector sequence into the first full connection layer and performing dimension compression processing on the historical weighted spatio-temporal spectrum feature vector in the first full connection layer to obtain a compressed weighted spatio-temporal spectrum feature vector;

[0087] S32. inputting the compressed weighted spatio-temporal spectral feature vector into the second fully connected layer and performing feature mapping on the compressed weighted spatio-temporal spectral feature vector in the second fully connected layer to obtain a water quality parameter concentration prediction value, thereby completing the training of the water quality parameter trend prediction model.

[0088] S4. obtaining real-time water body full spectrum absorption data, inputting the real-time water body full spectrum absorption data into the water quality parameter trend prediction model, and outputting a real-time water quality parameter concentration prediction value.

[0089] In a possible implementation, in step S4, obtaining real-time water body full spectrum absorption data, inputting the real-time water body full spectrum absorption data into the water quality parameter trend prediction model, and outputting a real-time water quality parameter concentration prediction value, can but not limited to be decomposed into steps S41-S43, comprising:

[0090] S41. obtaining real-time water body full spectrum absorption data, wherein the real-time water body full spectrum absorption data comprises water body full spectrum absorption data at a current time and water body full spectrum absorption data within the past twenty-three hours;

[0091] S42. preprocessing the real-time water body full spectrum absorption data and integrating the real-time water body full spectrum absorption data into a real-time time series spectral matrix;

[0092] S43. inputting the real-time time series spectral matrix into the water quality parameter trend prediction model for calculation to obtain a real-time water quality parameter concentration prediction value output by the water quality parameter trend prediction model, wherein the real-time water quality parameter concentration prediction value comprises at least three prediction values, and each prediction value corresponds to a water quality parameter concentration prediction value in the future for at least three hours.

[0093] S5. obtaining a plurality of preset concentration level thresholds, comparing the real-time water quality parameter concentration prediction value with each preset concentration level threshold, and issuing an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold.

[0094] In a possible implementation, in step S5, obtaining a plurality of preset concentration level thresholds, comparing the real-time water quality parameter concentration prediction value with each preset concentration level threshold, and issuing an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold, can but not limited to be decomposed into steps S51-S53, comprising:

[0095] S51. Obtain multiple preset concentration level thresholds, wherein the preset concentration level thresholds include a first-level concentration threshold, a second-level concentration threshold, and a third-level concentration threshold, and the first-level concentration threshold, the second-level concentration threshold, and the third-level concentration threshold are arranged in ascending order of value;

[0096] S52. Compare each predicted value in the real-time water quality parameter concentration prediction value with the first level concentration threshold, the second level concentration threshold and the third level concentration threshold respectively to obtain the concentration comparison result;

[0097] S53. If none of the predicted values ​​exceed the first-level concentration threshold, then the predicted values ​​and their corresponding times are visualized and displayed without issuing an alarm signal.

[0098] S54. If any of the predicted values ​​exceeds the first-level concentration threshold but does not exceed the second-level concentration threshold, then the predicted value and the corresponding time are visualized and a first-level alarm signal is issued.

[0099] S55. If any of the predicted values ​​exceeds the second-level concentration threshold but does not exceed the third-level concentration threshold, then the predicted value and the corresponding time are visualized and a second-level alarm signal is issued.

[0100] S56. If any of the predicted values ​​exceeds the third-level concentration threshold, the predicted value and the corresponding time are visualized and a third-level alarm signal is issued.

[0101] In one possible implementation, in specific applications, the water quality parameters corresponding to the predicted concentration values ​​of the water quality parameters to be generated should include at least one of the following: chemical oxygen demand, total nitrogen content, ammonia nitrogen content, total phosphorus content, and turbidity.

[0102] like Figure 3 As shown, the second aspect of this embodiment provides a hardware system for implementing the water quality parameter trend prediction method based on the full spectrum and attention mechanism described in the first aspect of the embodiment, including:

[0103] The historical data acquisition unit is used to acquire historical full-spectrum absorption data of water bodies and form a historical time-series spectral matrix;

[0104] The composite model training unit is configured to input the historical time-series spectral matrix as an input quantity into a convolutional neural network to extract local waveband features, so as to obtain a historical spectral feature vector sequence; then input the historical spectral feature vector sequence into a long short-term memory network to extract time-series features, so as to obtain a historical space-time spectral feature vector sequence, and utilize a multi-scale attention mechanism to perform attention weighting on the historical time-series spectral feature vector sequence according to different scales, to generate a historical weighted space-time spectral feature vector; and the composite model training unit is further configured to input the historical weighted space-time spectral feature vector into a fully connected layer, and take a water quality parameter concentration prediction value as an output quantity, to train a water quality parameter trend prediction model;

[0105] The real-time data processing unit is configured to acquire real-time water body full-spectrum absorption data, to input the real-time water body full-spectrum absorption data into the water quality parameter trend prediction model, and to output a real-time water quality parameter concentration prediction value.

[0106] The automatic alarm triggering unit is configured to acquire a plurality of preset concentration level thresholds, to compare the real-time water quality parameter concentration prediction value with each of the preset concentration level thresholds, and to issue an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold.

[0107] The working process, working details and technical effects of the system provided in this embodiment can be referred to the first aspect of the embodiment, and will not be repeated here.

[0108] As shown in Figure 4 The third aspect of the embodiment provides an electronic device, which comprises a memory, a processor and a transceiver connected in sequence, wherein the memory is configured to store a computer program, the transceiver is configured to transceive messages, and the processor is configured to read the computer program and execute the water quality parameter trend prediction method based on full-spectrum and attention mechanism as described in the first aspect of the embodiment.

[0109] Specifically, the memory can include, but is not limited to, random access memory (RAM), read only memory (ROM), flash memory, first input first output (FIFO) memory, first in last out (FILO) memory, and the like; specifically, the processor can include one or more processing cores, such as a 4-core processor, an 8-core processor, and the like. The processor can be implemented in at least one of the hardware forms of a DSP (Digital Signal Processing), an FPGA (Field-Programmable Gate Array), and a PLA (Programmable Logic Array), and the processor can also include a main processor and a coprocessor. The main processor is a processor for processing data in an awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in a standby state.

[0110] In some embodiments, the processor can be integrated with a GPU (Graphics Processing Unit) that is responsible for rendering and drawing the content required to be displayed on the display screen. For example, the processor can be, but is not limited to, a microprocessor of the STM32F105 series, a RISC (reduced instruction set computer) microprocessor, an X86 architecture processor, or a processor integrated with an embedded neural network processing unit (NPU). The transceiver can be, but is not limited to, a WIFI wireless transceiver, a Bluetooth wireless transceiver, a GPRS (General Packet Radio Service) wireless transceiver, a ZigBee wireless transceiver, a 3G transceiver, a 4G transceiver, and / or a 5G transceiver, and the like. In addition, the device can also include, but is not limited to, a power module, a display screen, and other necessary components.

[0111] The working process, working details, and technical effects of the electronic device provided in the embodiment can be referred to the first aspect of the embodiment, and will not be repeated here.

[0112] The fourth aspect of the embodiment provides a storage medium storing instructions of the water quality parameter trend prediction method based on full spectrum and attention mechanism in the first aspect of the embodiment, that is, the storage medium stores instructions, and when the instructions run on a computer, the water quality parameter trend prediction method based on full spectrum and attention mechanism in the first aspect of the embodiment is executed.

[0113] The storage medium refers to a carrier for storing data, which can include, but is not limited to, a floppy disk, an optical disk, a hard disk, a flash memory, a USB flash disk, a memory stick and the like, and the computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices.

[0114] The working process, working details and technical effects of the storage medium provided by the embodiment can be referred to the first aspect of the embodiment, and will not be described here.

[0115] The fifth aspect of the embodiment provides a computer program product containing instructions, which, when running on a computer, causes the computer to execute the water quality parameter trend prediction method based on full spectrum and attention mechanism in the first aspect of the embodiment, wherein the computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable devices.

[0116] Finally, it should be noted that: the above only describes the preferred embodiments of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A water quality parameter trend prediction method based on full spectrum and attention mechanism, characterized in that, The method comprises the following steps: obtaining historical water full-spectrum absorption data to form a historical time-series spectrum matrix, and inputting the historical time-series spectrum matrix as an input quantity into a convolutional neural network to extract local waveband features and obtain a historical spectrum feature vector sequence; inputting the historical spectrum feature vector sequence into a long short-term memory network to extract time-series features and obtain a historical spatio-temporal spectrum feature vector sequence, and using a multi-scale attention mechanism to perform attention weighting on the historical time-series spectrum feature vector sequence according to different scales to generate a historical weighted spatio-temporal spectrum feature vector; inputting the historical weighted spatio-temporal spectrum feature vector into a fully connected layer and taking a water quality parameter concentration prediction value as an output quantity to train a water quality parameter trend prediction model; obtaining real-time water full-spectrum absorption data, inputting the real-time water full-spectrum absorption data into the water quality parameter trend prediction model, and outputting a real-time water quality parameter concentration prediction value; obtaining a plurality of preset concentration level thresholds, comparing the real-time water quality parameter concentration prediction value with each of the preset concentration level thresholds, and outputting an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold.

2. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 1, characterized in that, The method for obtaining historical water full-spectrum absorption data to form a historical time-series spectrum matrix comprises the following steps: obtaining a preset sampling period and collecting water full-spectrum data of a target water body according to the preset sampling period to obtain historical full-spectrum absorbance data, wherein the historical full-spectrum absorbance data comprises wavelength point sampling data of 325 wavelength points, and each wavelength point is distributed in a wavelength range of 200-1000 nm; obtaining historical full-spectrum absorbance data sampled at a plurality of preset sampling periods, performing smoothing denoising, baseline correction and normalization processing on the historical full-spectrum absorbance data, and constructing a historical time-series spectrum matrix by using the processed historical full-spectrum absorbance data, wherein each row in the historical time-series spectrum matrix corresponds to a sampling period, and each column in the time-series spectrum matrix corresponds to wavelength point sampling data of a wavelength point at different sampling periods; correspondingly, the historical spectrum feature vector sequence obtained by inputting the historical time-series spectrum matrix as an input quantity into a convolutional neural network to extract local waveband features comprises the following steps: inputting the historical time-series spectrum matrix into a one-dimensional convolutional neural network and sliding a convolution kernel according to a wavelength dimension to generate a multi-channel spectrum feature map by using each convolution kernel in the one-dimensional convolutional neural network; performing batch normalization processing on the multi-channel spectrum feature map to obtain a historical spectrum feature vector; sequentially sorting and recombining the historical spectrum feature vector to obtain a historical spectrum feature vector sequence.

3. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 1, characterized in that, the historical spectrum feature vector sequence is input into a long short-term memory network to extract time-series features and obtain a historical spatio-temporal spectrum feature vector, which comprises the following steps: inputting the historical spectrum feature vector sequence into a long short-term memory network and simultaneously learning long short-term time-series dependencies according to a forward time sequence and a reverse time sequence, and outputting a forward hidden state and a reverse hidden state of the historical spectrum feature vector sequence; The forward hidden state and the reverse hidden state are spliced to form a global time sequence feature, and the global time sequence feature is taken as a historical spatiotemporal spectral feature vector sequence; Correspondingly, the historical spatiotemporal spectral feature vector sequence is attention-weighted according to different scales by using a multi-scale attention mechanism to generate a historical weighted spatiotemporal spectral feature vector sequence, which comprises: A preset time scale is obtained, and the historical spatiotemporal spectral feature vector sequence is divided according to the preset time scale to generate a short-time-scale historical spatiotemporal spectral feature vector branch, a medium-time-scale historical spatiotemporal spectral feature vector branch, and a long-time-scale historical spatiotemporal spectral feature vector branch, wherein the preset time scale comprises a short-time scale, a medium-time scale, and a long-time scale; The multi-scale attention mechanism is used to calculate corresponding attention weights for the short-time-scale historical spatiotemporal spectral feature vector branch, the medium-time-scale historical spatiotemporal spectral feature vector branch, and the long-time-scale historical spatiotemporal spectral feature vector branch, respectively; The short-time-scale historical spatiotemporal spectral feature vector branch, the medium-time-scale historical spatiotemporal spectral feature vector branch, and the long-time-scale historical spatiotemporal spectral feature vector branch are weighted processed by the attention weights to obtain a short-time-scale historical weighted spatiotemporal spectral feature vector branch, a medium-time-scale historical weighted spatiotemporal spectral feature vector branch, and a long-time-scale historical weighted spatiotemporal spectral feature vector branch; The short-time-scale historical weighted spatiotemporal spectral feature vector branch, the medium-time-scale historical weighted spatiotemporal spectral feature vector branch, and the long-time-scale historical weighted spatiotemporal spectral feature vector branch are spliced to form a historical weighted spatiotemporal spectral feature vector.

4. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 1, characterized in that, The full connection layer comprises a first full connection layer and a second full connection layer; Correspondingly, the historical weighted spatiotemporal spectral feature vector is input into the full connection layer, and a water quality parameter concentration prediction value is taken as an output quantity to train a water quality parameter trend prediction model, which comprises: The historical weighted spatiotemporal spectral feature vector sequence is input into the first full connection layer, and the historical weighted spatiotemporal spectral feature vector is dimensionally compressed in the first full connection layer to obtain a compressed weighted spatiotemporal spectral feature vector; The compressed weighted spatiotemporal spectral feature vector is input into the second full connection layer, and the compressed weighted spatiotemporal spectral feature vector is feature-mapped in the second full connection layer to obtain a water quality parameter concentration prediction value, thereby completing the training of the water quality parameter trend prediction model.

5. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 1, characterized in that, Real-time water body full-spectrum absorption data is obtained, and the real-time water body full-spectrum absorption data is input into the water quality parameter trend prediction model to output a real-time water quality parameter concentration prediction value, which comprises: Real-time water body full-spectrum absorption data is obtained, wherein the real-time water body full-spectrum absorption data comprises water body full-spectrum absorption data at a current time and water body full-spectrum absorption data within the past twenty-three hours; The real-time water body full-spectrum absorption data is preprocessed and integrated into a real-time time sequence spectral matrix; Inputting the real-time time-series spectrum matrix into the water quality parameter trend prediction model for calculation to obtain a real-time water quality parameter concentration prediction value output by the water quality parameter trend prediction model, wherein the real-time water quality parameter concentration prediction value comprises at least three prediction values, and each prediction value corresponds to a water quality parameter concentration prediction value in the future for at least three hours.

6. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 5, characterized in that, Obtaining a plurality of preset concentration level thresholds, comparing the real-time water quality parameter concentration prediction value with each preset concentration level threshold, and issuing an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold, comprising: Obtaining a plurality of preset concentration level thresholds, wherein the preset concentration level thresholds comprise a first-level concentration threshold, a second-level concentration threshold and a third-level concentration threshold, and the first-level concentration threshold, the second-level concentration threshold and the third-level concentration threshold are arranged in order from small to large in value; Comparing each prediction value in the real-time water quality parameter concentration prediction value with the first-level concentration threshold, the second-level concentration threshold and the third-level concentration threshold to obtain a concentration comparison result; If each prediction value does not exceed the first-level concentration threshold, visualizing each prediction value and the corresponding time without issuing an alarm signal; If a prediction value that exceeds the first-level concentration threshold and does not exceed the second-level concentration threshold appears in each prediction value, visualizing this prediction value and the corresponding time and issuing a first-level alarm signal; If a prediction value that exceeds the second-level concentration threshold and does not exceed the third-level concentration threshold appears in each prediction value, visualizing this prediction value and the corresponding time and issuing a second-level alarm signal; If a prediction value that exceeds the third-level concentration threshold appears in each prediction value, visualizing this prediction value and the corresponding time and issuing a third-level alarm signal.

7. The water quality parameter trend prediction method based on full spectrum and attention mechanism according to claim 1, characterized in that, The water quality parameter corresponding to the water quality parameter concentration prediction value comprises at least one of water quality chemical oxygen demand, water quality total nitrogen content, water quality ammonia nitrogen content, water quality total phosphorus content and water quality turbidity.

8. A water quality parameter trend prediction system based on full spectrum and attention mechanism, for implementing the water quality parameter trend prediction method based on full spectrum and attention mechanism according to any one of claims 1-7, characterized in that, Comprising: A historical data acquisition unit for acquiring historical water body full-spectrum absorption data to form a historical time-series spectrum matrix; A composite model training unit for inputting the historical time-series spectrum matrix as an input quantity into a convolutional neural network for local waveband feature extraction to obtain a historical spectrum feature vector sequence; then inputting the historical spectrum feature vector sequence into a long short-term memory network to extract time-series features to obtain a historical time-space spectrum feature vector sequence, and using a multi-scale attention mechanism to perform attention weighting on the historical time-series spectrum feature vector sequence according to different scales to generate a historical weighted time-space spectrum feature vector; and further for inputting the historical weighted time-space spectrum feature vector into a fully connected layer and taking a water quality parameter concentration prediction value as an output quantity to train a water quality parameter trend prediction model; A real-time data processing unit is configured to acquire real-time water body full-spectrum absorption data, input the real-time water body full-spectrum absorption data into the water quality parameter trend prediction model, and output a real-time water quality parameter concentration prediction value; An automatic alarm triggering unit is configured to acquire a plurality of preset concentration level thresholds, compare the real-time water quality parameter concentration prediction value with each of the preset concentration level thresholds, and send an alarm signal of a corresponding level when the real-time water quality parameter concentration prediction value exceeds the preset concentration level threshold.

9. An electronic device, comprising: The computer program or the instructions, when executed by a computer, implement the water quality parameter trend prediction method based on full-spectrum and attention mechanism according to any one of claims 1-7.

10. A computer program product comprising computer programs or instructions, characterized in that, The computer program or the instructions, when executed by a computer, implement the water quality parameter trend prediction method based on full-spectrum and attention mechanism according to any one of claims 1-7.

Citation Information

Cited By

  • Water quality monitoring model construction method and device, water quality monitoring method and device, equipment and medium

    CN121524637A