Water body ammonia nitrogen concentration prediction method and system based on TKAN model

By introducing the TKAN model in the prediction of ammonia nitrogen concentration in water bodies, using multi-head attention mechanism and multi-scale feature extraction, the problems of high complexity, overfitting and insufficient feature extraction of RNN models are solved, and more efficient and accurate prediction is achieved.

CN119785914APending Publication Date: 2025-04-08NANCHANG INST OF TECH

Patent Information

Application Number
CN202510245299.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-04
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

The existing RNN models have problems such as high model complexity, risk of overfitting and insufficient feature extraction in the prediction of ammonia nitrogen concentration in water bodies, resulting in low prediction accuracy, poor adaptability and low computational efficiency.

Method used

A method for predicting ammonia nitrogen concentration in water based on the TKAN model is proposed. Through multiple TKAN layers, each TKAN layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer and an output generation layer. Multi-head attention mechanism and multi-scale feature extraction are adopted to reduce the complexity of the model, enhance generalization ability and improve feature extraction efficiency.

Benefits of technology

It effectively reduces the complexity of the model, enhances the generalization ability, improves the feature extraction efficiency, improves the accuracy and calculation efficiency of the prediction of ammonia nitrogen concentration in water, and is suitable for dynamic prediction of complex water environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119785914A_ABST
    Figure CN119785914A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of environmental monitoring and prediction, and discloses a TKAN model-based water ammonia nitrogen concentration prediction method and system, and the TKAN model comprises a plurality of TKAN layers (including an input processing layer, a gating layer, a feature extraction layer, a state calculation layer and an output generation layer). The method comprises the following steps: acquiring to-be-detected water body data, and preprocessing to obtain water body time sequence data; acquiring current moment input data, a previous moment hidden state and a previous moment unit state through an input processing layer; obtaining an input gate state vector, a forgetting gate state vector and an output gate state vector through a gate control layer; aggregated features are obtained through a feature extraction layer; obtaining a unit state vector at the current moment through a state calculation layer; and obtaining a water body prediction result of each TKAN layer through the output generation layer, and integrating the water body prediction results of the plurality of TKAN layers to obtain a final water body ammonia nitrogen concentration prediction result. The method effectively improves the prediction precision of the ammonia nitrogen concentration of the water body.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of environmental monitoring and prediction, and in particular to a method and system for predicting ammonia nitrogen concentration in water based on a TKAN model. Background Art

[0002] Ammonia nitrogen is a key indicator of water pollution, and its concentration level directly affects water quality and the health of aquatic ecosystems. Therefore, accurately predicting the changing trend of ammonia nitrogen concentration in water bodies is of great practical significance for water quality management and pollution prevention and control.

[0003] Traditional ammonia nitrogen prediction methods mainly rely on statistical analysis and physical and chemical models. These methods often show limitations such as low prediction accuracy, poor adaptability and low computational efficiency when dealing with complex nonlinear relationships and large-scale time series data. For example, the linear regression model assumes that there is a linear relationship between variables and cannot effectively capture the complex nonlinear dynamics in the changes in ammonia nitrogen concentration; while the physical and chemical based model requires detailed process parameters and prior knowledge, the model construction is complex, and it is difficult to generalize to different water environments.

[0004] In recent years, deep learning technology has made significant progress in the field of time series prediction, especially recurrent neural networks (RNN) and their variants such as long short-term memory networks (LSTM) and gated recurrent units (GRU), which have performed well in processing time series data. These models have shown strong capabilities in capturing long-term and short-term dependencies in data and have gradually become the mainstream method for time series prediction. However, the existing RNN models still face the following challenges when applied to environmental monitoring data: High model complexity: In order to improve prediction accuracy, RNN models usually need to increase the number of network layers and hidden units, resulting in a sharp increase in model parameters, long training time, and high consumption of computing resources.

[0005] Overfitting risk: When processing high-dimensional and noisy environmental data, the RNN model is prone to overfitting, which affects the generalization ability of the model.

[0006] Insufficient feature extraction: Traditional RNN models fail to fully utilize the temporal characteristics and potential complex relationships of data during the feature extraction process, resulting in limited prediction performance.

[0007] In response to the above problems, the existing technology urgently needs a new water ammonia nitrogen concentration prediction model that can effectively reduce model complexity, enhance generalization ability and improve feature extraction efficiency. Summary of the invention

[0008] Based on this, this application proposes a method and system for predicting ammonia nitrogen concentration in water bodies based on the TKAN model, aiming to provide a new time series neural network model to effectively reduce the complexity of the RNN model, enhance the generalization ability and improve the efficiency of feature extraction.

[0009] The first aspect of the present application provides a method for predicting ammonia nitrogen concentration in water based on a TKAN model, wherein the TKAN model includes multiple TKAN layers, each of which includes a TKANCell unit layer, and the TKANCell unit layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer, and an output generation layer. The method includes: Acquire the water body data to be tested and perform preprocessing to obtain water body time series data; Obtaining the current moment input data, the previous moment hidden state and the previous moment unit state according to the water body time series data through the input processing layer; Obtaining an input gate state vector, a forget gate state vector, and an output gate state vector according to the current moment input data and the previous moment hidden state through the gating layer; Obtaining aggregate features according to the input data at the current moment through the feature extraction layer; Obtaining the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment through the state calculation layer; Obtaining the water body prediction result of each TKAN layer according to the aggregated features, the input gate state vector and the unit state vector through the output generation layer; The water body prediction results of multiple TKAN layers are integrated to obtain the final water body ammonia nitrogen concentration prediction result.

