Rapid detection method and system based on NIR and multi-distance domain generalization
By constructing a quality parameter detection model for domain invariant feature extraction and multi-scale spatial feature extraction prediction processing, the problems of instability and inaccuracy of near-infrared detection results caused by instability in sampling distances are solved, and rapid and efficient detection of different acquisition distances are achieved.
Patent Information
- Application Number
- CN202510476882.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-04-16
AI Technical Summary
The existing near-infrared detection technology causes changes in the signal intensity and noise level of the spectral data due to the instability of the sampling distance, which reduces the stability and accuracy of the detection results.
Using a fast detection method based on NIR and multi-distance domain generalization, a quality parameter detection model is constructed, domain-invariant feature extraction and multi-scale spatial feature extraction prediction processing are carried out, and the quality parameters of the substance to be inspected are generated, which improves the generalization ability of spectral data detection at different acquisition distances.
It realizes rapid detection of near-infrared spectral data to be inspected at different acquisition distances, improves the detection efficiency and accuracy, and enhances the ability to detect the quality parameters of the substance to be inspected.
Smart Images

Figure CN119985392A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a detection method and system, in particular to a rapid detection method and system based on NIR and multi-distance domain generalization. Background Art
[0002] Near-infrared spectroscopy has been widely used in many fields such as mineral products, material testing, and environmental monitoring because of its advantages of being fast, non-destructive, and not requiring complex sample pretreatment. This technology uses the spectrum in the range of 13,000 cm⁻¹~4,000 cm⁻¹ to irradiate the sample to obtain the chemical composition and structural information of the sample, providing strong support for rapid qualitative and quantitative analysis.
[0003] In actual industrial applications, due to the common roughness and irregularity of mineral surfaces, the distance between the sensor of the spectrometer and the mineral sample is difficult to maintain stable during sampling. Specifically: on the one hand, during operation, handheld or automatic sampling equipment is inevitably affected by factors such as sampling pressure, position and angle, resulting in changes in the sampling distance; on the other hand, this distance inconsistency will directly affect the signal strength and noise level of the spectral data, thereby reducing the stability and accuracy of the detection results, seriously restricting the application effect of traditional near-infrared detection technology in actual production. How to improve the reliability and accuracy of near-infrared detection is a technical problem that urgently needs to be solved. Summary of the invention
[0004] The purpose of the present invention is to overcome the shortcomings of the prior art and provide a rapid detection method and system based on NIR and multi-distance domain generalization, which can effectively realize rapid detection of near-infrared spectral data to be detected at different collection distances, improve the generalization ability of rapid detection of near-infrared spectral data, and improve the efficiency and accuracy of quality parameter detection of the substance to be detected.
[0005] According to the technical solution provided by the present invention, a rapid detection method based on NIR and multi-distance domain generalization, the rapid detection method comprises: Providing near infrared spectrum data of the substance to be tested, and loading the near infrared spectrum data to be tested into the constructed quality parameter detection model, so as to use the quality parameter detection model to perform quality detection processing on the near infrared spectrum data to be tested, and generating the quality parameters of the substance to be tested after the quality detection processing, wherein, When providing the near infrared spectrum data to be tested, it at least includes collecting the near infrared spectrum of the substance to be tested, wherein when collecting the near infrared spectrum of the substance to be tested, the collecting distance is within the collecting threshold of the multiple distance domains; During the quality detection process, at least domain invariant feature extraction and multi-scale spatial feature extraction and prediction are performed, wherein: The quality parameter detection model first performs domain-invariant feature extraction on the near-infrared spectral data to be tested to obtain the domain-invariant features of the near-infrared spectral data to be tested. Thereafter, the domain-invariant features to be tested are subjected to multi-scale spatial feature extraction and prediction processing to generate the quality parameters of the substance to be tested.
[0006] The quality parameter detection model includes a detection linear layer, a domain invariant feature extraction unit, a regression prediction unit and a prediction output unit, wherein: The detection linear layer is connected to the domain invariant feature extraction unit, and the domain invariant feature extraction unit is adaptively connected to the regression prediction unit; When performing quality inspection, the detection linear layer is used to perform linear transformation on the near-infrared spectrum data to be inspected, and the near-infrared spectrum transformation data to be inspected obtained by the linear transformation is loaded into the domain invariant feature extraction unit; The domain-invariant feature extraction unit is used to extract domain-invariant features from the near-infrared spectrum transformation data to be inspected, and the domain-invariant features to be inspected obtained by the domain-invariant feature extraction are loaded into the regression prediction unit; The regression prediction unit is used to perform multi-scale spatial feature extraction and prediction processing on the invariant features of the to-be-tested domain, and the obtained multi-scale spatial features to be tested are loaded into the prediction output unit; Based on the received multi-scale spatial features of the substance to be tested, the prediction output unit outputs the quality parameters of the substance to be tested.
[0007] The domain invariant feature extraction unit includes a plurality of domain invariant feature extraction modules connected in series, wherein the domain invariant feature extraction module at the head of the series connection is connected to the detection linear layer; The regression prediction unit comprises a plurality of regression prediction heads connected in series, wherein the number of the regression prediction heads in the regression prediction unit is consistent with the number of the domain invariant feature extraction modules in the domain invariant feature extraction unit, wherein the regression prediction head at the end of the series connection is adaptively connected to the prediction output unit; In the quality parameter detection model, each domain-invariant feature extraction module is jump-connected to the corresponding regression prediction head.
[0008] The domain-invariant feature extraction module includes a domain-invariant convolution module, a domain-invariant downsampling module, and a spatial channel attention module connected in sequence, wherein: For any two domain-invariant feature extraction modules connected in series, along the direction of the series connection, the output end of the spatial channel attention module in the previous domain-invariant feature extraction module is connected to the domain-invariant convolution module in the next domain-invariant feature extraction module; For any domain-invariant feature extraction module, the output end of the spatial channel attention module in the domain-invariant feature extraction module is connected to the corresponding regression prediction head through a skip connection; When performing domain-invariant feature extraction, for any domain-invariant feature extraction module, the domain-invariant feature sequence to be extracted loaded into the current domain-invariant feature extraction module is convolved using the domain-invariant convolution module to extract local features of the domain-invariant feature sequence to be extracted, and generate a domain-invariant convolved feature sequence; A domain-invariant downsampling module is used to downsample the domain-invariant convolution feature sequence to generate a domain-invariant downsampled feature sequence, wherein the feature dimension of the domain-invariant downsampled feature sequence is lower than the feature dimension of the domain-invariant convolution feature sequence; The spatial channel attention module is used to perform attention mechanism processing on the domain-invariant down-sampling feature sequence to generate a domain-invariant post-attention mechanism feature sequence after the attention mechanism processing.
[0009] The domain invariant convolution module includes at least two domain invariant convolution submodules connected in series, wherein: For any domain-invariant convolution submodule, the domain-invariant convolution submodule includes a domain-invariant sub-block convolution layer, a domain-invariant batch normalization layer, and a domain-invariant sub-block Mish activation function; When any two domain-invariant convolutional submodules are connected in series, along the direction of the connection, the domain-invariant subblock Mish activation function of the previous domain-invariant convolutional submodule is connected to the domain-invariant subblock convolutional layer in the next domain-invariant convolutional submodule; In the domain-invariant feature extraction module, the domain-invariant convolution submodule at the end of the concatenation is connected to the domain-invariant downsampling module through the corresponding domain-invariant sub-block Mish activation function.
[0010] The spatial channel attention module includes a spatial attention mechanism module using residual connection and a channel attention mechanism module using residual connection, wherein, Using the spatial attention mechanism module to perform spatial attention mechanism processing on the domain-invariant down-sampled feature sequence, so as to generate a domain-invariant spatial attention processed feature sequence after the spatial attention mechanism processing; A channel attention mechanism module is used to perform channel attention mechanism processing on the domain-invariant down-sampling feature sequence, so as to generate a domain-invariant channel attention processed feature sequence after the channel attention mechanism processing; Performing a matrix multiplication operation on the feature sequence after the domain-invariant spatial attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant spatial multiplication feature sequence after the matrix multiplication operation; Performing a matrix multiplication operation on the feature sequence after the domain-invariant channel attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant channel multiplied feature sequence after the matrix multiplication operation; A matrix addition operation is performed on the feature sequence after the domain-invariant spatial multiplication and the feature sequence after the domain-invariant channel multiplication to generate a feature sequence after the domain-invariant attention mechanism after the matrix addition operation.
[0011] The regression prediction head includes a regression prediction splicer, a regression prediction convolution module and a regression prediction transposed convolution module connected in sequence, wherein: For any two regression prediction heads connected in series, along the direction of the connection, the regression prediction transposed convolution module of the previous regression prediction head is connected to the regression prediction splicer of the next regression prediction head; For any regression prediction head, when a jump connection is used, the output end of the domain-invariant feature extraction module of the corresponding jump connection is connected through the regression prediction splicer.
[0012] When building a quality parameter detection model, the construction method includes: Constructing a basic model for quality parameter detection, and preparing a basic model training data set for training the basic model for quality parameter detection, wherein: The quality parameter detection basic model also includes a reconstruction decoding unit and a discriminator, wherein the reconstruction decoding unit and the discriminator are adaptively connected to the domain invariant feature extraction unit; The basic model training data set includes a plurality of model data samples, wherein when preparing the basic model training data set, near infrared spectra of the training material are collected at different training collection distances to form a model data sample based on the collected training near infrared spectrum data and the quality label of the training material. The training substance and the substance to be tested belong to the same category of substances, and the training acquisition distance is also within the acquisition threshold of the multi-distance domain; The basic model training data set is divided into at least a training sample set and a verification sample set, so as to use the training sample set to perform model training on the basic model for multi-distance domain quality parameter detection, and use the verification sample set to perform model verification on the basic model for multi-distance domain quality parameter detection, wherein: When the training sample set is used to train the basic model of multi-distance domain quality parameter detection, in each batch training process, the detection linear layer, domain invariant feature extraction unit, prediction output unit, reconstruction decoding unit and regression prediction unit in the basic model of quality parameter detection are firstly trained, and then the discriminator is trained; The basic model for multi-distance domain quality parameter detection is trained to reach a target state, and after the basic model for multi-distance domain quality parameter detection is verified using a verification sample set, a quality parameter detection model is formed based on the basic model for multi-distance domain quality parameter detection that has reached a target state through model training.
[0013] The reconstruction decoding unit includes a plurality of reconstruction decoding modules connected in series, wherein: The number of reconstruction decoding modules in the reconstruction decoding unit is consistent with the number of domain invariant feature extraction modules in the domain invariant feature extraction unit; For any reconstruction decoding module, the reconstruction decoding module includes a reconstruction decoding splicer, a reconstruction decoding convolution module and a reconstruction decoding transposed convolution module connected in sequence, wherein: For any two reconstruction and decoding modules connected in series, along the direction of the series connection, the reconstruction and decoding transposed convolution module of the previous reconstruction and decoding module is connected to the reconstruction and decoding splicer in the next reconstruction and decoding module; When constructing the basic model for quality parameter detection, the domain invariant feature extraction module is jump-connected to the corresponding reconstruction decoding module, and when the jump connection is made, the reconstruction decoding splicer is connected to the output end of the domain invariant feature extraction module of the corresponding jump connection.
[0014] A fast detection system based on NIR and multi-distance domain generalization, comprising a fast detection processing device, wherein a quality parameter detection model is deployed in the fast detection processing device; The rapid detection processing device uses the above-mentioned rapid detection method to perform quality detection processing on the near-infrared spectrum data of the substance to be detected, so as to output the quality parameters of the substance to be detected after the quality detection processing.
[0015] The advantages of the present invention are as follows: a quality parameter detection model is constructed, and the constructed quality parameter detection model can be used to perform rapid quality detection processing on near-infrared spectral data to be inspected under acquisition thresholds of multiple distance domains. The quality parameter detection model first performs domain-invariant feature extraction on the near-infrared spectral data to be inspected, so as to extract the domain-invariant features of the near-infrared spectral data to be inspected. Thereafter, the quality parameter detection model performs multi-scale spatial feature extraction and prediction processing on the domain-invariant features to be inspected, so as to generate quality parameters of the substance to be inspected after the multi-scale spatial feature extraction and prediction processing; rapid detection can be effectively achieved for the near-infrared spectral data to be inspected under different acquisition distances, thereby improving the generalization ability of rapid detection of near-infrared spectral data, and improving the efficiency and accuracy of quality parameter detection of the substance to be inspected. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 The present invention is a flowchart of an embodiment of the rapid detection method.
[0017] Figure 2 It is a structural block diagram of an embodiment of the basic model for quality parameter detection of the present invention.
[0018] Figure 3 This is a structural block diagram of an embodiment of the domain invariant convolution module of the present invention.
[0019] Figure 4 A schematic diagram of an embodiment of performing convolution processing on a domain-invariant sub-block convolution layer of the present invention.
[0020] Figure 5A schematic diagram of an embodiment of the spatial channel attention module of the present invention.
[0021] Figure 6 It is a schematic diagram of an embodiment of multiple near-infrared spectra of bauxite according to the present invention. DETAILED DESCRIPTION
[0022] The present invention will be further described below in conjunction with specific drawings and embodiments.
[0023] In order to effectively realize rapid detection of near-infrared spectral data to be detected at different collection distances, improve the generalization ability of rapid detection of near-infrared spectral data, and improve the efficiency and accuracy of quality parameter detection of substances to be detected, the present invention provides a rapid detection method based on NIR and multi-distance domain generalization. Specifically, the rapid detection method includes: Providing near infrared spectrum data of the substance to be tested, and loading the near infrared spectrum data to be tested into the constructed quality parameter detection model, so as to use the quality parameter detection model to perform quality detection processing on the near infrared spectrum data to be tested, and generating the quality parameters of the substance to be tested after the quality detection processing, wherein: When providing the near infrared spectrum data to be tested, it at least includes collecting the near infrared spectrum of the substance to be tested, wherein when collecting the near infrared spectrum of the substance to be tested, the collecting distance is within the collecting threshold of the multiple distance domains; During the quality detection process, the quality parameter detection model at least performs domain invariant feature extraction processing and multi-scale spatial feature extraction prediction processing, wherein: The quality parameter detection model first performs domain-invariant feature extraction on the near-infrared spectral data to be tested to extract the domain-invariant features of the near-infrared spectral data to be tested. Thereafter, the quality parameter detection model performs multi-scale spatial feature extraction and prediction processing on the domain-invariant features to generate the quality parameters of the substance to be tested after multi-scale spatial feature extraction and prediction processing.
[0024] Figure 1 A flow chart of an embodiment of the rapid detection method of the present invention is shown in the figure. It can be seen from the figure that when performing rapid detection, the near-infrared spectrum data (NIR) of the substance to be detected should be provided. Therefore, the substance to be detected should be of a type suitable for near-infrared spectrum detection, such as bauxite or other types of substances. When performing rapid detection on the substance to be detected, it specifically refers to determining the quality parameters of the substance to be detected based on the provided near-infrared spectrum data to be detected. For example, when the substance to be detected is bauxite, the quality parameters of the substance to be detected can be the content of Al2O3 in the substance to be detected. When the substance to be detected is of other types, the corresponding quality parameters correspond to the type of the substance to be detected. The corresponding quality parameters can be referred to the description here and will not be repeated here.
[0025] It should be understood that when providing the near infrared spectrum data to be tested, at least the near infrared spectrum of the substance to be tested should be collected, so that the corresponding near infrared spectrum data to be tested can be obtained after the near infrared spectrum collection. Figure 6 An embodiment of near-infrared spectral data of different samples based on bauxite is shown in the figure. The near-infrared spectral data to be tested in the present invention is spectral data obtained by performing a near-infrared spectral collection on the material to be tested using a near-infrared spectral collection instrument. Therefore, the near-infrared spectral data to be tested is data obtained by collecting a near-infrared spectrum. The near-infrared spectral collection instrument can adopt existing commonly used equipment, such as the MicroNIR Pro handheld near-infrared spectrometer of VIAVI.
[0026] It can be seen from the above description that when using a near-infrared spectrum acquisition instrument to collect near-infrared spectra, there is a collection distance between the substance to be tested and the near-infrared spectrum acquisition instrument, and the collection distance will fluctuate. In one embodiment of the present invention, the collection distance should be within the collection threshold of the multi-distance domain. Therefore, the multi-distance domain specifically refers to the use of samples generated by collecting at multiple collection distances for training when constructing a quality parameter detection model. Thereafter, when the collection distance corresponding to any near-infrared spectrum data to be tested is within the collection threshold of the multi-distance domain, the quality parameter detection model can be used for quality detection processing, and the quality parameters of the substance to be tested obtained after the quality detection processing have higher accuracy, that is, the accuracy of the quality parameters obtained by rapid detection is less affected by the collection distance. In other words, the quality parameter detection model of the present invention can adapt to near-infrared spectrum data to be tested at different collection distances, and can effectively realize rapid detection, thereby improving the generalization ability of quality detection processing for near-infrared spectrum data.
[0027] In one embodiment of the present invention, the acquisition threshold of the multi-distance domain may be 30 mm, that is, when the near-infrared spectrum of the substance to be tested is collected, it is necessary to ensure that the collection distance is between 0 and 30 mm when the near-infrared spectrum collection instrument is used to collect the near-infrared spectrum of the substance to be tested. After the near-infrared spectrum of the substance to be tested is collected, the near-infrared spectrum source data to be tested can be generated. In order to improve the detection accuracy, the standard normal transformation (standard Normal Variate transform, SNV) can be used to process the near-infrared spectrum source data to be tested to eliminate environmental noise and obtain the near-infrared spectrum data to be tested after processing. At this time, when providing the near-infrared spectrum data to be tested, at least near-infrared spectrum collection and standard normal transformation processing are included. Specifically, the method and process of using the standard normal transformation to process the near-infrared spectrum source data to be tested can be consistent with the prior art, which will not be repeated here.
[0028] It can be understood that after obtaining the near-infrared spectral data to be tested, the near-infrared spectral data to be tested should be loaded into the constructed quality parameter detection model so as to perform quality detection processing using the quality parameter detection model, wherein the quality detection processing performed by the quality parameter detection model at least includes domain-invariant feature extraction processing and multi-scale spatial feature extraction and prediction processing. In specific implementation, domain-invariant feature extraction processing should be performed first, and then multi-scale spatial feature extraction and prediction processing should be performed, so as to generate the quality parameters of the substance to be tested after multi-scale spatial feature extraction and prediction processing.
[0029] In one embodiment of the present invention, the quality parameter detection model includes a detection linear layer, a domain invariant feature extraction unit, a regression prediction unit and a prediction output unit, wherein: The detection linear layer is connected to the domain invariant feature extraction unit, and the domain invariant feature extraction unit is adaptively connected to the regression prediction unit; When quality detection is performed on the near infrared spectrum data to be inspected, a detection linear layer is used to perform linear transformation on the near infrared spectrum data to obtain near infrared spectrum transformation data to be inspected after the linear transformation, and the near infrared spectrum transformation data to be inspected is loaded into the domain invariant feature extraction unit; The domain-invariant feature extraction unit is used to extract domain-invariant features from the near-infrared spectrum transformation data to be inspected, so as to generate domain-invariant features to be inspected after the domain-invariant feature extraction, and the domain-invariant features to be inspected are loaded into the regression prediction unit; Using the regression prediction unit to perform multi-scale spatial feature extraction prediction processing on the invariant features of the to-be-tested domain, so as to generate the to-be-tested multi-scale spatial features after the multi-scale spatial feature extraction prediction processing, and loading the to-be-tested multi-scale spatial features into the prediction output unit; Based on the received multi-scale spatial features of the substance to be tested, the prediction output unit outputs the quality parameters of the substance to be tested.
[0030] Depend on Figure 6 As known in the art, the near infrared spectrum data to be tested is one-dimensional data, and the near infrared spectrum data to be tested can be expressed as a sequence of L×1, where L is the number of sampling points of the near infrared spectrum data to be tested, Figure 4 An embodiment of the near infrared spectrum data to be tested is shown in FIG. 1 , wherein the near infrared spectrum data to be tested is sequence data. Figure 4 middle, …, are L feature points of the near-infrared spectral data to be tested.
[0031] In order to meet the quality inspection requirements, the detection linear layer should be used to perform linear transformation on the near-infrared light slope data to be inspected. After the linear transformation, the near-infrared spectrum transformation data to be inspected can be obtained. Specifically, the detection linear layer is used to extract the information of the near-infrared spectrum data from the near-infrared spectrum data to be inspected, and capture the important features in the near-infrared spectrum data to be inspected. In addition, after the linear transformation, the feature dimension of the near-infrared spectrum transformation data to be inspected can be L×C, where C is the channel dimension of the near-infrared spectrum transformation data to be inspected. Therefore, during the linear transformation, the feature dimension of the near-infrared spectrum data to be inspected is also transformed.
[0032] In specific implementation, the linear transformation processing should be performed in the quality parameter detection model. When the linear transformation processing is performed in the quality parameter detection model, a detection linear layer should be set in the quality parameter detection model. Therefore, the quality detection processing should also include the linear transformation processing. In order to meet the quality detection processing, the quality parameter detection model should include a detection linear layer, a domain invariant feature extraction unit, a regression prediction unit and a prediction output unit. Figure 2 In the figure, XN1 is the detection linear layer, and the detection linear layer can adopt an existing commonly used form, specifically based on whether it can satisfy the above-mentioned linear transformation processing on the near-infrared spectrum data to be detected.
[0033] In the specific implementation, the domain invariant feature extraction unit is used to perform the above-mentioned domain invariant feature extraction processing, and the regression prediction unit is used to perform the above-mentioned multi-scale spatial feature extraction prediction processing. Specifically, the detection linear layer should be connected to the domain invariant feature extraction unit, and the near-infrared spectrum transformation data to be tested can be loaded into the domain invariant feature extraction unit, so that the domain invariant feature extraction unit can be used to perform domain invariant feature extraction processing on the near-infrared spectrum transformation data to be tested, and generate domain invariant features to be tested. It should be noted that performing domain invariant feature processing specifically refers to extracting features in the near-infrared spectrum transformation data to be tested that are independent of the acquisition distance, that is, the domain invariant features to be tested are independent of the acquisition distance when the near-infrared spectrum source data to be tested is generated, thereby effectively reducing the influence of the acquisition distance on the prediction quality parameters.
[0034] The domain-invariant features to be tested generated by the domain-invariant feature extraction process should be loaded into the regression prediction unit, so as to utilize the regression prediction unit to perform multi-scale spatial feature extraction and prediction processing on the domain-invariant features to be tested, and generate multi-scale spatial features to be tested. In order to output the quality parameters of the substance to be tested, the present invention maps and outputs the multi-scale spatial features to be tested through the prediction output unit, and can generate the quality parameters of the substance to be tested after the mapping output, wherein the prediction output unit can adopt the commonly used fully connected layer, and the form adopted by the prediction output unit shall be based on whether it can satisfy the mapping output of the quality parameters of the substance to be tested.
[0035] In one embodiment of the present invention, the domain invariant feature extraction unit includes a plurality of domain invariant feature extraction modules connected in series, wherein the domain invariant feature extraction module at the head of the series connection is connected to the detection linear layer; The regression prediction unit comprises a plurality of regression prediction heads connected in series, wherein the number of the regression prediction heads in the regression prediction unit is consistent with the number of the domain invariant feature extraction modules in the domain invariant feature extraction unit, wherein the regression prediction head at the end of the series connection is adaptively connected to the prediction output unit; In the quality parameter detection model, each domain-invariant feature extraction module is jump-connected to the corresponding regression prediction head.
[0036] In a specific implementation, the domain invariant feature extraction unit may include a plurality of domain invariant feature extraction modules connected in series. The number of domain invariant feature extraction modules in the domain invariant feature extraction unit may be selected according to needs. Generally, the domain invariant feature extraction unit includes at least two domain invariant feature extraction modules. The number of domain invariant feature extraction modules may be based on the actual application requirements. Figure 2 An embodiment of a domain-invariant feature extraction unit including four domain-invariant feature extraction modules connected in series is shown in the figure, wherein the domain-invariant feature extraction modules preferably adopt the same structural form. When multiple domain-invariant feature extraction modules are connected in series, the domain-invariant feature module located at the head of the series connection is connected to the detection linear layer so as to receive the near-infrared spectrum transformation data to be detected generated by the detection linear layer. It should be noted that when multiple domain-invariant feature extraction modules are connected in series to form a domain-invariant feature extraction unit, the shallow domain-invariant feature extraction module is used to capture local spectral details, and the deep domain-invariant feature extraction module is used to integrate global contextual relationships, thereby avoiding the insufficient long-range dependency modeling and loss of detail information caused by the limited receptive field in the single-layer structure, thereby improving the characterization capability of feature extraction of complex near-infrared spectrum data to be detected.
[0037] Specifically, the regression prediction unit can be formed by connecting multiple regression prediction heads in series, wherein the number of regression prediction heads in the regression prediction unit should be consistent with the number of domain invariant feature extraction modules in the domain invariant feature extraction unit. At this time, there is a one-to-one correspondence between the regression prediction heads and the domain invariant feature extraction modules. Figure 2 An embodiment of forming a regression prediction unit by connecting four regression prediction heads in series is shown in FIG. When the four regression prediction heads are connected in series to form a regression prediction unit, the regression prediction head at the end of the series connection is connected to the prediction output unit. In a specific implementation, the effect of connecting multiple regression prediction heads in series to form a regression prediction unit can refer to the corresponding description of connecting multiple domain-invariant feature extraction modules in series to form a domain-invariant feature extraction unit.
[0038] In a specific implementation, within the quality parameter detection model, each domain-invariant feature extraction module is jump-connected to the corresponding regression prediction head. For example, when four domain-invariant feature extraction modules are connected in series to form a domain-invariant feature extraction unit, the input end of the first domain-invariant feature extraction module is connected to the detection linear layer, and is connected to the fourth regression prediction head through a jump connection. The input end of the second domain-invariant feature extraction module is connected to the output end of the first domain-invariant feature extraction module, and is connected to the input end of the third domain-invariant feature extraction module, and is connected to the third regression prediction head through a jump connection; the output end of the third domain-invariant feature extraction module is connected to the input end of the fourth domain-invariant feature extraction module, and is connected to the second regression prediction head through a jump connection.
[0039] It should be noted that the output end of the fourth domain-invariant feature extraction module is connected to the input end of the first regression prediction head, but no jump connection is used. The regression prediction head connected to the prediction output unit is the fourth regression prediction head in the regression prediction unit. Along the direction from the first regression prediction head to the fourth regression prediction head, the corresponding regression prediction heads are the second regression prediction head and the third regression prediction head, respectively. The serial connection between the regression prediction heads can be referred to the description here, and examples will not be given one by one here. Figure 2 In the domain-invariant feature extraction unit shown in FIG, the domain-invariant feature extraction module located at the outermost side and connected to the detection linear layer is the first domain-invariant feature extraction module. For other situations, the corresponding order can be determined by referring to the above description, which will not be repeated here.
[0040] It should be understood that when jump connections are used between the domain-invariant feature extraction unit and the regression prediction unit, multi-scale feature fusion can be achieved, combining the shallow detail information in the domain-invariant feature extraction module with the deep semantic features of the corresponding regression prediction head, thereby retaining local details such as the absorption peak position and intensity in the near-infrared spectral data to be tested, and compensating for the loss of spatial information caused by downsampling, integrating details with the global context relationship, and improving the prediction accuracy of the quality parameter detection model for quality parameters.
[0041] In one embodiment of the present invention, the domain-invariant feature extraction module includes a domain-invariant convolution module, a domain-invariant downsampling module, and a spatial channel attention module connected in sequence, wherein: For any two domain-invariant feature extraction modules connected in series, along the direction of the series connection, the output end of the spatial channel attention module in the previous domain-invariant feature extraction module is connected to the domain-invariant convolution module in the next domain-invariant feature extraction module; For any domain-invariant feature extraction module, the output end of the spatial channel attention module in the domain-invariant feature extraction module is connected to the regression prediction head of the corresponding skip connection; When performing domain-invariant feature extraction, for any domain-invariant feature extraction module, the domain-invariant feature sequence to be extracted loaded into the current domain-invariant feature extraction module is convolved using the domain-invariant convolution module to extract local features of the domain-invariant feature sequence to be extracted, and generate a domain-invariant convolved feature sequence; A domain-invariant downsampling module is used to downsample the domain-invariant convolution feature sequence to generate a domain-invariant downsampled feature sequence, wherein the feature dimension of the domain-invariant downsampled feature sequence is lower than the feature dimension of the domain-invariant convolution feature sequence; The spatial channel attention module is used to perform attention mechanism processing on the domain-invariant down-sampling feature sequence to generate a domain-invariant post-attention mechanism feature sequence after the attention mechanism processing.
[0042] Figure 2 An embodiment of a domain-invariant feature extraction module is shown in FIG. As can be seen from the figure, each domain-invariant feature extraction module may include a domain-invariant convolution module, a domain-invariant downsampling module, and a spatial channel attention module. Figure 2 In the figure, the domain invariant downsampling module is not shown. The domain invariant downsampling module of the present invention can adopt an average pooling method when downsampling, that is, Figure 2 The average pooling in is the downsampling operation performed by the domain-invariant downsampling module of the present invention. Specifically, the domain-invariant downsampling module is composed of an average pooling layer. Figure 2 The scSE (Concurrent Spatial and Channel Squeeze&Excitation) in is the spatial channel attention module.
[0043] In one embodiment of the present invention, the domain-invariant convolution module serves as the input layer of the domain-invariant feature extraction module, and the spatial channel attention module serves as the output layer of the domain-invariant feature extraction module. Therefore, when any two domain-invariant feature extraction modules are connected in series, the output end of the spatial channel attention module in the previous domain-invariant feature extraction module is connected to the domain-invariant convolution module in the next domain-invariant feature extraction module. It can be understood that for the domain-invariant feature extraction module at the head of the series connection, the domain-invariant feature extraction module is connected to the detection linear layer through the domain-invariant convolution module to receive the near-infrared spectral transformation data to be detected loaded by the detection linear layer. In the case of jump connection, the output end of the spatial channel attention module in each domain-invariant feature extraction module is connected to the regression prediction head of the corresponding jump connection, that is, it is adaptively connected to the corresponding regression prediction head through the spatial channel attention module.
[0044] During specific implementation, for any domain-invariant feature extraction module, the domain-invariant convolution module is used to perform convolution processing on the domain-invariant feature sequence to be extracted loaded into the current domain-invariant feature extraction module, so as to extract local features of the domain-invariant feature sequence to be extracted, and generate a domain-invariant feature sequence after convolution. It can be understood that the situation of the domain-invariant feature sequence to be extracted is related to the loaded domain-invariant feature extraction module. For example, when the current domain-invariant feature extraction module is at the head of the series connection, it can be seen from the above description that the domain-invariant feature sequence to be extracted should be the near-infrared spectral transformation data to be tested. For other domain-invariant feature extraction modules, the corresponding domain-invariant feature sequence to be extracted should be the feature sequence after the domain-invariant attention mechanism generated by the previous domain-invariant feature extraction module.
[0045] From the above description, it can be seen that after executing the domain-invariant feature extraction process, the domain-invariant features to be tested should be loaded into the regression prediction unit. When the domain-invariant feature extraction unit adopts the above form, the domain-invariant features to be tested should include the domain-invariant attention mechanism post-feature sequence generated by all domain-invariant feature extraction modules. Therefore, from the above description, the specific situation of loading the domain-invariant features to be tested into the regression prediction unit can be obtained. Please refer to the above description for details.
[0046] In one embodiment of the present invention, the domain invariant convolution module includes at least two domain invariant convolution submodules connected in series, wherein: For any domain-invariant convolution submodule, the domain-invariant convolution submodule includes a domain-invariant sub-block convolution layer, a domain-invariant batch normalization layer, and a domain-invariant sub-block Mish activation function; When any two domain-invariant convolutional submodules are connected in series, along the direction of the connection, the domain-invariant subblock Mish activation function of the previous domain-invariant convolutional submodule is connected to the domain-invariant subblock convolutional layer in the next domain-invariant convolutional submodule; In the domain-invariant feature extraction module, the domain-invariant convolution submodule at the end of the concatenation is connected to the domain-invariant downsampling module through the corresponding domain-invariant sub-block Mish activation function.
[0047] In order to realize the above-mentioned convolution processing on the domain-invariant feature sequence to be extracted, the domain-invariant convolution module may include at least two domain-invariant convolution submodules connected in series. The number of domain-invariant convolution submodules in the domain-invariant convolution module may be selected as needed. Figure 3 FIG. 1 shows an embodiment in which a domain-invariant convolution module includes two domain-invariant convolution submodules connected in series. As can be seen from the figure, the domain-invariant convolution submodules can adopt the same structural form. For example, each domain-invariant convolution submodule should at least include a domain-invariant sub-block convolution layer, a domain-invariant batch normalization layer, and a domain-invariant sub-block Mish activation function connected in sequence. Figure 3When the two domain-invariant convolution submodules shown in are connected in series, JG1 is the domain-invariant sub-block convolution layer in the first domain-invariant convolution submodule, BN2 is the domain-invariant batch normalization layer in the first domain-invariant convolution submodule, and M2 is the domain-invariant sub-block Mish activation function in the first domain-invariant convolution submodule; similarly, it can be obtained that: JG2 is the domain-invariant sub-block convolution layer in the second domain-invariant convolution submodule, BN3 is the domain-invariant batch normalization layer in the second domain-invariant convolution submodule, and M3 is the domain-invariant sub-block Mish activation function in the second domain-invariant convolution submodule.
[0048] In specific implementation, the domain invariant sub-block convolutional layer can adopt the existing commonly used form. Figure 4 FIG. 2 shows an embodiment of a domain-invariant sub-block convolution layer performing convolution processing. As can be seen from the figure, the convolution kernel size used by the domain-invariant sub-block convolution layer can be 3, and the padding size can be 1. Of course, the domain-invariant sub-block convolution layer can also use other convolution parameters, which can be selected according to needs, and no examples are given here.
[0049] When the domain-invariant convolution module adopts the above structure and is connected to the domain-invariant downsampling module in the domain-invariant feature extraction module, the domain-invariant convolution sub-module at the end of the series connection is connected to the domain-invariant downsampling module through the corresponding domain-invariant sub-block Mish activation function. For example, when a domain-invariant convolution module is formed by connecting two domain-invariant convolution sub-modules in series, it is connected to the corresponding domain-invariant downsampling module through the domain-invariant sub-block Mish activation function M3, that is, the domain-invariant convolution feature sequence can be output through the domain-invariant sub-block Mish activation function M3. For other situations, please refer to the description here.
[0050] It should be noted that when performing convolution processing on the domain-invariant feature sequence to be extracted, the local features in the domain-invariant feature sequence to be extracted can be extracted through the domain-invariant sub-block convolution layer; by setting at least two domain-invariant sub-block convolution layers in the domain-invariant convolution module, feature extraction with more abstract semantic representation can be achieved; the domain-invariant batch normalization layer can be used to standardize the output sequence of the domain-invariant sub-block convolution layer to make the input distribution more stable and reduce internal covariate shift; the domain-invariant sub-block Mish activation function can improve the nonlinear representation ability, and it has a smooth curve in the negative value region, which helps to retain the feature information in the near-infrared spectral data to be tested.
[0051] The domain-invariant downsampling module downsamples the domain-invariant convolution feature sequence. Downsampling can gradually reduce the dimension of the features, extract more abstract and high-level features, and help the quality parameter detection model to better understand and generalize the data. Therefore, when the domain-invariant downsampled feature sequence is generated by the domain-invariant downsampling module, the feature dimension of the domain-invariant downsampled feature sequence is lower than the feature dimension of the domain-invariant convolution feature sequence.
[0052] In one embodiment of the present invention, the spatial channel attention module includes a spatial attention mechanism module using residual connection and a channel attention mechanism module using residual connection, wherein: Using the spatial attention mechanism module to perform spatial attention mechanism processing on the domain-invariant down-sampled feature sequence, so as to generate a domain-invariant spatial attention processed feature sequence after the spatial attention mechanism processing; A channel attention mechanism module is used to perform channel attention mechanism processing on the domain-invariant down-sampling feature sequence, so as to generate a domain-invariant channel attention processed feature sequence after the channel attention mechanism processing; Performing a matrix multiplication operation on the feature sequence after the domain-invariant spatial attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant spatial multiplication feature sequence after the matrix multiplication operation; Performing a matrix multiplication operation on the feature sequence after the domain-invariant channel attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant channel multiplied feature sequence after the matrix multiplication operation; A matrix addition operation is performed on the feature sequence after the domain-invariant spatial multiplication and the feature sequence after the domain-invariant channel multiplication to generate a feature sequence after the domain-invariant attention mechanism after the matrix addition operation.
[0053] Specifically, the spatial channel attention module can include a spatial attention mechanism module (Channel Squeeze and Spatial Excitation, sSE) and a channel attention mechanism module (Spatial Squeeze and Channel Excitation, cSE) at the same time, wherein both the spatial attention mechanism module and the channel attention mechanism module adopt residual connection, and the spatial attention mechanism module and the channel attention mechanism module adopt parallel distribution state, such as Figure 5 As shown, at this time, the domain-invariant downsampling feature sequence can be loaded into the spatial attention mechanism module and the channel attention mechanism module at the same time. Thereafter, the spatial attention mechanism module is used to perform spatial attention mechanism processing on the domain-invariant downsampling feature sequence to generate a domain-invariant spatial attention processed feature sequence after the spatial attention mechanism processing; at the same time, the channel attention mechanism module is used to perform channel attention mechanism processing on the domain-invariant downsampling feature sequence to generate a domain-invariant channel attention processed feature sequence after the channel attention mechanism processing.
[0054] For the spatial attention mechanism module using residual connection, after obtaining the feature sequence after the domain-invariant spatial attention processing, the feature sequence after the domain-invariant spatial attention processing should also be matrix multiplied with the feature sequence after the domain-invariant downsampling, so as to generate the domain-invariant spatial multiplication feature sequence after the matrix multiplication operation. Similarly, for the channel attention module using residual connection, after obtaining the feature sequence after the domain-invariant channel attention processing, the feature sequence after the domain-invariant spatial attention processing should also be matrix multiplied with the feature sequence after the domain-invariant downsampling, so as to generate the domain-invariant spatial multiplication feature sequence after the matrix multiplication operation.
[0055] Figure 5 A schematic diagram of an embodiment of a spatial channel attention module is also shown in FIG. Figure 5 In , DE0 is the feature sequence after domain-invariant downsampling. As can be seen from the figure, the spatial attention mechanism module may include a spatial attention convolution block and a spatial attention Sigmoid function. Figure 5 In the figure, KJG1 is a spatial attention convolution block, and S3 is a spatial attention Sigmoid function. When performing the spatial attention mechanism processing, the spatial attention convolution block can perform spatial attention convolution on the domain-invariant downsampling feature sequence to generate a domain-invariant spatial attention convolution feature sequence after the spatial attention convolution. Thereafter, the spatial attention Sigmoid function is used to perform spatial attention mapping on the domain-invariant spatial attention convolution feature sequence to generate a domain-invariant spatial attention mapping feature sequence after the spatial attention mapping. Figure 3 In the figure, D0 is the feature sequence after domain-invariant spatial attention convolution, and D1 is the feature sequence after domain-invariant spatial attention mapping.
[0056] In specific implementation, the feature dimension of the feature sequence after domain-invariant downsampling is L×C, the size of the convolution kernel used in the spatial attention convolution block can be 1, and in addition, the feature dimension of the feature sequence after domain-invariant spatial attention convolution and the corresponding feature dimension of the feature sequence after domain-invariant spatial attention mapping are both L×1. Figure 5 In , the output of the spatial attention sigmoid function is also connected to the input of the spatial attention multiplier. Figure 5 In , CF2 is the spatial attention multiplier. When using residual connection, the domain-invariant down-sampling feature sequence should be loaded into the spatial attention multiplier, and the spatial attention multiplier is used to perform matrix multiplication operation on the domain-invariant down-sampling feature sequence and the domain-invariant spatial attention mapping feature sequence, and generate the domain-invariant spatial multiplication feature sequence. Figure 5 In the above figure, D2 is the feature sequence after domain invariant space multiplication, and the feature dimension of the feature sequence after domain invariant space multiplication is L×C.
[0057] Figure 5An embodiment of the channel attention mechanism module is also shown. As can be seen from the figure, the channel attention mechanism module includes a channel attention pooling layer, a channel attention first convolution layer, a channel attention second convolution layer and a channel attention Sigmoid function. In the figure, Ch is the channel attention pooling layer, and the channel attention pooling layer can use average pooling for pooling operation. TJG1 is the channel attention first convolution layer, TJG2 is the channel attention second convolution layer, S2 is the channel attention Sigmoid function, and the convolution kernel size used in the channel attention first convolution layer and the channel attention second convolution layer can be 1.
[0058] When executing the channel attention mechanism, the channel attention pooling layer performs an average pooling operation on the domain-invariant downsampled feature sequence, and obtains the domain-invariant channel attention pooled feature sequence. Figure 5 In , E0 is the domain-invariant channel attention pooled feature sequence, and the feature dimension of the domain-invariant channel attention pooled feature sequence is 1×C. The domain-invariant channel attention pooled feature sequence is convolved through the first channel attention convolution layer to obtain the domain-invariant channel attention first convolution feature sequence after convolution. Figure 5 In , E1 is the feature sequence after the first convolution of the domain-invariant channel attention, and the feature dimension of the feature sequence after the first convolution of the domain-invariant channel attention is 1×(C / 2). The feature sequence after the first convolution of the domain-invariant channel attention is convolved through the second convolution layer of the channel attention to generate the feature sequence after the second convolution of the domain-invariant channel attention after the convolution. Figure 5 In , E2 is the feature sequence after the second convolution of the domain-invariant channel attention, and the feature dimension of the feature sequence after the second convolution of the domain-invariant channel attention is 1×C. The channel attention sigmoid function is used to perform channel attention mapping on the feature sequence after the second convolution of the domain-invariant channel attention, so as to generate a feature sequence after the domain-invariant channel attention mapping after the channel attention mapping. Figure 5 In , E3 is the feature sequence after domain-invariant channel attention mapping, and the feature dimension of the feature sequence after domain-invariant channel attention mapping is 1×C.
[0059] When the channel attention mechanism module adopts residual connection, it should also be connected to the channel attention multiplier through the channel attention sigmoid function. Figure 5 In the example, CF1 is the channel attention multiplier, which is composed of Figure 5 It can be seen that the domain-invariant down-sampling feature sequence should be loaded into the channel attention multiplier. After that, the channel attention multiplier is used to perform matrix multiplication operation on the domain-invariant down-sampling feature sequence and the domain-invariant channel attention mapping feature sequence, and generate the domain-invariant channel multiplication feature sequence. Figure 5In the figure, E4 is the feature sequence after domain-invariant channel multiplication, and the feature dimension of the feature sequence after domain-invariant channel multiplication is L×C.
[0060] In order to obtain the feature sequence after the domain-invariant attention mechanism, the feature sequence after the domain-invariant channel multiplication and the feature sequence after the domain-invariant spatial multiplication should be loaded into the matrix adder. Figure 5 In the example, Ad1 is a matrix adder, through which the elements corresponding to the feature sequence after domain-invariant channel multiplication and the feature sequence after domain-invariant space multiplication can be added, and after the corresponding elements are added, the feature sequence after the domain-invariant attention mechanism can be generated. Figure 5 In the figure, DE1 is the feature sequence after the domain-invariant attention mechanism, the channel dimension of the feature sequence after the domain-invariant attention mechanism is C, and the sequence dimension is L.
[0061] In one embodiment of the present invention, the regression prediction head includes a regression prediction splicer, a regression prediction convolution module and a regression prediction transposed convolution module connected in sequence, wherein: For any two regression prediction heads connected in series, along the direction of the connection, the regression prediction transposed convolution module of the previous regression prediction head is connected to the regression prediction splicer of the next regression prediction head; For any regression prediction head, when a jump connection is used, the output end of the domain-invariant feature extraction module of the corresponding jump connection is connected through the regression prediction splicer.
[0062] Figure 2 An embodiment of a regression prediction head is shown in FIG. As can be seen from the figure, the regression prediction head may include a regression prediction splicer, a regression prediction convolution module and a regression prediction transposed convolution module. At this time, when two regression prediction heads are connected in series, the regression prediction transposed convolution module of the previous regression prediction head is connected to the regression prediction splicer of the next regression prediction head, and in the case of a jump connection, it is connected to the output end of the domain invariant feature extraction module of the corresponding jump connection through the regression prediction splicer. Figure 2 In the example, HConv is the regression prediction convolution module, and HIConv is the regression prediction transposed convolution module, that is, Figure 2 The regression prediction splicer is not shown in the figure. In specific implementation, the regression prediction transposed convolution module can perform a transposed convolution operation.
[0063] In specific implementation, the regression prediction concatenator can be used to concatenate feature sequences in the channel dimension. For example, if the feature dimension of two feature sequences is L×C, then after concatenation in the channel dimension, the feature dimension of the feature sequence formed is L×2C. The regression prediction convolution module can adopt the same structural form as the above-mentioned domain invariant convolution module, and the above description can be referred to for details.
[0064] It should be noted that, in the regression prediction unit, the regression prediction head at the head of the series is the regression prediction head mentioned above. The connection between the regression prediction head and the domain invariant feature extraction module at the tail of the series does not use a jump connection. At this time, the domain invariant attention mechanism output by the domain invariant feature extraction module at the tail of the series should be directly loaded into the regression prediction convolution module at the regression prediction head at the head of the series. Therefore, for the regression prediction head at the head of the series, the regression prediction splicer can be omitted in the regression prediction head. Of course, the regression prediction splicer can also be retained, but the feature sequence after the domain invariant attention mechanism should be directly loaded into the regression prediction convolution module at the regression prediction head at the head of the series.
[0065] It should be understood that for other regression prediction heads, the regression prediction concatenator receives the feature sequence after the domain-invariant attention mechanism via the jump connection, and simultaneously receives the output of the concatenated regression prediction head.
[0066] In specific implementation, when the regression prediction head adopts the above-mentioned structural form, the nonlinear relationship of the quality parameters in the near-infrared spectral data to be tested can be captured by performing deep convolution operations through the regression prediction convolution module and the regression prediction transposed convolution module. Regression prediction is performed in sequence through multiple regression prediction heads, and the multi-scale spatial features to be tested can be output through the regression prediction head at the end of the series connection.
[0067] From the above description, it can be seen that the quality parameter detection model should be constructed first. Specifically, when constructing the quality parameter detection model, the construction method includes: Constructing a basic model for quality parameter detection, and preparing a basic model training data set for training the basic model for quality parameter detection, wherein: The quality parameter detection basic model also includes a reconstruction decoding unit and a discriminator, wherein the reconstruction decoding unit and the discriminator are adaptively connected to the domain invariant feature extraction unit; The basic model training data set includes a plurality of model data samples, wherein when preparing the basic model training data set, near infrared spectra of the training material are collected at different training collection distances to form a model data sample based on the collected training near infrared spectrum data and the quality label of the training material. The training substance and the substance to be tested belong to the same category of substances, and the training acquisition distance is also within the acquisition threshold of the multi-distance domain; The basic model training data set is divided into at least a training sample set and a verification sample set, so as to use the training sample set to perform model training on the basic model for multi-distance domain quality parameter detection, and use the verification sample set to perform model verification on the basic model for multi-distance domain quality parameter detection, wherein: When the training sample set is used to train the basic model of multi-distance domain quality parameter detection, in each batch training process, the domain invariant feature extraction unit, reconstruction decoding unit and regression prediction unit in the basic model of quality parameter detection are firstly trained, and then the discriminator is trained; The basic model for multi-distance domain quality parameter detection is trained to reach a target state, and after the basic model for multi-distance domain quality parameter detection is verified using a verification sample set, a multi-distance quality parameter detection model is formed based on the basic model for multi-distance domain quality parameter detection that has reached a target state through model training.
[0068] It should be noted that when constructing a quality parameter detection model, a quality parameter detection basic model should be constructed first. Different from the above-mentioned quality parameter detection model, the quality parameter detection basic model also includes a reconstruction decoding unit and a discriminator. Specifically, the reconstruction decoding unit and the discriminator are both adaptively connected to the domain invariant feature extraction unit; that is, in the construction training phase, the reconstruction decoding unit and the discriminator need to be used for model training, while in the inference phase, the reconstruction decoding unit and the discriminator need to be frozen. The following describes the reconstruction decoding unit and the discriminator separately.
[0069] In one embodiment of the present invention, the reconstruction decoding unit includes a plurality of reconstruction decoding modules connected in series, wherein: The number of reconstruction decoding modules in the reconstruction decoding unit is consistent with the number of domain invariant feature extraction modules in the domain invariant feature extraction unit; For any reconstruction decoding module, the reconstruction decoding module includes a reconstruction decoding splicer, a reconstruction decoding convolution module and a reconstruction decoding transposed convolution module connected in sequence, wherein: For any two reconstruction and decoding modules connected in series, along the direction of the series connection, the reconstruction and decoding transposed convolution module of the previous reconstruction and decoding module is connected to the reconstruction and decoding splicer in the next reconstruction and decoding module; When constructing the basic model for quality parameter detection, the domain invariant feature extraction module is jump-connected to the corresponding reconstruction decoding module, and when the jump connection is made, the reconstruction decoding splicer is connected to the output end of the domain invariant feature extraction module of the corresponding jump connection.
[0070] Specifically, the reconstruction decoding unit should include multiple reconstruction decoding modules, and the number of reconstruction decoding modules in the reconstruction decoding unit should be consistent with the number of domain invariant feature extraction modules in the domain invariant feature extraction unit, such as Figure 2 An embodiment in which the reconstruction decoding unit includes four reconstruction decoding modules connected in series is shown in FIG. Figure 2N in is the number of reconstruction decoding modules. The reconstruction decoding modules generally adopt the same structure. For example, any reconstruction decoding module should include a reconstruction decoding splicer, a reconstruction decoding convolution module, and a reconstruction decoding transposed convolution module. In specific implementation, when the reconstruction decoding unit is connected to the domain invariant feature extraction unit, it can be consistent with the connection between the regression prediction unit and the domain invariant feature extraction unit. For details, please refer to the corresponding connection description of the regression prediction unit and the domain invariant feature extraction unit, which will not be repeated here.
[0071] In specific implementation, the output end of the first domain invariant feature extraction module is connected to the fourth reconstruction decoding module through a jump connection, the output end of the second domain invariant feature extraction module is connected to the third reconstruction decoding module through a jump connection, the output end of the third domain invariant feature extraction module is connected to the second reconstruction decoding module through a jump connection, and the output end of the fourth domain invariant feature extraction module is connected to the first reconstruction decoding module, but no jump connection is used. For the specific jump connection, please refer to the corresponding description above. In addition, it can be seen from the above description that for the first reconstruction decoding module, the reconstruction decoding splicer can be omitted. The specific corresponding connection can refer to the corresponding description of the first retrospective prediction head above, which will not be repeated here.
[0072] When the reconstruction decoding module adopts the above-mentioned structural form, the convolution operation is performed through the reconstruction decoding convolution module, and the transposed convolution operation is performed through the reconstruction decoding transposed convolution module. Specifically, the upsampling operation is implemented through the transposed convolution operation of the reconstruction decoding transposed convolution module, and the dimension of the feature is gradually expanded to restore the spatial information of the input data. When the reconstruction decoding module and the corresponding domain invariant feature extraction module adopt a jump connection, the decoding module of this layer can use richer feature information for more accurate reconstruction.
[0073] In one embodiment of the present invention, the discriminator includes a discriminative first linear layer, a discriminative batch normalization layer, a discriminative Mish activation function, a discriminative second linear layer, and a discriminative Sigmoid activation function connected in sequence, wherein: When the discriminator is connected to the domain invariant feature extraction unit, the domain invariant feature extraction module at the end of the series connection is connected to the discriminant first linear layer of the discriminator.
[0074] Figure 2 An embodiment of a discriminator is shown in FIG. Figure 2 In the figure, XN3 is the discriminative first linear layer, BN1 is the discriminative batch normalization layer, M1 is the discriminative Mish activation function, XN4 is the discriminative second linear layer, and S1 is the discriminative Sigmoid activation function.
[0075] It should be noted that the discriminator can be used to determine whether the training domain invariant features generated by the domain invariant feature extraction unit are real features, thereby helping the quality parameter detection basic model to learn more accurate cross-domain feature representations. The discriminant Mish activation function introduces a nonlinear mapping relationship, and the discriminant Sigmoid activation function is used to predict the conversion function of the probability, mapping the output to the (0, 1) interval. In specific implementation, when the discriminator is connected to the domain invariant feature extraction unit, it specifically means that in the domain invariant feature extraction unit, the output end of the domain invariant feature extraction module at the end of the series connection is connected to the discriminant first linear layer of the discriminator.
[0076] It is understandable that when performing model training, a basic model training data set should be produced, and after producing the basic model training data set, model training should be performed on the quality parameter detection basic model. The basic model training data set should generally include multiple model data samples, wherein each model data sample should include a training near-infrared spectrum data and a quality label. Specifically, the training near-infrared spectrum data is generated by at least collecting near-infrared spectra of the training material. Therefore, the training near-infrared spectrum data can be consistent with the above-mentioned near-infrared spectrum data to be tested, and the quality label in the model data sample is the quality parameter of the training material.
[0077] In specific implementation, the training material and the material to be tested belong to the same category of materials. For example, when the material to be tested is bauxite, the training material should also be bauxite. In addition, when the near-infrared spectrum of the training material is collected, the corresponding training collection distance should also be within the collection threshold of the multi-distance domain, where the training collection distance is the distance corresponding to the near-infrared spectrum of the training material.
[0078] It should be noted that in order to achieve multi-distance domain generalization, the model data samples in the basic model training data set should cover multiple different training collection distances. The following takes bauxite as an example of training material and material to be tested to explain the method and process of making the basic model training data set. Specifically: 1336 bauxite samples with a particle size of 0.15 mm after crushing, grinding and sieving were collected, and each bauxite sample was placed on a near-infrared spectrum acquisition platform to collect near-infrared spectrum data of each bauxite sample. The near-infrared spectrum acquisition platform adopts VIAVI's MicroNIR Pro handheld near-infrared spectrometer. Specifically, the working parameters of the near-infrared spectrum acquisition platform can be set to: spectral wavelength range of 900-1700 nm, resolution of 6.24 nm, number of wavelength points of 125 at different intervals. In addition, the training acquisition distances of different bauxites are set to: 5mm, 10mm, 15mm, 20mm and 25mm respectively. Of course, the training acquisition distance can also be other situations, which can be selected according to needs.
[0079] From the above description, it can be seen that after placing the bauxite sample at the set training collection distance and using the near-infrared spectrum collection platform to collect near-infrared spectrum data, each near-infrared spectrum data should also be pre-processed by standard normal transformation, and the corresponding training near-infrared spectrum data can be obtained after pre-processing. In addition, for each bauxite sample, the corresponding quality parameters can be obtained by using the commonly used technical means in the technical field of this technology, so that the corresponding quality label can be determined, and a model training sample can be formed based on the training near-infrared spectrum data and the quality label.
[0080] When the training material is of other types, the corresponding basic model training data set can be constructed by referring to the above method, and examples will not be given one by one here.
[0081] In order to meet the training requirements, the basic model training data set can generally be divided into at least a training sample set and a verification sample set, so that the training sample set can be used to train the basic model for multi-distance domain quality parameter detection, and the verification sample set can be used to verify the basic model for multi-distance domain quality parameter detection; in addition, a test sample set can also be divided, such as the basic model training data set can be divided into a training sample set, a verification sample set and a test sample set in a ratio of 7:1:2. When dividing, it is necessary to follow the principle that the distance labels (domain labels) of the training set and the verification set do not overlap with the distance labels (domain labels) of the test set. For example, the training sample set and the verification sample set contain model data samples with training acquisition distances of 5mm, 10mm and 15mm, and the test sample set should only contain model data samples with training acquisition distances of 20mm and 25mm.
[0082] When training the basic model for quality parameter detection, the model training conditions should generally be set. The training of the basic model for quality parameter detection can be configured by setting the model training conditions, wherein the model training conditions may include a training loss function. Of course, the model training conditions may also include other necessary conditions, such as using an Adam optimizer with a regularization weight of 0.001, setting the initial learning rate to 0.0001, and using the ReduceLROnPlateau learning rate decay strategy to dynamically adjust the learning rate according to the loss value of the validation set. The size of each batch is 64, and the maximum number of iterations is set to 150.
[0083] Since the quality parameter detection basic model also includes a reconstruction decoding unit and a discriminator, in order to meet the needs of model training, the present invention adopts a phased training strategy. Specifically, for a batch of training samples in the training sample set, the parts except the discriminator are first trained, and then the discriminator is trained. This phased training method helps prevent the discriminator from being quickly saturated due to the overly simple output of the initial generator, thereby achieving continuous improvement in the performance of both parties in the two training stages and stable convergence of the model.
[0084] In specific implementation, after one round of model training of the quality parameter detection basic model using the training sample set, the quality parameter detection basic model after model training is verified using the validation sample set, and the learning rate is dynamically adjusted according to the validation set loss to achieve adaptive learning rate control. After 150 rounds of model training of the quality parameter detection basic model using the training sample set, a comprehensive performance evaluation of the trained quality parameter detection basic model is finally performed on the test set to quantitatively analyze its prediction accuracy and generalization ability.
[0085] It should be noted that after 150 rounds of model training for the quality parameter detection basic model, the quality parameter detection basic model after the 150th round of model training can generally be configured as a multi-distance quality parameter detection model, that is, the construction of a multi-distance domain quality parameter model is realized.
[0086] In one embodiment of the present invention, the training loss function adopts a comprehensive loss, including regression loss, reconstruction loss, maximum mean discrepancy (MMD) loss and adversarial loss. The calculation of the training loss function is specifically described below. Specifically, it can be seen from the above description that the regression prediction head and the commonly used structure of the reconstruction decoding module are basically the same, but the difference is that the regression prediction unit can obtain a numerical value with a feature dimension of 1 through the prediction output unit, that is, for each training sample in the training sample set, the corresponding quality parameter prediction value can be predicted by the prediction output unit, and the quality parameter prediction value is the numerical value with a feature dimension of 1.
[0087] For the reconstruction decoding unit, a reconstruction decoding linear layer is set in the reconstruction decoding module at the end of the series connection. Figure 2 XN2 in the above is the reconstruction decoding linear layer, through which near infrared spectrum reconstruction can be realized, that is, reconstructed near infrared spectrum data can be generated through the reconstruction decoding linear layer, and the feature dimension of the reconstructed near infrared spectrum data is consistent with the feature dimension of the training near infrared spectrum data, both of which are L×1. The reconstruction decoding linear layer can adopt the existing commonly used form, which can meet the requirements of generating reconstructed near infrared spectrum data.
[0088] The regression loss is used to calculate the difference between the predicted value of the quality parameter output by the prediction output unit and the quality label corresponding to each training sample, which is:
[0089] in, is the regression loss, N is the total number of training samples in the training sample set, Indicates i The quality parameter prediction value output by the regression prediction unit for each training sample is: Indicates i The actual value of the quality parameter of the training samples.
[0090] Specifically, no. i The actual value of the quality parameter of the training samples Through the i The quality labels of the training samples are directly obtained. Therefore, Figure 2 The regression loss in is the regression loss calculation using the quality parameter prediction value output by the regression prediction unit.
[0091] The reconstruction loss is used to calculate the difference between the reconstructed near-infrared spectral data restored by the reconstruction decoding unit and the training samples loaded into the domain invariant feature extraction unit, which is:
[0092] in, To rebuild the losses, Indicates that based on i The reconstructed near-infrared spectral data generated by the training samples are k The reconstructed value of wavelength points, Indicates i The training samples are k The near-infrared spectrum value of the wavelength point is m, which is the number of wavelength points in the training near-infrared spectrum data, that is, the number of sampling points of the training near-infrared spectrum data. Generally, m should be consistent with the above-mentioned L.
[0093] Figure 2 The reconstruction loss in is the reconstruction loss calculation using the reconstructed near-infrared spectrum data generated by the reconstruction decoding unit.
[0094] The MMD loss is used to calculate the difference between the training near-infrared spectral data of different distance domains input into the domain-invariant feature extraction unit, and the domain-invariant feature extraction unit outputs the corresponding training domain-invariant features, so as to promote the quality parameter detection basic model to learn a domain-invariant feature space. For example, if the collection distance of one training sample is 5 mm and the collection distance of another training sample is 10 mm, then the MMD loss is to calculate the difference between the corresponding training domain-invariant features formed by the two training samples after the domain-invariant feature extraction, and the calculation formula is:
[0095] in, is the MMD loss, and Represents training samples i and training samples j The training near infrared spectral data is extracted by the domain invariant feature extraction unit to output the training domain invariant features. and Represents training samples i and training samples j The distance domain label to which it belongs,
[0096] in, represents the Euclidean norm, where represents the square of the difference in feature centers between the two domains. Assuming that the feature centers of the two distance domains are and , then the calculation formula of the norm is:
[0097] and Indicates that the two distance domains are k The characteristic mean at the wavelength points. represents the mathematical expectation, and express and The distribution of the distance domain. and Represents the distance domain and The feature map values of all samples in and Take the average value, for the sample feature set in each domain , .
[0098] For each wavelength point , and use, for example, the RBF kernel function to map it into a high-dimensional feature space. In this feature space, Each component of represents the similarity with a specific center point. Suppose there is a set of center points , then the mapping of the RBF kernel function can be expressed as,
[0099] in, Usually, the sampling wavelength points are selected from the training samples or fixed, then: , is the hyperparameter of the RBF kernel function.
[0100] It should be noted that, when performing the above mapping, in addition to the above RBF kernel function, other mapping functions may also be used, which will not be described one by one here.
[0101] When calculating the adversarial loss, it is necessary to load the adversarial discriminant features into the discriminator. The calculation method is:
[0102] in, To combat losses, represents the discriminator, represents the adversarial discriminative features input to the discriminator, is the label state corresponding to the adversarial discriminant feature. The adversarial discriminant feature is a true discriminant feature or a false discriminant feature. When the adversarial discriminant feature is a true discriminant feature, the label state corresponding to the adversarial discriminant feature is is 1. When the adversarial discriminant feature is a false discriminant feature, the label state corresponding to the adversarial discriminant feature is is 0.
[0103] It should be noted that the true discriminant feature is the feature sequence after the domain-invariant attention mechanism loaded by the domain-invariant feature extraction unit at the end of the concatenation, and the false discriminant feature is the feature generated by simulating the feature sequence after the domain-invariant attention mechanism using normal distribution. Therefore, Figure 2 The normal distribution in , specifically means that the false discriminant features conform to the normal distribution. From the above description, it can be seen that when training the model, N domain-invariant attention mechanism feature sequences should be formed, that is, when calculating the adversarial loss, the number of true discriminant features is N, so the number of false discriminant features should also be N. It is the discriminant value output by the discriminator of the adversarial discriminant feature.
[0104] It should be understood that adversarial learning can be achieved through the above-mentioned adversarial loss. After adversarial learning, the quality detection basic model can drive the unseen domain invariant features extracted from the real discriminant features to tend towards a normal distribution.
[0105] It should be noted that when adopting staged training, the discriminator is frozen in the first step, and the regression loss, reconstruction loss, and maximum mean difference loss can be calculated, but the adversarial loss is not calculated; the discriminator is unfrozen in the second step, and the adversarial loss can be calculated thereafter. In specific implementation, when the training loss function adopts the MMD loss, the distance invariant spectral features can be extracted through the dynamic domain confusion mechanism, and the quality parameter detection model generated by forcing the construction can establish a nonlinear mapping relationship between near-infrared spectral data and material quality parameters.
[0106] Specifically, when the MMD loss is combined with the dynamic domain confusion mechanism, its core goal is to force the quality parameter detection basic model to ignore the differences in near-infrared spectral data in different acquisition distance domains through adversarial training, thereby extracting features with cross-domain consistency. Specifically, "dynamic domain confusion" refers to the continuous adjustment of the feature space mapping during the training process, so that the feature distributions between distance domains gradually overlap, and the MMD distance of the distance domain features is calculated in real time, and the distance is minimized and optimized during back propagation, which is equivalent to pushing the distance domain features closer in the latent space; at the same time, this confusion process is dynamically adaptive to avoid overfitting caused by the bias of a single batch of samples. Finally, the extracted "distance invariant spectral features" are manifested as: the relative distances of the feature vectors of the same substance in different distance domains in high-dimensional space are close, even if the near-infrared spectral data is nonlinearly distorted due to the acquisition distance, its deep features can still maintain discriminability, thereby improving the robustness of cross-domain prediction.
[0107] It should be noted that the dynamic domain obfuscation mechanism specifically refers to the structure of the quality parameter detection basic model and the above-mentioned method of model training for the quality parameter detection basic model. When the quality parameter basic model is verified using the verification sample set, only the regression loss is calculated, and the learning rate used in training is adaptively adjusted using the calculated regression loss, such as using the ReduceLROnPlateau learning rate decay strategy to dynamically adjust the learning rate according to the loss value of the verification set.
[0108] From the above description, it can be seen that after the model is trained in the above manner and the target state is reached, a quality parameter detection model can be obtained, after which the quality parameter detection model can be used for rapid detection.
[0109] In summary, a rapid detection system based on NIR and multi-distance domain generalization can be obtained, including a rapid detection processing device, wherein a quality parameter detection model is deployed in the rapid detection processing device; The rapid detection processing device uses the above-mentioned rapid detection method to perform quality detection processing on the near-infrared spectrum data of the substance to be detected, so as to output the quality parameters of the substance to be detected after the quality detection processing.
[0110] Specifically, the rapid detection processing device can use existing commonly used computer equipment, and the quality parameter detection model can be constructed in the above manner and deployed in the rapid detection processing device in a manner commonly used in the technical field. Thereafter, the rapid detection processing device can be used to perform the above rapid detection, and the method of rapid detection can refer to the above description, which will not be repeated here.
[0111] From the above description, it can be seen that in the prior art, the traditional deep learning model directly establishes the correlation between spectrum and component through end-to-end mapping, but its essential defect is that it does not consider the influence of the inevitable sampling distance fluctuation on the spectral distribution in industrial scenarios. When the traditional deep learning model is directly applied to the unknown distance domain after being trained in the fixed distance domain, the distance-related noise patterns such as the intensity attenuation and baseline drift of the spectral signal are highly coupled with the characteristics of the material composition, and the traditional deep learning model will produce systematic prediction deviations due to the mismatch of the inter-domain distribution.
[0112] In order to break through this bottleneck, the quality parameter detection model of the present invention forces the domain-invariant feature extraction unit to strip off distance-sensitive information through a generative adversarial mechanism, and uses the discriminator to dynamically distinguish domain labels to guide the quality parameter detection basic model to learn cross-domain invariant spectral representation; at the same time, the MMD loss is introduced to explicitly constrain the alignment of multi-distance domain feature distributions in the high-dimensional reproducing kernel Hilbert space, and the above-mentioned RBF kernel function is combined to capture the differences in high-order statistics, so as to achieve progressive adaptation of near-infrared spectral data at different acquisition distances, which can be used to solve the problem of changes in spectral acquisition distance in near-infrared detection technology, breaking through the strong dependence of the traditional single-domain modeling paradigm on the sampling distance, and providing an essential technical breakthrough for online detection in complex industrial environments.
[0113] The above schematically describes the invention and its implementation methods, which is not restrictive. Without departing from the spirit or basic features of the invention, the invention can be implemented in other specific forms. What is shown in the accompanying drawings is only one of the implementation methods of the invention. The actual structure is not limited thereto, and any figure mark in the invention should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, without departing from the purpose of the invention, a structural method and an embodiment similar to the technical solution are designed without creativity, which should all belong to the protection scope of the invention. In addition, the word "including" does not exclude other elements or steps, and the word "one" before the element does not exclude the inclusion of "multiple" elements. The multiple elements stated in the product claim can also be implemented by one element through software or hardware. The words first, second, etc. are used to indicate the name, and do not indicate any specific order.
Claims
1. A fast detection method based on NIR and multi-distance domain generalization, characterized in that: The rapid detection method comprises: Providing near infrared spectrum data of the substance to be tested, and loading the near infrared spectrum data to be tested into the constructed quality parameter detection model, so as to use the quality parameter detection model to perform quality detection processing on the near infrared spectrum data to be tested, and generating the quality parameters of the substance to be tested after the quality detection processing, wherein, When providing the near infrared spectrum data to be tested, it at least includes collecting the near infrared spectrum of the substance to be tested, wherein when collecting the near infrared spectrum of the substance to be tested, the collecting distance is within the collecting threshold of the multiple distance domains; During the quality detection process, at least domain invariant feature extraction and multi-scale spatial feature extraction and prediction are performed, wherein: The quality parameter detection model first performs domain-invariant feature extraction on the near-infrared spectral data to be tested to obtain the domain-invariant features of the near-infrared spectral data to be tested. Thereafter, the domain-invariant features to be tested are subjected to multi-scale spatial feature extraction and prediction processing to generate the quality parameters of the substance to be tested.
2. The rapid detection method based on NIR and multi-distance domain generalization according to claim 1 is characterized in that: The quality parameter detection model includes a detection linear layer, a domain invariant feature extraction unit, a regression prediction unit and a prediction output unit, wherein: The detection linear layer is connected to the domain invariant feature extraction unit, and the domain invariant feature extraction unit is adaptively connected to the regression prediction unit; When performing quality inspection, the detection linear layer is used to perform linear transformation on the near-infrared spectrum data to be inspected, and the near-infrared spectrum transformation data to be inspected obtained by the linear transformation is loaded into the domain invariant feature extraction unit; The domain-invariant feature extraction unit is used to extract domain-invariant features from the near-infrared spectrum transformation data to be inspected, and the domain-invariant features to be inspected obtained by the domain-invariant feature extraction are loaded into the regression prediction unit; The regression prediction unit is used to perform multi-scale spatial feature extraction and prediction processing on the invariant features of the to-be-tested domain, and the obtained multi-scale spatial features to be tested are loaded into the prediction output unit; Based on the received multi-scale spatial features of the substance to be tested, the prediction output unit outputs the quality parameters of the substance to be tested.
3. The rapid detection method based on NIR and multi-distance domain generalization according to claim 2 is characterized in that: The domain invariant feature extraction unit includes a plurality of domain invariant feature extraction modules connected in series, wherein the domain invariant feature extraction module at the head of the series connection is connected to the detection linear layer; The regression prediction unit comprises a plurality of regression prediction heads connected in series, wherein the number of the regression prediction heads in the regression prediction unit is consistent with the number of the domain invariant feature extraction modules in the domain invariant feature extraction unit, wherein the regression prediction head at the end of the series connection is adaptively connected to the prediction output unit; In the quality parameter detection model, each domain-invariant feature extraction module is jump-connected to the corresponding regression prediction head.
4. The rapid detection method based on NIR and multi-distance domain generalization according to claim 3 is characterized in that: The domain-invariant feature extraction module includes a domain-invariant convolution module, a domain-invariant downsampling module, and a spatial channel attention module connected in sequence, wherein: For any two domain-invariant feature extraction modules connected in series, along the direction of the series connection, the output end of the spatial channel attention module in the previous domain-invariant feature extraction module is connected to the domain-invariant convolution module in the next domain-invariant feature extraction module; For any domain-invariant feature extraction module, the output end of the spatial channel attention module in the domain-invariant feature extraction module is connected to the corresponding regression prediction head through a skip connection; When performing domain-invariant feature extraction, for any domain-invariant feature extraction module, the domain-invariant feature sequence to be extracted loaded into the current domain-invariant feature extraction module is convolved using the domain-invariant convolution module to extract local features of the domain-invariant feature sequence to be extracted, and generate a domain-invariant convolved feature sequence; A domain-invariant downsampling module is used to downsample the domain-invariant convolution feature sequence to generate a domain-invariant downsampled feature sequence, wherein the feature dimension of the domain-invariant downsampled feature sequence is lower than the feature dimension of the domain-invariant convolution feature sequence; The spatial channel attention module is used to perform attention mechanism processing on the domain-invariant down-sampling feature sequence to generate a domain-invariant post-attention mechanism feature sequence after the attention mechanism processing.
5. The rapid detection method based on NIR and multi-distance domain generalization according to claim 4 is characterized in that: The domain invariant convolution module includes at least two domain invariant convolution submodules connected in series, wherein: For any domain-invariant convolution submodule, the domain-invariant convolution submodule includes a domain-invariant sub-block convolution layer, a domain-invariant batch normalization layer, and a domain-invariant sub-block Mish activation function; When any two domain-invariant convolutional submodules are connected in series, along the direction of the connection, the domain-invariant subblock Mish activation function of the previous domain-invariant convolutional submodule is connected to the domain-invariant subblock convolutional layer in the next domain-invariant convolutional submodule; In the domain-invariant feature extraction module, the domain-invariant convolution submodule at the end of the concatenation is connected to the domain-invariant downsampling module through the corresponding domain-invariant sub-block Mish activation function.
6. The rapid detection method based on NIR and multi-range domain generalization according to claim 4 is characterized in that: The spatial channel attention module includes a spatial attention mechanism module using residual connection and a channel attention mechanism module using residual connection, wherein: Using the spatial attention mechanism module to perform spatial attention mechanism processing on the domain-invariant down-sampled feature sequence, so as to generate a domain-invariant spatial attention processed feature sequence after the spatial attention mechanism processing; A channel attention mechanism module is used to perform channel attention mechanism processing on the domain-invariant down-sampling feature sequence, so as to generate a domain-invariant channel attention processed feature sequence after the channel attention mechanism processing; Performing a matrix multiplication operation on the feature sequence after the domain-invariant spatial attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant spatial multiplication feature sequence after the matrix multiplication operation; Performing a matrix multiplication operation on the feature sequence after the domain-invariant channel attention processing and the feature sequence after the domain-invariant downsampling, so as to generate a domain-invariant channel multiplied feature sequence after the matrix multiplication operation; A matrix addition operation is performed on the feature sequence after the domain-invariant spatial multiplication and the feature sequence after the domain-invariant channel multiplication to generate a feature sequence after the domain-invariant attention mechanism after the matrix addition operation.
7. The rapid detection method based on NIR and multi-distance domain generalization according to claim 3 is characterized in that: The regression prediction head includes a regression prediction splicer, a regression prediction convolution module and a regression prediction transposed convolution module connected in sequence, wherein: For any two regression prediction heads connected in series, along the direction of the connection, the regression prediction transposed convolution module of the previous regression prediction head is connected to the regression prediction splicer of the next regression prediction head; For any regression prediction head, when a jump connection is used, the output end of the domain-invariant feature extraction module of the corresponding jump connection is connected through the regression prediction splicer.
8. The rapid detection method based on NIR and multi-distance domain generalization according to any one of claims 3 to 7, characterized in that: When building a quality parameter detection model, the construction method includes: Constructing a basic model for quality parameter detection, and preparing a basic model training data set for training the basic model for quality parameter detection, wherein: The quality parameter detection basic model also includes a reconstruction decoding unit and a discriminator, wherein the reconstruction decoding unit and the discriminator are adaptively connected to the domain invariant feature extraction unit; The basic model training data set includes a plurality of model data samples, wherein when preparing the basic model training data set, near infrared spectra of the training material are collected at different training collection distances to form a model data sample based on the collected training near infrared spectrum data and the quality label of the training material. The training substance and the substance to be tested belong to the same category of substances, and the training acquisition distance is also within the acquisition threshold of the multi-distance domain; The basic model training data set is divided into at least a training sample set and a verification sample set, so as to use the training sample set to perform model training on the basic model for multi-distance domain quality parameter detection, and use the verification sample set to perform model verification on the basic model for multi-distance domain quality parameter detection, wherein: When the training sample set is used to train the basic model of multi-distance domain quality parameter detection, in each batch training process, the detection linear layer, domain invariant feature extraction unit, prediction output unit, reconstruction decoding unit and regression prediction unit in the basic model of quality parameter detection are firstly trained, and then the discriminator is trained; The basic model for multi-distance domain quality parameter detection is trained to reach a target state, and after the basic model for multi-distance domain quality parameter detection is verified using a verification sample set, a quality parameter detection model is formed based on the basic model for multi-distance domain quality parameter detection that has reached a target state through model training.
9. The rapid detection method based on NIR and multi-distance domain generalization according to claim 8, characterized in that: The reconstruction decoding unit includes a plurality of reconstruction decoding modules connected in series, wherein: The number of reconstruction decoding modules in the reconstruction decoding unit is consistent with the number of domain invariant feature extraction modules in the domain invariant feature extraction unit; For any reconstruction decoding module, the reconstruction decoding module includes a reconstruction decoding splicer, a reconstruction decoding convolution module and a reconstruction decoding transposed convolution module connected in sequence, wherein: For any two reconstruction and decoding modules connected in series, along the direction of the series connection, the reconstruction and decoding transposed convolution module of the previous reconstruction and decoding module is connected to the reconstruction and decoding splicer in the next reconstruction and decoding module; When constructing the basic model for quality parameter detection, the domain invariant feature extraction module is jump-connected to the corresponding reconstruction decoding module, and when the jump connection is made, the reconstruction decoding splicer is connected to the output end of the domain invariant feature extraction module of the corresponding jump connection.
10. A fast detection system based on NIR and multi-range domain generalization, characterized in that: It includes a rapid detection and processing device, wherein a quality parameter detection model is deployed in the rapid detection and processing device; For the near-infrared spectrum data to be tested of the substance to be tested, the rapid detection processing device adopts the rapid detection method described in any one of claims 1 to 9 to perform quality detection processing, so as to output the quality parameters of the substance to be tested after the quality detection processing.
Citation Information
Patent Citations
Infrared weak target detection method based on anti-fact causal learning
CN114972869A
Attention-based subdomain adaptive hyperspectral image classification method and system
CN115311499A
Domain adaptation method using residual attention module
CN115578593A
Garbage category grabbing, classifying and identifying method and system
CN117688466A
Bauxite quality parameter parallel detection method based on TC-Unet
CN119619049A
Cited By
Multi-quality parameter cooperative detection method and system based on near infrared spectrum
CN120142228A