Gas mixture detection model construction method and gas mixture detection method
By constructing a gas mixture detection model based on CNN and KAN models, the shortcomings of the existing technology in high precision and real-time response are solved, and the rapid and accurate detection and concentration analysis of complex gas mixtures are achieved, which is suitable for air quality control in industrial manufacturing processes.
Patent Information
- Application Number
- CN202411674308.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-21
- Publication Date
- 2025-03-14
AI Technical Summary
The prior art has difficulty meeting the requirements for gas mixture detection in industrial manufacturing processes in terms of high precision and real-time response, especially when separate and identifying single components in complex gas mixtures.
A gas mixture detection model based on the CNN model and KAN model is used to obtain spectral data, build a basic detection model and iteratively train based on the spectral data to obtain the gas detection model. The CNN model is used for the classification of gas components, and the KAN model is used for the decomposition and prediction of gas components and concentrations.
The recognition speed and accuracy of complex mixed gases are improved, and the independent spectrum of each component can be effectively decomposed with multiple absorption peaks overlapping, achieving high-precision fitting and concentration analysis, which is suitable for real-time air quality control in industrial manufacturing processes.
Smart Images

Figure CN119622509A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of industrial monitoring technology, and in particular to a gas mixture detection model construction method and a gas mixture detection method. Background Art
[0002] In industrial production, AMC (Airborne Molecular Contamination) monitoring is a crucial technology used to monitor and control pollutants in the air that may be present in the industrial manufacturing process. These pollutants may come from the environment, equipment, materials or operators, and have a serious impact on the industrial production process and product quality.
[0003] Therefore, the implementation of effective AMC monitoring and management is essential to ensure the stability, reliability and high quality of industrial production. However, mixed gas detection still faces challenges when performing AMC monitoring, especially when high precision and real-time response are required. Traditional detection methods may take a long time or complex analysis steps to separate and identify single components in complex gas mixtures, which makes it difficult to meet the real-time and high-precision requirements of industrial manufacturing processes. This problem needs to be solved urgently. Summary of the invention
[0004] The present invention aims to solve at least one of the technical problems in the above-mentioned technology to a certain extent, and proposes a method for constructing a gas mixture detection model, comprising:
[0005] Acquire spectral data of several gas mixtures;
[0006] Construct a basic detection model based on CNN model and KAN model;
[0007] The basic detection model is trained based on the spectral data to obtain a gas detection model.
[0008] Furthermore, the basic detection model is composed of a CNN model and a KAN model connected in sequence; wherein,
[0009] The CNN model is composed of a convolutional layer, a pooling layer and a fully connected layer connected in sequence. The input of the CNN model is vectorized spectral data, and the output of the CNN model is the probability that the target sample belongs to each gas mixture category.
[0010] The output of the KAN model is the gas composition and concentration of the target sample.
[0011] Further, training the basic detection model based on the spectral data includes:
[0012] Dividing the spectral data into a training set, a validation set and a test set;
[0013] Iteratively train the CNN model and the KAN model according to the training set, and calculate the model errors of the CNN model and the KAN model through a loss function;
[0014] When the model error does not meet expectations, the model parameters of the CNN model and the KAN model are tuned based on the gradient descent method.
[0015] Furthermore, when calculating the error of the CNN model, the loss function used is the cross entropy loss function; wherein,
[0016] The expression of the cross entropy loss function is:
[0017]
[0018] Among them, Loss represents the model error; C represents the number of categories; y c represents the true category of the target sample; p c Represents the probability that the target sample predicted by the CNN model belongs to the real category; i = 1, 2, 3, 4...
[0019] Furthermore, when calculating the error of the KAN model, the loss function used is the mean square error function; wherein,
[0020] The expression of the mean square error function is:
[0021]
[0022] Among them, MSE represents the model error of the KAN model; C i represents the true concentration data of the i-th gas mixture sample; represents the predicted concentration data of the i-th gas mixture sample by the KAN model; n represents the number of gas mixture samples; i = 1, 2, 3, 4...
[0023] Furthermore, when the CNN model and the KAN model are iteratively trained respectively according to the training set and the model error is calculated by the loss function, it also includes:
[0024] A regularization term is added to the loss function to prevent the model from overfitting; the regularization term includes: L2 regularization, and the corresponding expression is:
[0025]
[0026] Where G represents the loss function; σ represents the regularization strength; CP irepresents the i-th control point; m represents the total number of control points; i=1,2,3,4…
[0027] Furthermore, after the basic detection model is trained based on the spectral data, it also includes:
[0028] Calculate at least one of a confusion matrix, classification accuracy, precision, recall rate, and F1 score of the CNN model to determine the accuracy of the CNN model; and
[0029] The accuracy of the KAN model was determined based on the root mean square error.
[0030] The present application also proposes a gas mixture detection method, comprising:
[0031] The gas mixture detection is performed based on the gas detection model constructed based on the gas mixture detection model construction method.
[0032] The present application also proposes a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, it is at least used to implement the above-mentioned gas mixture detection method.
[0033] The present application also proposes a computer program product, which is stored in a computer-readable storage medium. When the computer program product is executed by a processor, it is at least used to implement the above-mentioned gas mixture detection method.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] The present application provides a gas mixture detection method based on a CNN network and a KAN network, which, combined with spectral analysis techniques such as infrared spectroscopy (IR) or Fourier transform infrared spectroscopy (FTIR), can improve the recognition speed and accuracy of complex mixed gases. The multi-segment polynomial characteristics of the B-spline of the KAN model enable it to accurately fit the complex patterns in the spectral data, especially when multiple absorption peaks overlap, and can effectively decompose the independent spectrum of each component to achieve high-precision fitting. And the number of control points and basis functions of the B-spline can be adjusted according to the complexity of the spectral data, thereby optimizing the calculation efficiency while ensuring the fitting accuracy. In addition, the local control characteristics of the B-spline enable it to achieve a good balance between the local characteristics of the spectral data and the overall smoothness, and is particularly suitable for processing high-dimensional and complex spectral data. Through these technologies, rapid and accurate detection and concentration analysis of various gaseous molecular pollutants in the air can be achieved, providing a more reliable air quality control method for industrial manufacturing processes, which helps to improve the yield and quality stability of products.
[0036] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description and the accompanying drawings. The technical scheme of the present invention is further described below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0038] Figure 1 A schematic diagram of a gas mixture detection model construction method provided in an embodiment;
[0039] Figure 2 A schematic diagram of an electronic device provided for an embodiment;
[0040] Figure 3 A schematic diagram of a computer-readable storage medium is provided for an embodiment. DETAILED DESCRIPTION
[0041] The present invention is described below in conjunction with the accompanying drawings. The preferred embodiments described herein are only used to illustrate and explain the present invention and are not used to limit the present invention.
[0042] Figure 1 A method for constructing a gas mixture detection model provided by the present invention comprises:
[0043] Acquire spectral data of several gas mixtures;
[0044] Construct a basic detection model based on CNN model and KAN model;
[0045] The basic detection model is trained based on the spectral data to obtain a gas detection model.
[0046] Furthermore, the basic detection model is composed of a CNN model and a KAN model connected in sequence; wherein,
[0047] The CNN model consists of sequentially connected convolutional layers, pooling layers, and fully connected layers. The input of the CNN model is vectorized spectral data, and the output of the CNN model is the probability that the target sample belongs to each gas mixture category.
[0048] The output of the KAN model is the gas composition and concentration of the target sample.
[0049] It should be noted that the above-mentioned gas mixture refers to a gas sample with known composition and concentration, and the target sample refers to a sample with unknown composition and concentration.
[0050] According to some embodiments of the present application, the data preparation step for training the model includes:
[0051] 1. Data collection: Use a Fourier transform infrared spectrometer (FTIR) to collect spectral data of multiple sets of mixed gases. These spectral data should cover combinations of different gas components and concentrations to ensure that the model can learn the characteristics of multiple mixtures.
[0052] 2. Data preprocessing: Preprocess the collected infrared absorption spectrum data of mixed gases, remove noise and perform normalization. Normalization can ensure that different spectral data have similar amplitude ranges, thereby improving the stability of training. Label the spectral data with known gas mixture labels and the concentration of each component. Ensure that the data set covers a variety of different mixing ratios and component combinations so that the basic detection model can fully learn.
[0053] 3. Data partitioning: Divide the spectral dataset into training set, validation set and test set, for example, 70% for training, 15% for validation and 15% for testing.
[0054] According to some embodiments of the present application, the original spectral data type is spectral data from Fourier transform infrared spectroscopy (FTIR), and the data form is a one-dimensional vector (i.e., vectorized spectral data); the spectrum graph is a curve representing the variation of absorbance with wavelength (or wave number), and this curve is discretized into a one-dimensional vector, and each data point represents the absorbance at a specific wavelength:
[0055] v=[I(λ1),I(λ2),...,I(λ i ),...]
[0056] Among them, λ i represents the i-th wavelength, I(λ i ) represents the absorbance at that wavelength.
[0057] According to some embodiments of the present application, the architecture and working principle of the CNN model are as follows:
[0058] 1. Convolutional layer:
[0059] Input data: Input one-dimensional vector spectral data v.
[0060] Processing method: The 1D convolution kernel slides along the input vector. Each time it slides, the local features of the corresponding position (such as the shape and position of the absorption peak) are extracted:
[0061]
[0062] Among them, w i is the weight of the convolution kernel, Fk (λ) is the output of the kth feature map.
[0063] Output data: multiple feature maps, each capturing a different local feature in the spectrum:
[0064] O 卷积 =[F1(λ),F2(λ),...,F k (λ)]
[0065] O 卷积 Represents the convolution output, and these feature maps reflect the important information in each wavelength range in the spectrum.
[0066] 2. Pooling layer:
[0067] Input data: feature map output by the convolutional layer.
[0068] Processing method: The pooling layer downsamples the feature map (such as maximum pooling or average pooling), retains key features and reduces data dimensions:
[0069] P k (λ)=pool(F k (λ)
[0070] Output data: feature map after downsampling, the amount of data is reduced, but important information is retained:
[0071] O 池化 =[P1(λ),P2(λ),...,P k (λ)]
[0072] 3. Fully connected layer:
[0073] Input data: The pooled feature map is flattened into a one-dimensional vector.
[0074] Processing method: The fully connected layer maps the flattened features to the output classification labels through the weight matrix:
[0075] O=W·p+b
[0076] Among them, W is the weight matrix, p is the flattened eigenvector, and b is the bias.
[0077] Output data: Classification probability distribution, determining to which gas mixture class the input spectrum belongs:
[0078] O 分类 =[p1,p2,...,p c ]
[0079] Among them, p c is the probability that the input spectrum belongs to class c.
[0080] According to some embodiments of the present application, the architecture and working principle of the KAN model are as follows:
[0081] 1. Input data:
[0082] Data type: Spectral data after CNN classification, still a one-dimensional vector.
[0083] Processing method: The KAN model accepts the classified spectral data, decomposes it into independent spectra for each gas component, and calculates the concentration.
[0084] 2. Spline function processing:
[0085] Input data: Classification spectra from CNN (O 分类 ).
[0086] Processing method: KAN uses multi-layer spline functions to perform nonlinear mapping on the input data. Each layer of spline function uses the formula:
[0087]
[0088] Among them, φ i is the spline function, g i (x) is the linear transformation of the input data.
[0089] Output data: decomposed spectral characteristics, indicating the contribution of each gas component in the spectrum.
[0090] 3. Concentration calculation:
[0091] Processing method: KAN uses the decomposed spectral data to calculate the concentration of each gas component through linear or nonlinear regression:
[0092] C n =Regression(f(x))
[0093] Among them, C n Indicates the concentration of the nth gas component.
[0094] 4. Output data: concentration value of each gas component.
[0095] In summary, the data change process in this embodiment is as follows:
[0096] 1. Raw spectral data: obtained from FTIR and represented as a one-dimensional vector.
[0097] 2. CNN processing: Input the one-dimensional vector into 1D-CNN, extract features through convolution and pooling, classify them, and output the category of the spectrum.
[0098] 3. KAN processing: Perform nonlinear decomposition on the classified spectral data and calculate the concentration of each gas component.
[0099] 4. Final result: Generate a concentration report providing a detailed analysis of each gas component.
[0100] Through the above method, the data is gradually processed and converted from the original spectrum, and finally an accurate gas composition analysis result is obtained.
[0101] Furthermore, a basic detection model is trained based on spectral data, including:
[0102] Divide the spectral data into training set, validation set and test set;
[0103] Iteratively train the CNN model and the KAN model according to the training set, and calculate the model errors of the CNN model and the KAN model through the loss function;
[0104] When the model error does not meet expectations, the model parameters of the CNN model and the KAN model are tuned based on the gradient descent method.
[0105] Furthermore, when calculating the error of the CNN model, the loss function used is the cross entropy loss function; where,
[0106] The expression of the cross entropy loss function is:
[0107]
[0108] Among them, Loss represents the model error; C represents the number of categories; y c represents the true category of the target sample; p c Represents the probability that the target sample predicted by the CNN model belongs to the real category; i = 1, 2, 3, 4...
[0109] According to some embodiments of the present application, the construction and training process of the CNN model is as follows:
[0110] 1. Model architecture: Build a one-dimensional convolutional neural network (1D-CNN), including convolutional layers, pooling layers, and fully connected layers. The input of the network is one-dimensional spectral data, and the output is a classification result, indicating which gas mixture category the spectrum belongs to.
[0111] 2. Loss function: Use the cross-entropy loss function to measure the gap between the category probability distribution output by the model and the true label:
[0112]
[0113] Where C is the number of categories, y cis the true label, p c is the predicted probability.
[0114] 3. Optimizer: Use Adam optimizer to perform gradient descent to adjust the weights and biases of the model to minimize the loss function.
[0115] 4. Training process: Perform multiple rounds of iterative training on the training set. In each round of iteration, the model calculates the output through forward propagation, calculates the error through the loss function, and adjusts the weights through back propagation. Use the validation set to monitor the performance of the model to prevent overfitting. If the performance of the validation set begins to deteriorate, early stopping or regularization techniques can be used.
[0116] Furthermore, when calculating the error of the KAN model, the loss function used is the mean square error function; where,
[0117] The expression of the mean square error function is:
[0118]
[0119] Among them, MSE represents the model error of the KAN model; C i represents the true concentration data of the i-th gas mixture sample; represents the predicted concentration data of the i-th gas mixture sample by the KAN model; n represents the number of gas mixture samples; i = 1, 2, 3, 4...
[0120] According to some embodiments of the present application, the construction and training process of the KAN model is as follows:
[0121] 1. Model architecture: Kolmogorov-Arnold Networks (KAN) are constructed, and the input is the spectral data after CNN classification. Each layer of KAN uses a learnable spline function to process the input data and finally outputs the concentration of each gas component.
[0122] 2. Spline function parameter learning: The parameters of the spline function are initialized and then adjusted through training data so that KAN can accurately decompose the mixed spectrum and predict the concentration.
[0123] 3. Loss function: Use mean squared error (MSE) as the loss function to measure the gap between the predicted concentration and the actual concentration:
[0124]
[0125] Among them, C i represents the true concentration of the i-th sample, represents the concentration predicted by the model for the i-th sample, n represents the number of samples; i = 1, 2, 3, 4...
[0126] 4. Optimizer: The Adam optimizer is also used to optimize the model parameters based on the gradient descent method, so that KAN can accurately predict the concentration of each gas component.
[0127] 5. Training process: Use the training set for multiple iterations. In each iteration, KAN calculates the predicted concentration through forward propagation, calculates the loss through MSE, and adjusts the spline function parameters through back propagation. The validation set is used to monitor the model performance and ensure that the model can generalize to new data.
[0128] Furthermore, when the CNN model and the KAN model are iteratively trained according to the training set and the model error is calculated by the loss function, it also includes:
[0129] Add regularization terms to the loss function to prevent the model from overfitting; regularization terms include: L2 regularization, the corresponding expression is:
[0130]
[0131] Where G represents the loss function; σ represents the regularization strength; CP i represents the i-th control point; m represents the total number of control points.
[0132] Furthermore, after training the basic detection model based on the spectral data, it also includes:
[0133] Calculate at least one of a confusion matrix, classification accuracy, precision, recall, and F1 score of the CNN model to determine the accuracy of the CNN model; and
[0134] The accuracy of the KAN model was determined based on the root mean square error.
[0135] According to some embodiments of the present application, the evaluation process of the trained basic detection model is as follows:
[0136] 1. CNN classification model evaluation: Use the test set to evaluate the classification accuracy of CNN. For example, you can calculate one or more of the confusion matrix, classification accuracy, precision, recall rate, and F1 score to comprehensively evaluate the classification performance of the model.
[0137] 2. KAN decomposition and prediction model evaluation: Use the test set to evaluate the concentration prediction performance of KAN. Calculate the MSE and root mean square error (RMSE) to evaluate the prediction accuracy of the model:
[0138]
[0139] In this embodiment, the evaluation process further includes: for each sample in the test set, comparing the predicted concentration with the actual concentration, and generating an error analysis report.
[0140] The present application also proposes a gas mixture detection method, comprising:
[0141] The gas mixture detection is performed based on the gas detection model constructed based on the gas mixture detection model construction method.
[0142] According to some embodiments of the present application, mixed gas detection is performed by using a detection model trained based on the above method, and the model deployment and application process includes:
[0143] 1. Deployment: Integrate the trained CNN and KAN models into the actual gas detection system for real-time processing of spectral data from FTIR. Set up a model update and retraining mechanism to ensure that the model can adapt to new data changes.
[0144] 2. Application: Applied to scenarios such as environmental monitoring and industrial emission monitoring, using the deployed model for real-time gas mixture analysis and component concentration prediction.
[0145] 2.1 Sample collection and spectrum acquisition: Use a gas sampling device to collect gaseous molecular pollutant samples in the test environment. The collected samples are introduced into the FTIR spectrometer for spectral scanning to obtain the infrared absorption spectrum of the gas mixture.
[0146] 2.2 Spectral classification (using CNN): The preprocessed spectral data is input into a convolutional neural network (CNN). CNN extracts spectral features (such as absorption peak position, shape, etc.) through multi-layer convolution operations for spectral classification. The CNN model classifies the spectral data into specific gas mixture labels based on the features.
[0147] 2.3 Spectral decomposition and concentration prediction (using KAN): The classified spectral data are input into Kolmogorov-Arnold Networks (KAN), and the activation function of the traditional neural network is replaced by a nonlinear spline function to decompose the spectrum more accurately.
[0148] The expression of KAN network is as follows:
[0149]
[0150] Among them, f(x) is the decomposition function of the spectrum, g i (x) is the input spectral data after linear transformation, φ i is a nonlinear spline function, and m is the number of spline functions.
[0151] KAN decomposes the input spectral data by learning these spline functions to obtain the independent spectral characteristics of each gas component. Based on the decomposed spectrum, the concentration of each gas component is calculated and the final quantitative analysis results are output.
[0152] 2.4 Result output and report generation: Based on the results of KAN decomposition and concentration prediction, a gaseous pollutant concentration report is generated, which includes the type and concentration value of each gas component. The generated report is transmitted to the user terminal for environmental monitoring or industrial control.
[0153] According to some embodiments of the present application, in spectral analysis, spectral data usually contains complex features, such as multiple overlapping absorption peaks and local discontinuities. In order to accurately decompose these spectral features and extract the concentration of each gas component therefrom, Kolmogorov-Arnold Networks (KAN) uses B-Spline as its main spline function. B-Spline is a class of piecewise polynomial functions widely used in numerical analysis and computer graphics. B-Spline functions are constructed through linear combinations of a set of basis functions (Basis Functions) and can flexibly represent complex curves. Each basis function corresponds to a specific node (or control point), which determines the shape and position of the spline.
[0154] The expression of B-spline function is as follows:
[0155]
[0156] Where S(x) represents the spline function; N i,k (x) represents the i-th basis function, k represents the order of the spline; CP i Represents a control point.
[0157] According to some embodiments of the present application, in KAN, B-splines are used to perform nonlinear mapping and decomposition on input spectral data. The specific applications are as follows:
[0158] 1. Spline basis function: In each layer of KAN, the spectral data x is input into multiple B-spline basis functions, which are connected through the control points CP i Adjust the curve shape to accurately fit the complex features of the input spectrum.
[0159] 2. Piecewise polynomial combination: By combining these basis functions, B-splines can provide different piecewise polynomial representations in different wavelength ranges, making the spectral decomposition not only accurate but also adaptable to the characteristics of different gas components.
[0160] 3. Local control: Since B-spline has good local controllability, when a control point is adjusted, the change of the curve is limited to the segment adjacent to the control point. This enables KAN to accurately adjust local features while maintaining the overall smoothness of the spectrum, thereby accurately extracting the concentration of each gas component.
[0161] The advantages of the above solution are:
[0162] 1. High-precision fitting: The multi-segment polynomial characteristics of B-spline enable it to accurately fit complex patterns in spectral data, especially when multiple absorption peaks overlap, and can effectively decompose the independent spectrum of each component.
[0163] 2. Flexibility: The number of control points and basis functions of B-splines can be adjusted according to the complexity of the spectral data, thereby optimizing the computational efficiency while ensuring the fitting accuracy.
[0164] 3. Local adjustment capability: The local control characteristics of B-spline enable it to achieve a good balance between the local characteristics and overall smoothness of spectral data, and is particularly suitable for processing high-dimensional and complex spectral data.
[0165] In summary, by adopting B-splines in KAN, the model can more effectively process and decompose complex spectral data, providing higher accuracy and stability for the concentration prediction of gas components. This method is particularly suitable for the analysis of multi-component gas mixtures and can significantly improve the accuracy and efficiency of spectral analysis.
[0166] According to some embodiments of the present application, in KAN, the core of the training process is to optimize the control points and other related parameters of the spline function so that the model can accurately fit the input data and can effectively perform spectral decomposition or other complex tasks. The following is a detailed description of how the KAN model is optimized during the training process:
[0167] 1. Initial Setup
[0168] Knots and Degree: First, you need to select the node positions and degree of the spline. The node positions can be evenly distributed or manually set according to the data characteristics, and the degree is usually selected as a cubic spline or other suitable degree.
[0169] Initial control points: Each B-spline basis function is associated with a control point CP i According to some embodiments of the present application, the initial control point can be set by linear interpolation, sample mean or other methods.
[0170] 2. Definition of loss function
[0171] Loss Function: The loss function measures the error between the model output and the true label. In KAN, the mean square error (MSE) is usually used as the loss function:
[0172]
[0173] Among them, y j is the true value of the jth sample, is the model prediction value, and n is the number of samples.
[0174] 3. Gradient calculation
[0175] Gradient of control point: In each iteration, the loss function is calculated for each control point CP i The partial derivative of , which represents the change of the loss function when the control point changes.
[0176]
[0177] in, is the partial derivative of the model output with respect to the control points.
[0178] Influence of basis function: Due to the basis function N of B-spline i,k (x) is a fixed recursive formula, control point CP i The impact on the model output can be calculated by combining basis functions:
[0179]
[0180] Among them, x j is the jth sample of the input data, and m is the number of control points.
[0181] 4. Gradient Descent Optimization
[0182] Update rule: Use gradient descent method to update each control point CP i , to minimize the loss function:
[0183]
[0184] Among them, η is the learning rate, which controls the size of the update step.
[0185] Learning rate setting: The choice of learning rate is crucial to the training process. A suitable learning rate can ensure that the model converges at a steady rate without excessive fluctuations or premature stopping. Common initial values of the learning rate are 0.01 or 0.001.
[0186] Adaptive optimizer: You can use adaptive optimization algorithms like Adam or RMSProp, which dynamically adjust the learning rate based on the historical information of the gradient, thereby improving the efficiency and stability of the optimization process.
[0187] 5. Regularization
[0188] L2 regularization: In order to prevent the model from overfitting, a regularization term can be added to the loss function to penalize the control points. A commonly used regularization method is L2 regularization:
[0189]
[0190] Among them, σ represents the regularization strength parameter, which penalizes the size of the control point and ensures the smoothness of the model curve.
[0191] 6. Model evaluation and validation
[0192] Validation set: During the training process, the validation set is used regularly to evaluate the performance of the model and monitor the convergence of the model. The performance of the validation set can be used to determine whether the learning rate, regularization parameters, or other hyperparameters need to be adjusted.
[0193] Early Stopping: If the loss of the validation set no longer decreases or starts to increase, early stopping can be used to terminate training early to avoid overfitting of the model.
[0194] 7. Finalization of the model
[0195] Test set evaluation: After training is completed, the model is evaluated using the test set to ensure that the model has good generalization ability.
[0196] Model deployment: Once the model has passed the test evaluation, it can be deployed in real-world applications to process new spectral data in real time, perform spectral decomposition and concentration prediction.
[0197] In summary, during the training process of KAN, the core of optimization lies in adjusting the control point CP of the B-spline i and related parameters to minimize the loss function and ensure the accurate fit of the model to the spectral data. Through the gradient descent method and its variants (such as Adam), the model can gradually adjust these parameters so that the final prediction result is as close to the true value as possible. Regularization techniques and the use of validation sets further improve the robustness and generalization ability of the model.
[0198] like Figure 2 As shown, the present application provides an electronic device, which includes a memory and a processor. The memory stores a computer program or instruction. When the computer program or instruction is executed by the processor, it is at least used to implement the above-mentioned gas mixture detection method.
[0199] like Figure 3 As shown, the present application also proposes a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is executed by a processor, it is at least used to implement the above-mentioned gas mixture detection method.
[0200] The present application also proposes a computer program product, which is stored in a computer-readable storage medium. When the computer program product is executed by a processor, it is at least used to implement the above-mentioned gas mixture detection method.
[0201] It is obvious that a person skilled in the art may make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for constructing a gas mixture detection model, characterized in that: include: Acquire spectral data of several gas mixtures; Construct a basic detection model based on CNN model and KAN model; The basic detection model is trained based on the spectral data to obtain a gas detection model.
2. The method according to claim 1, characterized in that The basic detection model is composed of a CNN model and a KAN model connected in sequence; wherein, The CNN model is composed of a convolutional layer, a pooling layer and a fully connected layer connected in sequence. The input of the CNN model is vectorized spectral data, and the output of the CNN model is the probability that the target sample belongs to each gas mixture category. The output of the KAN model is the gas composition and concentration of the target sample.
3. The method according to claim 1, characterized in that Training the basic detection model based on the spectral data includes: Dividing the spectral data into a training set, a validation set and a test set; Iteratively train the CNN model and the KAN model according to the training set, and calculate the model errors of the CNN model and the KAN model through a loss function; When the model error does not meet expectations, the model parameters of the CNN model and the KAN model are tuned based on the gradient descent method.
4. The method according to claim 3, characterized in that When calculating the error of the CNN model, the loss function used is the cross entropy loss function; where, The expression of the cross entropy loss function is: Among them, Loss represents the model error; C represents the number of categories; y c represents the true category of the target sample; p c Represents the probability that the target sample predicted by the CNN model belongs to the real category; i = 1, 2, 3, 4...
5. The method according to claim 3, characterized in that When calculating the error of the KAN model, the loss function used is the mean square error function; where, The expression of the mean square error function is: Among them, MSE represents the model error of the KAN model; C i represents the true concentration data of the i-th gas mixture sample; represents the predicted concentration data of the i-th gas mixture sample by the KAN model; n represents the number of gas mixture samples; i = 1, 2, 3, 4...
6. The method according to any one of claims 3 to 5, characterized in that: When the CNN model and the KAN model are iteratively trained according to the training set and the model error is calculated by the loss function, the method further includes: A regularization term is added to the loss function to prevent the model from overfitting; the regularization term includes: L2 regularization, and the corresponding expression is: Where G represents the loss function; σ represents the regularization strength; CP i represents the i-th control point; m represents the total number of control points; i=1,2,3,4… 7. The method according to claim 3, characterized in that After training the basic detection model based on the spectral data, the method further includes: Calculate at least one of a confusion matrix, classification accuracy, precision, recall rate, and F1 score of the CNN model to determine the accuracy of the CNN model; and The accuracy of the KAN model was determined based on the root mean square error.
8. A method for detecting a gas mixture, characterized in that: include: Gas mixture detection is performed based on the gas detection model constructed by the gas mixture detection model construction method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program or instruction, and when the computer program or instruction is executed by the processor, it is at least used to implement the method of claim 8.
10. A computer program product, the computer program product being stored in a computer-readable storage medium, characterized in that: When the computer program product is executed by a processor, it is used to at least implement the method of claim 8.
Citation Information
Cited By
Near infrared spectrum-based leaf moisture content and chlorophyll detection method
CN120992551A
FTIR spectrum functional group intelligent identification method and system based on fusion of computer vision and deep learning
CN121074647A
Method for establishing and detecting infrared spectroscopic analysis model of mixed gas
CN122451705A
A mixed gas infrared spectrum analysis model establishing and detecting method
CN122451705B