[0010] As an optional implementation of the first aspect, the steps of obtaining the water body data to be tested and preprocessing it to obtain water body time series data include: using a moving median method to remove outliers and noise in the water body data to be tested, and using a missing value processing method to fill in the missing data in the water body data to be tested, so as to obtain first water body data; using a minimum-maximum normalization method to standardize the first water body data to obtain second water body data; and constructing time series data based on the second water body data to obtain the water body time series data.

[0011] As an optional implementation of the first aspect, the step of obtaining an input gate state vector, a forget gate state vector and an output gate state vector according to the input data at the current moment and the hidden state at the previous moment through the gating layer includes: the gating layer includes an input gate, a forget gate and an output gate; through the input gate, the input data at the current moment and the hidden state at the previous moment are selectively received to obtain the input gate state vector; through the forget gate, the input data at the current moment and the hidden state at the previous moment are selectively forgotten to obtain the forget gate state vector; through the output gate, the input data at the current moment and the hidden state at the previous moment are converted and controlled to obtain the output gate state vector.

[0012] As an optional implementation manner of the first aspect, the step of selectively receiving the input data at the current moment and the hidden state at the previous moment through the input gate to obtain the input gate state vector is expressed as: ,in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Pass, when it is close to 0, it means that data input is blocked at the current moment and the hidden state at the previous moment pass, represents the sigmoid activation function, represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents the bias vector; through the forget gate, the current moment input data and the previous moment hidden state are selectively forgotten, and the step calculation formula of obtaining the forget gate state vector is expressed as: ,in, When it is close to 1, it means that the current input data is retained. and the hidden state at the previous moment , when it is close to 0, it means forgetting the input data at the current moment and the hidden state at the previous moment , represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents a bias vector; through the output gate, the current moment input data and the previous moment hidden state are converted and controlled, and the step calculation formula of obtaining the output gate state vector is expressed as: ,in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Output, when it is close to 0, it means suppressing the input data at the current moment and the hidden state at the previous moment Output, represents the input transformation weight matrix, represents the recursive transformation weight matrix, Represents the bias vector.

[0013] As an optional implementation of the first aspect, the calculation formula of the step of obtaining the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment through the state calculation layer is expressed as: ,in, Represent the unit state vector at the current moment and the previous moment respectively, represents the Hadamard element-wise product, represents the unit state input transformation matrix, represents the unit state recursive transformation matrix, Represents the cell state bias vector.

[0014] As an optional implementation of the first aspect, the step of the feature extraction layer being used to obtain aggregate features based on the input data at the current moment includes: the feature extraction layer includes multiple parallel KANLinear layers, each of the KANLinear layers is equipped with an independent weight matrix, a bias vector, a configurable nonlinear transformation function and a state update mechanism, and a time perception mechanism is introduced in each of the KANLinear layers; multi-scale time features of the water body are extracted through the multiple parallel KANLinear layers; the weights of the multi-scale time features are calculated using a multi-head attention mechanism; and the multi-scale time features are weightedly fused according to the weights to obtain the aggregate features.

[0015] As an optional implementation of the first aspect, the calculation formula for the step of extracting multi-scale time characteristics of the water body through the multiple parallel KANLinear layers is expressed as: , ,in, Respectively represent k The state vectors of the current and previous moments of the KANLinea layer, Indicates k The scale time characteristics of the KANLinea layer, Indicates k The input transformation matrix of the KANLinea layer, Indicates k The recursive transformation matrix of the KANLinea layer, represents the dynamic weight coefficient of state update, Indicates k The nonlinear transformation function of the KANLinea layer is used; the multi-scale time features are weightedly fused according to the weights to obtain the step of obtaining the aggregated features. The calculation formula is expressed as: , ,in, represents the aggregation feature, represents the number of KANLinea layers, represents the concatenated vector output by all KANLinea layers, represents the aggregation weight matrix, represents the aggregation bias vector, Indicates converting a multidimensional matrix to a one-dimensional array.

[0016] The second aspect of the present application provides a water body ammonia nitrogen concentration prediction system based on a TKAN model, wherein the TKAN model includes multiple TKAN layers, each of which includes a TKANCell unit layer, and the TKANCell unit layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer, and an output generation layer. The system includes a data acquisition module, a TKAN model, and a comprehensive prediction module, wherein: The data acquisition module is used to acquire the water body data to be tested and perform preprocessing to obtain water body time series data; The input processing layer is used to obtain the current moment input data, the previous moment hidden state and the previous moment unit state according to the water body time series data; The gating layer is used to obtain an input gate state vector, a forget gate state vector and an output gate state vector according to the current moment input data and the previous moment hidden state; The feature extraction layer is used to obtain aggregate features according to the input data at the current moment; The state calculation layer is used to obtain the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment; The output generation layer is used to obtain the water body prediction result of each TKAN layer according to the aggregated features, the input gate state vector and the unit state vector; The comprehensive prediction module is used to integrate the water body prediction results of multiple TKAN layers to obtain the final water body ammonia nitrogen concentration prediction result.

[0017] The third aspect of the present application provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to implement the above-mentioned method for predicting ammonia nitrogen concentration in water based on the TKAN model.

[0018] The fourth aspect of the present application provides a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the above-mentioned method for predicting ammonia nitrogen concentration in water bodies based on the TKAN model.

[0019] Compared with the prior art, the present application provides a method for predicting ammonia nitrogen concentration in water based on the TKAN model. First, by obtaining the water body data to be tested and preprocessing it, it is converted into water body time series data suitable for model processing. This step ensures that the data format of the model input is consistent with the requirements and is the basis for subsequent analysis. Then, the input processing layer obtains the input data at the current moment and the hidden state and unit state at the previous moment according to the water body time series data, so that historical information can be integrated into the current prediction, improving the accuracy of the prediction. Then, the gating layer calculates the state vectors of the input gate, forgetting gate and output gate through the input data at the current moment and the hidden state at the previous moment. The functions of these three gates are similar to the memory, forgetting and output mechanisms of memory cells, which helps the model to dynamically adjust the degree of attention to past information when processing time series data, and realize the capture of long-term dependencies. The feature extraction layer extracts key features based on the input data at the current moment. This process helps the model focus on the key factors affecting the ammonia nitrogen concentration and improves the accuracy of the prediction. The state calculation layer uses the state vectors of the forget gate and output gate and the unit state at the previous moment to calculate the unit state vector at the current moment. This process is equivalent to the model screening and updating historical information, making the prediction more in line with the actual situation. Finally, the output generation layer combines the aggregated features, the input gate state vector and the unit state vector to generate the water body prediction results of each TKAN layer. These results reflect the impact of features at different levels on ammonia nitrogen concentration. Therefore, by adopting a multi-layer TKAN structure, this design can enhance the model's deep learning and processing capabilities for water body data. Each layer of TKAN can extract different feature information, thereby improving the accuracy of the prediction.

[0020] Additional aspects and advantages of the present application will be given in part in the following description, and in part will become apparent from the following description, or will be understood through the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 A flow chart of a method for predicting ammonia nitrogen concentration in water based on the TKAN model proposed in the first embodiment of the present application; Figure 2 This is a network structure diagram of the TKAN model proposed in the first embodiment of the present application; Figure 3 This is a performance comparison chart between the TKAN model and the LSTM proposed in the second embodiment of the present application; Figure 4This is a schematic diagram of the structure of a water ammonia nitrogen concentration prediction system based on the TKAN model proposed in the third embodiment of the present application.

[0022] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0024] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here. In addition, the "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally represents that the objects associated with each other are in an "or" relationship.

[0025] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0026] Example 1 See also Figure 1 , which is a flow chart of a method for predicting ammonia nitrogen concentration in water based on the TKAN model proposed in the first embodiment of the present application. The proposed method includes S01 to S07.

[0027] See also Figure 2 , which is a network structure diagram of the TKAN model proposed in the first embodiment of the present application, wherein the TKAN model includes multiple TKAN layers, each TKAN layer includes a TKANCell unit layer, and the TKANCell unit layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer and an output generation layer.

[0028] S01: Acquire the water body data to be tested and perform preprocessing to obtain water body time series data.

[0029] In some embodiments, a moving median method is used to remove outliers and noise in the water body data to be tested, and a missing value processing method is used to fill in the missing data in the water body data to be tested, so as to obtain first water body data; a minimum-maximum normalization method is used to standardize the first water body data to obtain second water body data; and time series data is constructed based on the second water body data to obtain water body time series data.

[0030] In this step, historical observation data of ammonia nitrogen concentration in water bodies and related water quality parameters (such as water temperature, pH value, dissolved oxygen, etc.) are collected. These parameters have a significant impact on the change of ammonia nitrogen concentration and can provide comprehensive water quality information. The data cleaning process is particularly important because water quality data is often affected by factors such as equipment failure and human error. It is necessary to ensure data quality to improve prediction accuracy. The missing value processing process uses the time series interpolation method to fill in the missing data according to the characteristics of water quality parameters. For short-term missing values, linear interpolation is used; for long-term missing values, the average value of historical data for the same period is used to fill. The data standardization process uses the minimum-maximum normalization method to unify the data of each water quality indicator to the [0,1] interval. This process ensures that water quality indicators of different dimensions can be treated fairly in the model. The time series data construction process constructs a suitable input-output sequence pair according to the changing characteristics of ammonia nitrogen concentration in water bodies. For example, multidimensional water quality data from the past 30 days is used to predict ammonia nitrogen concentration in the next 3 days.

[0031] S02: Through the input processing layer, the input data at the current moment, the hidden state at the previous moment, and the unit state at the previous moment are obtained according to the water body time series data.

[0032] Specifically, in this step, the input processing layer receives the water body time series data constructed in step S01 as input. For each time step t, the input processing layer first extracts the water quality parameter data at the current time t from the water body time series data and uses it as the input data at the current time At the same time, the input processing layer also receives the hidden state from the previous moment t-1 and cell status The hidden state at the initial time (t=0) and cell status It is usually initialized to a zero vector or a random small value. The input processing layer does not perform complex calculations or transformations. Its main function is to integrate the water body time series data, the hidden state of the previous moment, and the unit state to provide the necessary input information for the subsequent gating layer, feature extraction layer, etc. This integration method ensures that the model can use historical information and combine it with the input data at the current moment to make more accurate predictions. The input processing layer can be regarded as a data preparation module, and its output is directly passed to other components of the TKANCell unit layer.

[0033] S03: Through the gating layer, the input gate state vector, the forget gate state vector and the output gate state vector are obtained according to the current input data and the hidden state at the previous moment.

[0034] It should be noted that the gating layer is a key component in the TKAN model, responsible for controlling the flow of information and modeling long-term dependencies. It contains three main components: input gate, forget gate, and output gate. These gate structures enable the model to selectively update, retain, and output information, thereby effectively capturing the complex temporal dynamics in water quality data.

[0035] In this step, the input gate is responsible for controlling the degree of influence of the newly input water quality information on the unit state. Through the sigmoid activation function, the input information is mapped to a value between 0 and 1 to achieve selective reception of new water quality data. and the bias vector The input is transformed and combined with the hidden state information of the water quality data at the previous moment.

[0036] The forget gate determines the retention ratio of the water quality status information at the previous moment. By selectively forgetting the status at the previous moment, the model can keep the long-term water quality trend memory while updating the outdated information in time. and the bias vector Achieve selective forgetting of historical water quality information.

[0037] The output gate is responsible for regulating the conversion process of the unit state to the output. By controlling the conversion ratio of the unit state information to the output, the water quality prediction output can be precisely controlled. This gate uses the weight matrix I and the bias vector , combining current input and historical status information to control information output.

[0038] These three gate structures work together to enable the TKAN model to effectively handle both long-term dependencies and short-term fluctuations in water quality data, thereby improving the accuracy and reliability of ammonia nitrogen concentration prediction.

[0039] In some embodiments, the input data at the current moment and the hidden state at the previous moment are selectively received through the input gate to obtain an input gate state vector; the input data at the current moment and the hidden state at the previous moment are selectively forgotten through the forget gate to obtain a forget gate state vector; and the input data at the current moment and the hidden state at the previous moment are converted and controlled through the output gate to obtain an output gate state vector.

[0040] Specifically, the calculation formula for the step of obtaining the input gate state vector is expressed as: , in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Pass, when it is close to 0, it means that data input is blocked at the current moment and the hidden state at the previous moment pass, represents the sigmoid activation function, represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents the bias vector; The calculation formula for the step of obtaining the forget gate state vector is expressed as: , in, When it is close to 1, it means that the current input data is retained. and the hidden state at the previous moment , when it is close to 0, it means forgetting the input data at the current moment and the hidden state at the previous moment , represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents the bias vector; The calculation formula for the step of obtaining the output gate state vector is expressed as: , in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Output, when it is close to 0, it means suppressing the input data at the current moment and the hidden state at the previous moment Output, represents the input transformation weight matrix, represents the recursive transformation weight matrix, Represents the bias vector.

[0041] S04: Obtain aggregated features based on the input data at the current moment through the feature extraction layer.

[0042] The KANLinear layer is one of the innovations of the TKAN model, which consists of multiple parallel KANLinear layers. Each KANLinear layer is equipped with an independent weight matrix, bias vector, configurable nonlinear transformation function, and independent state update mechanism, responsible for processing different feature subspaces of input information. This design enables the model to extract multi-dimensional features of input water quality data. Each KANLinear layer captures different scale features in water quality data through different nonlinear transformations.

[0043] Specifically, the weight matrix includes an input weight matrix and a recursive weight matrix. The input weight matrix is ​​responsible for processing the water quality data input at the current time step, and the input data is converted through a trainable weight matrix. The recursive weight matrix is ​​used to process the hidden state information of the previous moment to achieve modeling of the temporal dependency of water quality data. The bias vector provides additional degrees of freedom for the model and improves the ability to fit complex water quality changes. The initialization bias of the forget gate can be controlled by the unit_forget_bias parameter (this is a parameter used to control the initialization method of the forget gate bias, which helps the model better maintain long-term water quality trend memory in the early stage of training, reduce the gradient disappearance problem, and improve the stability of model training).

[0044] Therefore, the KANLinear layer supports flexible configuration, which can be set through sub_kan_configs (this is a parameter for configuring the KANLinear layer, which is used to define the characteristics of the parallel KANLinear layer in TKAN. It allows the model to use multiple KANLinear layers with different configurations at the same time, enhances the feature extraction ability of the model, and provides flexible nonlinear transformation options to better adapt to complex water quality prediction scenarios. Parameters set different nonlinear transformation functions or use predefined configurations.

[0045] Furthermore, a time perception mechanism is introduced in each KANLinear layer, and multi-scale time features of the water body are extracted through multiple parallel KANLinear layers; a multi-head attention mechanism is used to calculate the weights of the multi-scale time features; and the multi-scale time features are weightedly fused according to the weights to obtain the aggregated features.

[0046] Specifically, through multiple parallel KANLinear layers, the calculation formula for extracting the multi-scale temporal characteristics of the water body is expressed as: , , in, Respectively represent k The state vectors of the current and previous moments of the KANLinea layer, Indicates k The scale time characteristics of the KANLinea layer, Indicates k The input transformation matrix of the KANLinea layer, Indicates k The recursive transformation matrix of the KANLinea layer, represents the dynamic weight coefficient of state update, Indicates k The nonlinear transformation function of the KANLinea layer; The step of weighted fusion of the multi-scale time features according to the weights to obtain the aggregated features is expressed as follows: , , in, represents the aggregation feature, represents the number of KANLinea layers, represents the concatenated vector output by all KANLinea layers, represents the aggregation weight matrix, represents the aggregation bias vector, Indicates converting a multidimensional matrix to a one-dimensional array.

[0047] In the process of weighted fusion, the aggregation weight matrix and the aggregation bias vector are used. The aggregation weight matrix is ​​used to weight the outputs of multiple sub-KAN layers. The weight matrix can be adaptively adjusted through training to adapt to the changes in the importance of different water quality indicators; the aggregation bias vector is used to provide bias adjustment for the aggregation process, further enhancing the model's ability to express complex water quality relationships.

[0048] S05: Obtain the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment through the state calculation layer.

[0049] Specifically, the calculation formula of this step is expressed as: , in, Represent the unit state vector at the current moment and the previous moment respectively, represents the Hadamard element-wise product, represents the unit state input transformation matrix, represents the unit state recursive transformation matrix, Represents the cell state bias vector.

[0050] In this step, a state update mechanism is introduced in the state calculation layer to combine the output of the input gate and the forget gate with the current water quality input and the water quality state at the previous moment to update the internal water quality state of the unit. This mechanism enables the model to effectively capture the long-term dependencies in the water quality sequence data through a carefully designed water quality weight matrix system and state update formula. The state update process includes the update of the unit state and the hidden state.

[0051] S06: Through the output generation layer, the water body prediction results of each TKAN layer are obtained according to the aggregated features, the input gate state vector and the unit state vector.

[0052] Specifically, the calculation formula of this step is expressed as: ,in, Represents the hidden state vector at the current moment.

[0053] Furthermore, the hidden state vector at the current moment is linearly transformed to obtain the process formula of the water body prediction result: ,in, represents the output water body prediction vector, p is the output feature dimension, represents the output transformation matrix, Represents the output bias vector.

[0054] S07: The water body prediction results of multiple TKAN layers are integrated to obtain the final water body ammonia nitrogen concentration prediction result.

[0055] It should be noted that when integrating the water body prediction results of multiple TKAN layers, a variety of methods can be used, such as weighted summation of the prediction results of each TKAN layer, or using neural networks such as multi-layer perceptron (MLP) to comprehensively predict multiple prediction results. The specific comprehensive method can be selected according to actual needs and data characteristics.

[0056] In summary, based on the embodiments provided in this application, the method of this application has the following advantages: 1. The TKAN model significantly improves the accuracy of water quality prediction through multi-scale feature extraction and time perception mechanism. The model can simultaneously capture short-term fluctuations, seasonal changes and long-term trends, thereby more comprehensively understanding the complex water quality dynamics.

[0057] 2. The present invention adopts an innovative attention mechanism to enhance the model's ability to identify key water quality indicators. This makes the prediction results more stable and reliable, especially when facing abnormal water quality events.

[0058] 3. The TKAN model optimizes the computing architecture and significantly improves computing efficiency. This feature enables this method to adapt to large-scale, real-time water quality monitoring needs and provide timely and accurate decision support for water resources management departments.

[0059] Therefore, the present invention is particularly suitable for the dynamic prediction of ammonia nitrogen concentration in complex water environments. It can effectively deal with variable environmental factors and provide strong technical support for water resource management and water pollution prevention and control. By applying the present invention, water quality management personnel can more accurately predict potential water quality problems and formulate targeted prevention and control measures, thereby promoting the sustainable development of the water environment.

[0060] Example 2 In the second embodiment of the present application, first, the monitoring data of a water quality monitoring station in a certain period of time in a certain city are selected, including 10 water quality indicators such as water temperature, pH value, dissolved oxygen, etc. The scheme includes prediction steps of 1 step, 3 steps, 6 steps, 9 steps, 12 steps and 15 steps, and the sequence length is dynamically adjusted according to the prediction step length, not less than 45 time steps. The ratio of training set to validation set is 8:2, and each configuration is run 10 times to take the average value.

[0061] Secondly, determine the model structure: TKAN model is a deep learning model with a two-layer structure. The first layer contains 100 units and returns a sequence; the second layer also contains 100 units and uses a 20-dimensional subspace. The output layer uses a linear activation function.

[0062] Then, the training strategy of the TKAN model was determined: the training strategy included a batch size of 128, a maximum training round of 1000, an optimizer of Adam (learning rate 0.001), and a loss function of mean square error. The early stopping mechanism was set to stop if there was no improvement in the validation loss after 10 rounds, and the learning rate was adjusted to reduce the learning rate if there was no improvement in the validation loss after 5 rounds.

[0063] Finally, the TKAN model and LSTM are compared in terms of prediction accuracy R2 and training time.

[0064] In terms of prediction accuracy, the R2 score is maintained above 0.8 for short-term predictions (1-6 steps); the R2 score is maintained above 0.7 for medium-term predictions (9 steps); and the R2 score is above 0.6 for long-term predictions (12-15 steps). In terms of computational efficiency (reflected by training time), the average training time for short-term predictions is about 40 seconds. As the prediction step increases, the training time increases linearly, and the training time for 15-step predictions does not exceed 120 seconds. In terms of model stability (reflected by standard deviation), the variance of the results of multiple runs is small, indicating that the model has good stability. Although the standard deviation of the results increases slightly with the longer the prediction step, it is still within an acceptable range.

[0065] The results are as follows Figure 3 As shown in the figure, by comparison, the TKAN model has excellent overall performance. The TKAN model has the following advantages over LSTM: First, the TKAN model performs better in terms of prediction accuracy. When predicting short-term (1-6 steps), the R2 score remains above 0.88, while the LSTM is only around 0.85 under the same conditions. When predicting long-term (12-15 steps), the R2 score of the TKAN model remains above 0.81, while the LSTM drops to around 0.74.

[0066] Secondly, the prediction stability of the TKAN model is better, and the standard deviation is generally smaller than that of the LSTM. When predicting 15 steps, the standard deviation of the TKAN model is 0.021429, while that of the LSTM is 0.013632, indicating that the results of the TKAN model are more stable and reliable when run multiple times.

[0067] In addition, the TKAN model has higher computational efficiency and its average training time is significantly lower than that of LSTM. When predicting 15 steps ahead, the TKAN model takes 188.11 seconds, while the LSTM takes 250.02 seconds, saving about 25% of training time.

[0068] Furthermore, the performance of the TKAN model decays more slowly. As the prediction step increases, the R2 score of the TKAN model drops from 0.91 to 0.81, a decrease of about 11%, while the LSTM drops from 0.94 to 0.74, a decrease of about 21%. This shows that the performance of the TKAN model decays more slowly in long-term predictions and is more suitable for long sequence prediction tasks.

[0069] Finally, the TKAN model is more robust. From the perspective of standard deviation, the standard deviation of the TKAN model grows more slowly. When predicting 15 steps, the standard deviation of the TKAN model is 0.021429, while the standard deviation of the LSTM model is 0.013632, indicating that the TKAN model is more resistant to outliers and noise. These advantages make the TKAN model more suitable for practical application scenarios such as water quality prediction.

[0070] In summary, compared with traditional RNN models (such as LSTM and GRU), the TKAN model has unique advantages in the field of water quality prediction. The TKAN model shows significant advantages in the following aspects: 1. Multi-scale feature extraction capability Parallel KANLinear layers: Water quality input data are processed simultaneously through multiple parallel KANLinear layers, each of which focuses on water quality characteristics at different time scales, such as short-term fluctuations, seasonal changes, and long-term trends.

[0071] Adaptive feature extraction: Each KANLinear layer can automatically adjust its feature extraction strategy according to the characteristics of water quality data (such as pH value, dissolved oxygen, etc.) to adapt to the characteristics of different water bodies.

[0072] Feature fusion mechanism: Adaptive fusion of multi-scale water quality features is achieved through an innovative attention mechanism and weight matrix to fully capture the complexity of water quality changes.

[0073] Nonlinear transformation enhancement: Each KANLinear layer is equipped with an independent nonlinear transformation function to enhance the model's ability to capture complex water quality change patterns, such as algal blooms or sudden pollution events.

[0074] 2. Efficient time perception mechanism Dynamic time weight: Automatically adjust feature weights according to the sampling interval of water quality data to adapt to water quality monitoring data of different frequencies, and solve the difficulties of traditional models in dealing with irregular sampling data.

[0075] Long-term dependency modeling: Through improved gating mechanisms and state update strategies, the long-term variation trends of water quality indicators, such as seasonal changes or interannual fluctuations, can be effectively captured, while effectively alleviating the gradient vanishing problem in traditional RNNs.

[0076] Time series correlation analysis: It can automatically identify and maintain important time series dependencies between water quality indicators, and improve the ability to predict long-term water quality changes.

[0077] Time scale adaptation: The model can automatically adjust the time scale range of interest according to different water quality prediction tasks (such as short-term warning or long-term trend analysis).

[0078] 3. Enhanced Attention Mechanism Multi-level attention: A multi-level attention mechanism is introduced in the process of water quality feature extraction and fusion to highlight the impact of key water quality indicators.

[0079] Adaptive weight allocation: Dynamically adjust the attention weights according to the importance of different water quality indicators to adapt to the characteristics of different water bodies.

[0080] Local-global attention: Consider both the local water quality temporal characteristics and the global water status to fully grasp the changes in water quality.

[0081] Interactive feature enhancement: The attention mechanism is used to achieve effective interaction between different water quality feature dimensions and capture complex water quality interactions.

[0082] 4. Optimized model complexity Parameter sharing mechanism: Reduce the number of model parameters through innovative weight sharing strategies and improve the training effect of the model on limited water quality data.

[0083] Modular architecture: facilitates model expansion and maintenance, and supports flexible configuration adjustments for different water characteristics.

[0084] Computational efficiency optimization: Improve the training and inference efficiency of water quality prediction through parallel computing and optimized matrix operations.

[0085] Resource consumption control: While ensuring water quality prediction performance, effectively control computing resource consumption to meet the needs of real-time monitoring systems.

[0086] 5. Enhanced generalization capabilities Noise robustness: Improving resistance to noise in water quality monitoring through multi-scale feature extraction and attention mechanism Data adaptability: Able to adapt to different types and qualities of water quality input data, such as high-frequency online monitoring data and low-frequency manual sampling data.

[0087] Overfitting suppression: Overfitting is effectively controlled through mechanisms such as regularization and dropout, improving the generalization ability of the model between different water bodies.

[0088] Transfer learning capability: The model has good knowledge transfer capability and can quickly adapt to new water bodies or newly added water quality indicators.

[0089] 6. Advantages of parallel computing Efficient parallel architecture: supports GPU acceleration and distributed training; Batch processing optimization: Optimized batch processing mechanism improves training efficiency; Parallel feature extraction: multiple KANLinear layers can process input data in parallel; Computing resource utilization: Better use of the parallel computing capabilities of modern hardware architectures.

[0090] 7. Prediction stability Prediction consistency: Improve the stability of water quality prediction by integrating the outputs of multiple submodules and reduce the prediction bias of a single model.

[0091] Error control: Multi-level feature extraction and fusion mechanism effectively reduce water quality prediction errors and improve prediction reliability.

[0092] Enhanced robustness: It has stronger resistance to water quality input disturbances and outliers, and can adapt to complex and changing water environments.

[0093] Long-term prediction capability: Maintain high accuracy and stability in long-term water quality prediction tasks, providing a reliable basis for long-term water resources planning.

[0094] Example 3 See also Figure 4 , shown is a schematic diagram of the structure of a water body ammonia nitrogen concentration prediction system based on a TKAN model proposed in the third embodiment of the present application, the system includes a data acquisition module 100, a TKAN model 200 and a comprehensive prediction module 300, the TKAN model 200 includes a plurality of TKAN layers, each TKAN layer includes a TKANCell unit layer, the TKANCell unit layer includes an input processing layer 201, a gating layer 202, a feature extraction layer 203, a state calculation layer 204 and an output generation layer 205, wherein: The data acquisition module 100 is used to acquire the water body data to be tested and perform preprocessing to obtain the water body time series data; The input processing layer 201 is used to obtain the current moment input data, the previous moment hidden state and the previous moment unit state according to the water body time series data; The gating layer 202 is used to obtain an input gate state vector, a forget gate state vector and an output gate state vector according to the current input data and the previous hidden state; The feature extraction layer 203 is used to obtain aggregate features according to the input data at the current moment; The state calculation layer 204 is used to obtain the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment; An output generation layer 205, configured to obtain a water body prediction result of each TKAN layer according to the aggregated features, the input gate state vector and the unit state vector; The comprehensive prediction module 300 is used to integrate the water body prediction results of multiple TKAN layers to obtain the final water body ammonia nitrogen concentration prediction result.

[0095] On the other hand, the present application also proposes an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; wherein the processor is configured to execute the executable instructions to implement the above-mentioned method for predicting ammonia nitrogen concentration in water bodies based on the TKAN model.

[0096] On the other hand, the present application also proposes a computer-readable storage medium. When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is able to execute the above-mentioned method for predicting ammonia nitrogen concentration in water bodies based on the TKAN model.

[0097] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0098] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0099] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A method for predicting ammonia nitrogen concentration in water based on the TKAN model, characterized in that: The TKAN model includes a plurality of TKAN layers, each of which includes a TKANCell unit layer, and the TKANCell unit layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer, and an output generation layer. The method includes: Acquire the water body data to be tested and perform preprocessing to obtain water body time series data; Obtaining the current moment input data, the previous moment hidden state and the previous moment unit state according to the water body time series data through the input processing layer; Obtaining an input gate state vector, a forget gate state vector, and an output gate state vector according to the current moment input data and the previous moment hidden state through the gating layer; Obtaining aggregate features according to the input data at the current moment through the feature extraction layer; Obtaining the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment through the state calculation layer; Obtaining the water body prediction result of each TKAN layer according to the aggregated features, the input gate state vector and the unit state vector through the output generation layer; The water body prediction results of multiple TKAN layers are integrated to obtain the final water body ammonia nitrogen concentration prediction result.

2. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 1, characterized in that: The steps of obtaining the water body data to be tested and preprocessing it to obtain the water body time series data include: Using a moving median method to remove outliers and noise in the water body data to be tested, and using a missing value processing method to fill in missing data in the water body data to be tested, to obtain first water body data; The first water body data is normalized by using a minimum-maximum normalization method to obtain second water body data; Time series data is constructed according to the second water body data to obtain the water body time series data.

3. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 1, characterized in that: The step of obtaining an input gate state vector, a forget gate state vector and an output gate state vector according to the current moment input data and the previous moment hidden state through the gating layer includes: The gating layer includes an input gate, a forget gate and an output gate; The input data at the current moment and the hidden state at the previous moment are selectively received through the input gate to obtain the input gate state vector; By using the forget gate, selectively forgetting the input data at the current moment and the hidden state at the previous moment, to obtain the forget gate state vector; The output gate is used to convert the input data at the current moment and the hidden state at the previous moment to obtain the output gate state vector.

4. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 3 is characterized in that: The step of selectively receiving the current moment input data and the previous moment hidden state through the input gate to obtain the input gate state vector is expressed as: , in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Pass, when it is close to 0, it means that data input is blocked at the current moment and the hidden state at the previous moment pass, represents the sigmoid activation function, represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents the bias vector; The step of selectively forgetting the input data at the current moment and the hidden state at the previous moment through the forget gate to obtain the forget gate state vector is expressed as: , in, When it is close to 1, it means that the current input data is retained. and the hidden state at the previous moment , when it is close to 0, it means forgetting the input data at the current moment and the hidden state at the previous moment , represents the input transformation weight matrix, represents the recursive transformation weight matrix, represents the bias vector; The step of converting and controlling the input data at the current moment and the hidden state at the previous moment through the output gate to obtain the output gate state vector is expressed as: , in, When it is close to 1, it means that data can be entered at the current time. and the hidden state at the previous moment Output, when it is close to 0, it means suppressing the input data at the current moment and the hidden state at the previous moment Output, represents the input transformation weight matrix, represents the recursive transformation weight matrix, Represents the bias vector.

5. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 4, characterized in that: The step of obtaining the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment through the state calculation layer is expressed as: , in, Represent the unit state vector at the current moment and the previous moment respectively, represents the Hadamard element-wise product, represents the unit state input transformation matrix, represents the unit state recursive transformation matrix, Represents the cell state bias vector.

6. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 1, characterized in that: The step of the feature extraction layer for obtaining aggregate features according to the input data at the current moment comprises: The feature extraction layer includes multiple parallel KANLinear layers, each of which is equipped with an independent weight matrix, a bias vector, a configurable nonlinear transformation function and a state update mechanism, and a time perception mechanism is introduced in each of the KANLinear layers; Extracting multi-scale temporal characteristics of the water body through the multiple parallel KANLinear layers; A multi-head attention mechanism is used to calculate the weights of the multi-scale temporal features; The multi-scale time features are weightedly fused according to the weights to obtain the aggregated features.

7. The method for predicting ammonia nitrogen concentration in water based on the TKAN model according to claim 6, characterized in that: The calculation formula for extracting the multi-scale time characteristics of the water body through the multiple parallel KANLinear layers is expressed as: , , in, Respectively represent k The state vectors of the current and previous moments of the KANLinea layer, Indicates k The scale time characteristics of the KANLinea layer, Indicates k The input transformation matrix of the KANLinea layer, Indicates k The recursive transformation matrix of the KANLinea layer, represents the dynamic weight coefficient of state update, Indicates k The nonlinear transformation function of the KANLinea layer; The calculation formula of the step of weighted fusion of the multi-scale time features according to the weights to obtain the aggregated features is expressed as: , , in, represents the aggregation feature, represents the number of KANLinea layers, represents the concatenated vector output by all KANLinea layers, represents the aggregation weight matrix, represents the aggregation bias vector, Indicates converting a multidimensional matrix to a one-dimensional array.

8. A water body ammonia nitrogen concentration prediction system based on the TKAN model, characterized in that: The TKAN model includes multiple TKAN layers, each of which includes a TKANCell unit layer, and the TKANCell unit layer includes an input processing layer, a gating layer, a feature extraction layer, a state calculation layer, and an output generation layer. The system includes a data acquisition module, a TKAN model, and a comprehensive prediction module, wherein: The data acquisition module is used to acquire the water body data to be tested and perform preprocessing to obtain water body time series data; The input processing layer is used to obtain the current moment input data, the previous moment hidden state and the previous moment unit state according to the water body time series data; The gating layer is used to obtain an input gate state vector, a forget gate state vector and an output gate state vector according to the current moment input data and the previous moment hidden state; The feature extraction layer is used to obtain aggregate features according to the input data at the current moment; The state calculation layer is used to obtain the unit state vector at the current moment according to the forget gate state vector, the output gate state vector and the unit state at the previous moment; The output generation layer is used to obtain the water body prediction result of each TKAN layer according to the aggregated features, the input gate state vector and the unit state vector; The comprehensive prediction module is used to integrate the water body prediction results of multiple TKAN layers to obtain the final water body ammonia nitrogen concentration prediction result.

9. An electronic device, characterized in that: include: processor; a memory for storing instructions executable by the processor; Wherein, the processor is configured to execute the executable instructions to implement a method for predicting ammonia nitrogen concentration in water based on the TKAN model as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: When the instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute a method for predicting ammonia nitrogen concentration in water based on a TKAN model as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Multi-wind-power-plant short-term power prediction method considering time evolution and space correlation

    CN115293415A

  • Ultra-supercritical unit intermediate point temperature prediction method based on improved Seq2Seq model

    CN118349830A

Cited By

  • Processing method, device and processing equipment of deep and large reservoir water bloom remote sensing prediction model

    CN120219982A