Cross-device quality parameter detection model construction method based on unsupervised domain adaptation

By constructing a cross-device quality parameter detection model based on unsupervised domain adaptation, the problem of model performance degradation caused by spectrometer differences is solved, and efficient and low-cost detection of bauxite quality parameters is achieved under label-free conditions.

CN121071497BActive Publication Date: 2026-02-24CHINA CERTIFICATION & INSPECTION (GROUP) CO LTD HEBEI BRANCH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511634026.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-11-10
Publication Date
2026-02-24
Estimated Expiration
2045-11-10

AI Technical Summary

Technical Problem

Existing technologies for bauxite quality testing suffer from severe performance degradation when models are applied across different instruments due to differences in spectrometers. Furthermore, a large number of labeled samples are required for model reconstruction, resulting in high costs and low efficiency.

Method used

An unsupervised, domain-adaptive cross-device quality parameter detection model is constructed. By building a model that includes a feature extraction network, a task predictor, a domain discriminator, and an alignment processing module, and using source and target domain data for unsupervised training, cross-device quality parameter detection is achieved.

Benefits of technology

Without the need for target domain labels, it significantly reduces modeling costs and time, improves the reliability and accuracy of detection, and enables cross-device quality parameter detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121071497B_ABST
    Figure CN121071497B_ABST
Patent Text Reader

Abstract

The application relates to a cross-device quality parameter detection model construction method based on unsupervised domain adaptation. The method comprises the following steps: constructing a quality parameter detection basic model, and constructing a training data set for training the quality parameter detection basic model; when the training data set is used for model training of the quality parameter detection basic model, at least an unsupervised domain adaptation training method is used, and a corresponding quality parameter detection target model is generated after model training; when quality parameter detection is performed, near-infrared spectrum data of a sample to be detected is acquired, and the near-infrared spectrum data of the sample to be detected is loaded into the quality parameter detection target model, so that the quality parameter detection target model is used to predict and output quality parameter information of the sample to be detected. The application can effectively solve the technical bottleneck that the performance of a model is seriously reduced when the model is applied across devices due to differences between spectrometers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a model building method, and more particularly to a cross-device quality parameter detection model building method based on unsupervised domain adaptation. Background Technology

[0002] Bauxite, a key mineral supporting strategic industries such as defense technology, aerospace, and electronic components, has an alumina content that directly determines the energy efficiency of electrolytic aluminum production and the performance of end materials, making it a core indicator for measuring bauxite quality. China's annual bauxite imports have exceeded 159 million tons, with over 90% relying on Guinea and Australia. As the grade fluctuations of imported ore become increasingly prominent, enhancing the ability to independently, in real-time, and online analyze bauxite quality is a crucial means to optimize resource allocation, improve resource utilization, and ensure the independent control of strategic resources.

[0003] Currently, industrial testing largely relies on wet chemical analysis, which, while highly accurate, is time-consuming, complex, and expensive. Modern technologies such as X-ray fluorescence spectroscopy, laser-induced breakdown spectroscopy, and neutron activation analysis have made breakthroughs in efficiency and accuracy, but still face limitations such as high equipment costs and cumbersome sample pretreatment. Therefore, they cannot meet the real-time requirements of trade screening and production control. Near-infrared spectroscopy, with its advantages of non-contact, non-destructive testing, fast response, and online integration, has been widely used in agriculture, food, pharmaceuticals, and environmental monitoring, and has shown great potential in the detection of bauxite components.

[0004] With advancements in computer science and chemometrics, deep learning models, with their powerful nonlinear feature extraction and noise suppression capabilities, have greatly propelled the development of NIRS (Near-Infrared Spectroscopy) technology, demonstrating performance superior to traditional chemometric methods in the precise detection of various complex systems. However, when these advanced models are applied to real-world industrial scenarios, a significant challenge emerges: instrument heterogeneity. Differences in the optical and electronic characteristics of near-infrared spectrometers of different models, batches, or even operating conditions lead to significant distribution shifts in the acquired spectral data. Consequently, the performance of a deep model trained on a source-domain instrument degrades when directly transferred to a target-domain instrument.

[0005] Understandably, to adapt to near-infrared spectral data acquired by instruments in the target domain, new depth models should be constructed. However, constructing these models requires acquiring a large number of labeled samples. This necessitates time-consuming, labor-intensive, and costly laboratory analysis, thereby increasing detection costs. Therefore, effectively constructing depth models in the absence of target domain labels is a pressing technical challenge that needs to be addressed. Summary of the Invention

[0006] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation. This method can effectively solve the technical bottleneck of severe performance degradation when the model is applied across devices due to differences in spectrometers. The entire construction process does not require sample labels for the target domain, which significantly reduces the cost and cycle of modeling, improves the reliability and accuracy of quality parameter detection, and provides important support for the widespread application of near-infrared spectroscopy technology in industrial settings.

[0007] According to the technical solution provided by this invention, a method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation is provided, the method comprising:

[0008] A basic model for quality parameter detection is constructed, and a training dataset is built for training the basic model for quality parameter detection, wherein,

[0009] The training dataset includes a source domain dataset created based on a source domain spectrometer and a target domain dataset created based on a target domain spectrometer.

[0010] The source domain dataset includes several source domain training samples. Each source domain training sample includes source domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the source domain training sample based on the source domain spectrometer, as well as source domain quality parameter labels characterizing the corresponding quality parameters of the source domain training sample.

[0011] The target domain dataset includes several target domain training samples, and each target domain training sample includes target domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the target domain training sample based on a target domain spectrometer.

[0012] When training the basic model for quality parameter detection using the training dataset, at least an unsupervised domain adaptation training method should be used, and a corresponding target model for quality parameter detection should be generated after the model is trained.

[0013] During quality parameter detection, the near-infrared spectral data of the sample to be tested is acquired and loaded into the quality parameter detection target model, so as to use the quality parameter detection target model to predict and output the quality parameter information of the sample to be tested.

[0014] The basic model for quality parameter detection includes at least a feature extraction network, a task predictor, a domain discriminator, and an alignment processing module.

[0015] When training a model using an unsupervised domain adaptation training method, each round of model training includes a forward propagation phase and a backpropagation phase.

[0016] The forward propagation phase of each round of model training includes:

[0017] Source domain training samples and target domain training samples are loaded into the feature extraction network in batches so that the feature extraction network can perform deep feature extraction and generate batch deep feature sets. The batch deep feature sets include source domain depth features corresponding to the source domain training near-infrared spectral data in each source domain training sample, and target domain depth features corresponding to the target domain near-infrared spectral data in each target domain training sample.

[0018] A task predictor is used to perform task prediction on the batch deep feature set to generate a batch quality parameter prediction set. Simultaneously, a domain discriminator is used to perform domain discrimination on the batch deep feature set to generate a batch domain category set.

[0019] The batch quality parameter prediction set includes the predicted source domain quality parameters corresponding to each source domain depth feature and the predicted target domain quality parameters corresponding to each target domain depth feature;

[0020] The batch domain category set includes source domain category information corresponding to each source domain depth feature and target domain category information corresponding to each target domain depth feature;

[0021] Based on the current batch depth feature set and batch quality parameter prediction set, the alignment processing module performs local feature distribution matching processing based on a local fine alignment strategy to generate a batch local alignment feature set after local feature distribution matching processing.

[0022] The batch local alignment feature set includes several local alignment feature pairs, each of which includes weighted source domain features and weighted target domain features.

[0023] The feature dimensions of the weighted source domain features and the weighted target domain features are consistent with the feature dimensions of the source domain deep features and the target domain deep features.

[0024] The backpropagation phase of each round of model training includes:

[0025] Calculate the model training loss for the current round, which includes at least the source domain task prediction loss, domain adversarial loss, and selective alignment loss. Update the network parameters of the quality parameter detection base model based on the model training loss.

[0026] The source domain task prediction loss is calculated and generated based on the predicted values ​​of source domain quality parameters and the corresponding source domain quality parameter labels in all batch quality parameter prediction sets.

[0027] Domain adversarial loss is calculated and generated based on all batch domain category sets;

[0028] The selective alignment loss is calculated based on the local alignment feature set of all batches.

[0029] When performing local feature distribution matching based on a local fine alignment strategy and generating batch locally aligned feature sets, the alignment processing module includes at least sequential sample screening and feature selection processes.

[0030] When performing sample screening, based on the source domain quality parameter labels of all source domain training samples in the current batch, the predicted values ​​of target domain quality parameters in the current batch quality parameter prediction set are screened to obtain several predicted values ​​of target domain quality parameters that match the source domain quality parameter labels of the current batch. A target domain screening sample set is formed based on all the screened target domain quality parameter prediction values, wherein each screened target domain quality parameter prediction value forms a screening sample in the target domain screening sample set.

[0031] When performing feature selection processing, the target domain depth features corresponding to each selected sample in the target domain selection sample set are obtained, and the source domain depth features that match the target depth features of the selected samples are obtained.

[0032] The target domain depth features and the source domain depth features that match the target domain depth features are weighted and aligned to generate weighted target domain features and weighted source domain features respectively after weighted alignment. The generated weighted target domain features and weighted source domain features are then used as a local aligned feature pair.

[0033] When performing sample filtering and generating the target sample set, the process includes sequential global output consistency filtering and local feature-output consistency filtering.

[0034] When performing global output consistency filtering, the following are included:

[0035] Based on the source domain quality parameter labels of all source domain training samples in the current batch, calculate the source domain label mean and source domain label standard deviation;

[0036] For any predicted value of a target domain quality parameter within the batch quality parameter prediction set, if the predicted value of the target domain quality parameter satisfies the global output consistency screening condition, then the target domain training sample corresponding to the predicted value of the target domain quality parameter is configured as an initial subsample.

[0037] When the predicted values ​​of the target domain quality parameters meet the global output consistency screening criteria, then:

[0038] ,

[0039] in, For the predicted values ​​of quality parameters in the target domain, The average value of the source domain labels. The standard deviation of the source domain labels. This is the absolute value of the difference between the predicted value of the quality parameter of the target domain and the mean value of the label of the source domain.

[0040] When performing local feature-output consistency filtering, the following is included:

[0041] For any initial subsample, obtain the target domain depth feature corresponding to the initial subsample;

[0042] The acquired target domain depth features are matched with the source domain depth features in the batch depth feature set to determine the source domain depth features that match the target domain depth features, and the source domain training samples corresponding to the determined source domain depth features are configured as source domain matching samples.

[0043] The predicted target domain quality parameters of the initially selected subsamples are compared with the source domain quality parameter labels of the source domain matching samples using confidence level screening. When the confidence level screening passes, the initially selected subsamples are configured as a screening sample.

[0044] When performing confidence level filtering, we have:

[0045] If the initial subsamples satisfy the local feature-output consistency screening condition, then:

[0046]

[0047] in, The source domain quality parameter labels for the samples matched to the source domain. The confidence threshold. This is the absolute value of the difference between the predicted value of the target domain quality parameter and the source domain quality parameter label of the matching sample in the source domain.

[0048] Feature matching processing includes:

[0049] For each initially selected subsample, calculate the Euclidean distance between the target domain depth feature and all source domain depth features in the current batch depth feature set;

[0050] The source domain depth feature corresponding to the minimum Euclidean distance is configured as the source domain depth feature that matches the target domain depth feature.

[0051] When performing weighted alignment of the target domain depth features and the source domain depth features that match the target domain depth features, the following steps are included:

[0052] Calculate the L1 distance between the target domain depth features and the corresponding source domain depth features to obtain the difference vector representing the L1 distance of the features;

[0053] The difference vector is input into the weight generation network to generate a dynamic weight vector.

[0054] The target domain depth features and source domain depth features are respectively multiplied by the generated dynamic weight vector using the Hadamard product to generate weighted target domain features and weighted source domain features, respectively.

[0055] When using a weight generation network to generate dynamic weight vectors, we have:

[0056]

[0057] in, For dynamic weight vectors, For the difference vector, , All are fully connected layers. This is a non-linear activation function used to enable the weight generation network to learn more complex feature difference relationships. for An activation function is used to normalize the output values ​​of the weight generation network to the (0,1) interval to form the final weighting coefficients.

[0058] When updating the network parameters of the basic model based on the model training loss to detect quality parameters, the following are included:

[0059] The network parameters of the feature extraction network are updated based on source domain task prediction loss, domain adversarial loss, and selective alignment loss.

[0060] When updating the network parameters of the feature extraction network based on the domain adversarial loss, at least the gradient inversion processing of the domain adversarial loss should be performed, and when updating the network parameters of the feature extraction network, the update direction should be configured to maximize the domain adversarial loss.

[0061] The quality parameter detection target model includes a feature extraction network and a task predictor. During quality parameter detection, the near-infrared spectral data to be detected is loaded into the feature extraction network within the quality parameter detection target model, and the quality parameter information of the sample to be detected is output by the task predictor.

[0062] Regarding the domain adversarial loss, we have:

[0063]

[0064] in, The number of training samples in the source domain. The number of training samples for the target domain. For the domain discriminator to distinguish the first Each source domain deep feature Source domain category information, For the domain discriminator to distinguish the first Deep features of each target domain Target domain category information;

[0065] For the selective alignment loss, we have:

[0066]

[0067] in, For selective alignment loss, For MMD loss function, For regularization loss, This represents the total number of locally aligned feature pairs generated after each round of model training. The dimension of the dynamic weight vector. To form the first The dynamic weight vector used in the local alignment feature pair Each weight value For the first Weighted source domain features within each local alignment feature pair No. Weighted target domain features within each local alignment feature pair To weighted source domain features Weighted target domain features Gaussian kernel function operation , This is the loss weighting coefficient.

[0068] When updating the network parameters of the basic model for quality parameter detection, the following is also included:

[0069] The source domain task prediction loss is used to update the network parameters of the task predictor first, and then the source domain task prediction loss is propagated to the feature extraction network.

[0070] First, the network parameters of the domain discriminator are updated using the domain adversarial loss. Then, the domain adversarial loss after gradient inversion is propagated to the feature extraction network. When updating the network parameters of the domain discriminator, the update direction is configured to minimize the domain adversarial loss.

[0071] Using the MMD loss function and regularization loss First, update the network parameters of the weight generation network within the alignment processing module. Then, apply the MMD loss function. Backpropagation is performed to the feature extraction network;

[0072] The network parameters of the feature extraction network are jointly updated based on the source domain task prediction loss, the domain adversarial loss of gradient inversion, and the source domain task prediction loss.

[0073] The advantages of this invention are: the alignment processing module enables sample screening and feature selection, and the basic model for quality parameter detection can effectively avoid negative transfer problems caused by sample heterogeneity; simultaneously, the dynamic weighting mechanism, achieved through dynamic weight vectors, effectively mitigates feature information loss caused by domain-specific artifacts such as instrument noise. Therefore, the basic model for quality parameter detection can ultimately learn domain-invariant features, achieving effective cross-instrument transfer of the basic model for quality parameter detection.

[0074] From the perspective of application cost and promotion value, this invention overcomes the limitations of traditional methods that require the time-consuming and expensive re-modeling or correction of a large number of labeled samples when replacing or adding instruments. It can achieve knowledge transfer from the source domain to the target domain under unsupervised conditions where the labels of the training samples in the target domain are completely missing, thereby enabling the basic model for quality parameter detection to accurately predict data in the target domain. With the non-destructive and data-driven characteristics of near-infrared spectroscopy, the model can be quickly transferred and deployed without any chemical experimental labeling for the new instrument, thus significantly reducing the overall application cost of the detection system and possessing good application and promotion value. Attached Figure Description

[0075] Figure 1 This is a schematic flowchart of an embodiment of the cross-device quality parameter detection model construction method of the present invention.

[0076] Figure 2 This is a schematic diagram of one embodiment of constructing a training dataset according to the present invention.

[0077] Figure 3 This is a schematic diagram of an embodiment of the present invention that uses a source-domain spectrometer to acquire near-infrared spectral data.

[0078] Figure 4 This is a schematic diagram of an embodiment of the present invention that uses a target domain spectrometer to acquire near-infrared spectral data.

[0079] Figure 5 This is a schematic diagram of the near-infrared spectra of six representative bauxite samples collected by the source domain spectrometer and the target domain spectrometer in this invention.

[0080] Figure 6 This is a schematic diagram of one embodiment of the domain discriminator of the present invention.

[0081] Figure 7 This is a schematic diagram of one embodiment of the basic model for quality parameter detection of the present invention. Detailed Implementation

[0082] The present invention will be further described below with reference to specific accompanying drawings and embodiments.

[0083] To effectively address the technical bottleneck of severe performance degradation in cross-device applications due to spectrometer differences, this invention provides a method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation. Specifically, the method includes:

[0084] A basic model for quality parameter detection is constructed, and a training dataset is built for training the basic model for quality parameter detection, wherein,

[0085] The training dataset includes a source domain dataset created based on a source domain spectrometer and a target domain dataset created based on a target domain spectrometer.

[0086] The source domain dataset includes several source domain training samples. Each source domain training sample includes source domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the source domain training sample based on the source domain spectrometer, as well as source domain quality parameter labels characterizing the corresponding quality parameters of the source domain training sample.

[0087] The target domain dataset includes several target domain training samples, and each target domain training sample includes target domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the target domain training sample based on a target domain spectrometer.

[0088] When training the basic model for quality parameter detection using the training dataset, at least an unsupervised domain adaptation training method should be used, and a corresponding target model for quality parameter detection should be generated after the model is trained.

[0089] During quality parameter detection, the near-infrared spectral data of the sample to be tested is acquired and loaded into the quality parameter detection target model, so as to use the quality parameter detection target model to predict and output the quality parameter information of the sample to be tested.

[0090] It should be noted that the "cross-device" aspect of this invention specifically refers to two spectrometers whose near-infrared spectra exhibit significant shifts, resulting in a mismatch in the distribution of near-infrared spectral data acquired by the two spectrometers. To address the technical bottleneck of performance degradation when using a model across devices, this invention employs a cross-device quality parameter detection model based on unsupervised domain adaptation, thereby constructing a target model for quality parameter detection applicable across devices.

[0091] Figure 1 The diagram illustrates a flowchart of an embodiment of the cross-device quality parameter detection model construction of the present invention. As shown in the diagram, when constructing the unsupervised domain-adaptive cross-device quality parameter detection model, a basic quality parameter detection model and a training dataset should be constructed first. The training dataset should be based on the source domain spectrometer and target domain spectrometer that form the cross-device model. Specifically, the source domain spectrometer and target domain spectrometer refer to spectrometers that satisfy the above-mentioned cross-device requirements. Figure 3 The figure illustrates an embodiment of near-infrared spectral data of a bauxite sample acquired by a source-domain spectrometer. Figure 4 The figure illustrates an embodiment of near-infrared spectral data of a bauxite sample acquired by a target-domain spectrometer. As shown in the figure, the near-infrared spectra acquired by the source-domain spectrometer and the target-domain spectrometer exhibit significant differences in baseline, noise, and peak intensity. Furthermore, each spectrum can be characterized as a waveform plotted with wavenumber as the abscissa and absorbance as the ordinate. Therefore, the characteristic dimension of each spectral data point can be represented as 1×N, where N is the number of wavenumber points acquired, and "1" represents the channel dimension. The number of wavenumber points N can be selected as needed and will not be elaborated further here.

[0092] The source domain spectrometer can generally be a commonly used spectrometer, while the target domain spectrometer can generally be a new spectrometer or a spectrometer other than the commonly used one. It should be understood that in the existing technology, in order to meet the needs of rapid quality parameter detection, a detection model is generally built for the source domain spectrometer. The constructed detection model can be used to detect the quality parameters of the near-infrared spectral data collected by the source domain spectrometer. It can be understood that when building the detection model, a dataset based on the source domain spectrometer will be constructed.

[0093] To effectively enable cross-device application of the model and overcome performance degradation caused by spectrometer differences, the training dataset created in this invention should include a source domain dataset based on a source domain spectrometer and a target domain dataset based on a target domain spectrometer. The source domain dataset includes several source domain training samples. Each source domain training sample includes source domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the source domain training sample using a source domain spectrometer, and source domain quality parameter labels characterizing the corresponding quality parameters of the source domain training sample. It should be noted that the source domain dataset can be the dataset used to construct the detection model, and the source domain quality parameter labels can be created using existing commonly used techniques, such as accurately measuring the content through laboratory chemical analysis methods and obtaining the source domain quality parameter labels accordingly. In other words, when creating the source domain dataset, this invention can directly utilize existing datasets, thereby saving corresponding production costs.

[0094] In practice, the target domain dataset can include target domain training near-infrared spectral data. That is, when creating the target domain dataset, only near-infrared spectral data can be collected using a target domain spectrometer, without the need to create corresponding quality parameter labels. This can further reduce the cost of creating the training dataset. Figure 2 The diagram illustrates one embodiment of constructing a training dataset.

[0095] It should be noted that the source domain training samples and the target domain training samples should belong to the same type of substance. This invention does not specifically limit the type of substance, but in principle, it should be applicable to any substance that can be analyzed for chemical composition or physical properties using near-infrared spectroscopy. However, the corresponding quality parameters of the source domain training samples and the target domain training samples should not be completely identical, or preferably, their quality parameters should be completely different. This can improve the performance of the constructed target detection model based on the quality parameters.

[0096] After determining the material type of the sample to be tested, the quality parameter type of the sample can be determined. The quality parameter is the content of the corresponding substance in the sample. The quality parameter of the sample to be tested corresponds to the same quality parameter as the source domain quality parameter label in the aforementioned source domain training samples. For example, when the sample to be tested is bauxite, the quality parameter information can be the alumina content in the bauxite, which is a core indicator for evaluating its industrial grade and economic value. In addition, the method of this invention can also be extended to the detection of other major associated components in bauxite, such as the silica content or ferric oxide content that jointly affect its quality. The quality parameter can be flexibly selected according to the needs of downstream smelting and other applications. When the sample to be tested is other types of mineral products, such as iron ore, coal, chemical products such as polymers, or agricultural products such as grains and oilseeds, one or more key quality parameters can also be determined accordingly, which will not be listed here.

[0097] When the product to be tested, the source domain training sample, and the target domain training sample are bauxite, the training dataset can be constructed as follows: the source domain dataset is formed by collecting a batch of bauxite samples mainly from major global producing areas such as Australia and Guinea using a source domain spectrometer, and the target domain dataset is formed by collecting another batch of bauxite samples using a target domain spectrometer.

[0098] In practice, the source-domain spectrometer and target-domain spectrometer can acquire near-infrared light data using common methods to obtain corresponding source-domain training near-infrared spectral data and target-domain training near-infrared spectral data, respectively. For example, near-infrared spectral sampling can be performed under diffuse reflectance conditions. To improve the signal-to-noise ratio and measurement repeatability, the number of scans for each sample can be set to 5 or more, and the average value is taken as the final spectrum. The wavelength range for spectral acquisition can be set from 900 nm to 1700 nm. Of course, the specific spectrometer and parameters can be configured according to the actual application scenario.

[0099] After constructing the above training dataset, the basic model for quality parameter detection can be used. In order to meet the needs of cross-device quality parameter detection, this invention is based at least on the unsupervised domain adaptation training method, and generates the corresponding quality parameter detection target model after model training. The quality parameter detection target model is the model constructed by the method of this invention, that is, the quality parameter detection target model is the cross-device quality parameter detection model.

[0100] After constructing the quality parameter detection target model, the quality parameter can be detected using the quality parameter detection model. Specifically, during quality parameter detection, the near-infrared spectral data of the sample to be tested is acquired and loaded into the quality parameter detection target model. The quality parameter detection target model is then used to predict and output the quality parameter information of the sample to be tested. The near-infrared spectral data to be tested is generated by the source domain spectrometer or the target domain spectrometer through near-infrared spectral data acquisition of the sample to be tested. In other words, the quality parameter detection model can meet the quality parameter detection requirements of the near-infrared spectral data of the sample to be tested by the source domain spectrometer and the target domain spectrometer.

[0101] As explained above, the basic model for quality parameter detection is trained using an unsupervised adaptive training method based on source domain datasets created from source domain spectrometers and target domain datasets created from target domain spectrometers. This innovatively introduces an unsupervised domain adaptation mechanism into the near-infrared regression problem, aiming to solve the core challenge of declining model transfer performance across devices due to spectrometer heterogeneity. When instruments are replaced or added in industrial settings, this invention eliminates the need to relabel a large number of expensive target domain training samples. Instead, it utilizes only existing source domain labeled data (source domain quality parameter labels) and unlabeled target domain training samples to achieve efficient model transfer and reuse. This significantly shortens the deployment cycle of new models and substantially reduces the economic cost of chemometric modeling.

[0102] In one embodiment of the present invention, the basic model for quality parameter detection includes at least a feature extraction network, a task predictor, a domain discriminator, and an alignment processing module, wherein,

[0103] When training a model using an unsupervised domain adaptation training method, each round of model training includes a forward propagation phase and a backpropagation phase.

[0104] The forward propagation phase of each round of model training includes:

[0105] Source domain training samples and target domain training samples are loaded into the feature extraction network in batches so that the feature extraction network can perform deep feature extraction and generate batch deep feature sets. The batch deep feature sets include source domain depth features corresponding to the source domain training near-infrared spectral data in each source domain training sample, and target domain depth features corresponding to the target domain near-infrared spectral data in each target domain training sample.

[0106] A task predictor is used to perform task prediction on the batch deep feature set to generate a batch quality parameter prediction set. Simultaneously, a domain discriminator is used to perform domain discrimination on the batch deep feature set to generate a batch domain category set.

[0107] The batch quality parameter prediction set includes the predicted source domain quality parameters corresponding to each source domain depth feature and the predicted target domain quality parameters corresponding to each target domain depth feature;

[0108] The batch domain category set includes source domain category information corresponding to each source domain depth feature and target domain category information corresponding to each target domain depth feature;

[0109] Based on the current batch depth feature set and batch quality parameter prediction set, the alignment processing module performs local feature distribution matching processing based on a local fine alignment strategy to generate a batch local alignment feature set after local feature distribution matching processing.

[0110] The batch local alignment feature set includes several local alignment feature pairs, each of which includes weighted source domain features and weighted target domain features.

[0111] The feature dimensions of the weighted source domain features and the weighted target domain features are consistent with the feature dimensions of the source domain deep features and the target domain deep features.

[0112] The backpropagation phase of each round of model training includes:

[0113] Calculate the model training loss for the current round, which includes at least the source domain task prediction loss, domain adversarial loss, and selective alignment loss. Update the network parameters of the quality parameter detection base model based on the model training loss.

[0114] The source domain task prediction loss is calculated and generated based on the predicted values ​​of source domain quality parameters and the corresponding source domain quality parameter labels in all batch quality parameter prediction sets.

[0115] Domain adversarial loss is calculated and generated based on all batch domain category sets;

[0116] The selective alignment loss is calculated based on the local alignment feature set of all batches.

[0117] To obtain a target model for quality parameter detection through model training, the basic model for quality parameter detection should include a feature extraction network, a task predictor, a domain discriminator, and an alignment module. The feature extraction network extracts features from near-infrared spectral data to obtain corresponding depth features. The task predictor then provides the task prediction output. The domain discriminator performs domain discrimination, and the alignment module handles alignment during model training. The feature extraction network can adopt commonly used forms, such as the U-Net network, with the specific choice depending on its ability to extract deep features. The task predictor can use a commonly used prediction head. The domain discriminator and alignment module will be explained in detail below.

[0118] Figure 7 The figure shows an embodiment of a basic model for quality parameter detection. In the figure, G f For feature extraction networks, G y For task predictor, G d The alignment processing module performs alignment work for the domain discriminator, sample selection, and feature selection. Figure 7 The model also includes a gradient inversion layer, which is mainly used for gradient inversion. Its specific operation will be explained below. It should be noted that the domain discriminator, alignment module, and gradient inversion layer are only used for model training and do not need to participate in inference. Therefore, in one embodiment of the present invention, the quality parameter detection target model includes a feature extraction network and a task predictor. During quality parameter detection, the near-infrared spectral data to be detected is loaded into the feature extraction network within the quality parameter detection target model, and the quality parameter information of the sample to be detected is output by the task predictor.

[0119] also, Figure 7 middle, For the target domain dataset, Training near-infrared spectral data for the target domain, For the source domain dataset, To train near-infrared spectral data for the source domain, Source domain quality parameter labels for near-infrared spectral data trained in the source domain. To train near-infrared spectral data with the target domain The corresponding predicted values ​​of the target domain quality parameters.

[0120] In order to train a target model for quality parameter detection, some necessary training conditions should be set, such as setting the optimizer and the number of training iterations. For the training conditions, a feasible training condition is: use the Adam optimizer to perform end-to-end joint optimization of all learnable parameters of the model; configure the learning rate as 1e-3; set the size of each processing batch to 64, and the maximum number of training iterations to 100 generations.

[0121] In practice, the number of training samples in the source domain can be equal to or unequal to the number of training samples in the target domain, depending on the needs. As explained above, the basic model for quality parameter detection should be trained 100 times using the training dataset. The basic model after the 100th training round should then be configured as the target model for quality parameter detection. The specific method for configuring the basic model as the target model is consistent with existing techniques and will not be elaborated here. When the batch size is 64, 32 source domain training samples and 32 target domain training samples will be simultaneously input into the basic model for quality parameter detection. For other batch sizes, please refer to the explanation here; examples will not be provided here.

[0122] Similar to existing model training, each round of model training also includes a forward propagation phase and a backward propagation phase. The functions of the forward propagation phase and the backward propagation phase are consistent with those of the existing ones. However, the processes of the forward propagation phase and the backward propagation phase in this invention are different from those of the existing ones, which will be explained in detail below.

[0123] During the forward propagation phase of each round of model training, source domain training samples and target domain training samples are loaded into the feature extraction network within the basic model for quality parameter detection, based on the batch size. This allows for deep feature extraction using the feature extraction network, generating a batch deep feature set. The batch deep feature set includes source domain depth features corresponding to the source domain training near-infrared spectral data in each source domain training sample, and target domain depth features corresponding to the target domain near-infrared spectral data in each target domain training sample. As explained above, when the batch size is 64, the corresponding number of source domain depth features and target domain depth features is 32 each.

[0124] After the feature extraction network extracts the batch depth feature set, a task predictor can be configured to perform task prediction, and a domain discriminator can be configured to perform domain discrimination. The domain discriminator mainly outputs the log probability of each depth feature belonging to the source domain or the target domain. Specifically, the task predictor will perform task prediction on all source domain depth features and target domain depth features in the batch depth feature set to generate a batch quality parameter prediction set. The domain discriminator will also perform domain discrimination on all source domain depth features, target and depth features in the batch depth feature set. At this time, a batch domain category set will be generated.

[0125] Figure 5 This paper presents an embodiment of near-infrared spectra of six representative bauxite samples acquired by a source-domain spectrometer and a target-domain spectrometer. In the figure, S1 is the source-domain spectrometer, S2 is the target-domain spectrometer, the horizontal axis is wavelength, and the vertical axis is absorbance. As can be seen from the figure, due to the differences in optical elements, detector response, and internal algorithms between the source-domain spectrometer and the target-domain spectrometer, even when measuring the same sample, their spectral curves exhibit significant nonlinear shifts in absorbance baseline and noise level. The spectral data across devices have non-negligible deviations at different levels.

[0126] Figure 5 In (a), when the aluminum content of the sample is 34.58%, the near-infrared spectral data curves acquired by the source domain spectrometer and the target domain spectrometer show significant differences in baseline height, peak position and intensity; Figure 5 In (b), when the aluminum content of the sample is 40.26%, the near-infrared spectral data curves collected by the source domain spectrometer and the target domain spectrometer also show nonlinear shifts, and the difference in absorbance peaks is quite obvious; Figure 5 (c) The aluminum content of the sample is 44.07%. Figure 5 (d) The aluminum content of the sample was 49.98%. Figure 5 (e) The aluminum content of the sample is 53.80% and Figure 5 (f) When the aluminum content of the sample is 56.92%, the near-infrared spectral data curves collected by the source domain spectrometer and the target domain spectrometer all show complex nonlinear deviations caused by the instruments in terms of absorbance baseline, peak shape and noise level, and these deviations show different forms as the aluminum content changes.

[0127] At the sample level, samples with similar content (e.g.) Figure 5 (b) and Figure 5 (c) in the sample, their spectral morphology is also relatively similar; while the sample with the largest content range (such as Figure 5 (a) and Figure 5 The spectral characteristics of (f) in the middle are quite different.

[0128] The aforementioned spectral feature shift phenomenon stems from the fundamental differences in their intrinsic chemical composition. To achieve feature alignment, a global alignment strategy is currently often adopted. However, this strategy forcibly aligns source and target domain samples with inherently different chemical properties, distorting the intrinsic manifold structure of the feature space and impairing the model's discriminative ability.

[0129] At the feature level, examining all six sets of spectra reveals that the deviation between the source-domain spectrometer and the target-domain spectrometer is not a simple linear shift, but a complex nonlinear function that varies with wavelength and is sample-dependent. The specific manifestations of this difference also differ: in some bands, it mainly manifests as a systematic absorbance shift; while in other bands, it may appear as instrument-specific artifacts. Therefore, at the feature level of cross-domain samples, the global alignment strategy performs indiscriminate alignment across all feature dimensions. Domain-specific artifacts introduced by instrument differences are incorrectly treated as alignment targets by the model, causing the basic model for quality parameter detection to learn statistically similar but chemically distorted feature representations.

[0130] As explained above, the primary challenge of near-infrared spectroscopy in cross-instrument analysis stems from the complexity of the samples themselves. Taking bauxite as an example, its spectral characteristics are highly correlated with its chemical composition, resulting in significant heterogeneity within the data. Directly aligning the overall data distribution from different instruments can easily lead to mismatches between samples with vastly different chemical properties, causing negative transfer and ultimately impairing the model's discriminative ability.

[0131] To overcome the problems caused by global alignment and ensure that the basic model for quality parameter detection truly learns useful feature representations, in one embodiment of the present invention, an alignment processing module is used to perform local feature distribution matching processing on the current batch deep feature set and the batch quality parameter prediction set to generate a batch locally aligned feature set. This ensures that alignment is performed only on selected samples that are highly correlated with the source domain samples, fundamentally avoiding the risk of negative transfer caused by sample mismatch. It is understood that the number of batch locally aligned feature sets is consistent with the number of batches in each round of model training. The method and process of the alignment processing module performing local feature distribution matching processing will be described in detail below.

[0132] It should be understood that during the backpropagation phase, the model training loss for the current round should be calculated so that the network parameters of the basic model for quality parameter detection can be updated using the model training loss. The basic method of updating network parameters using the model training loss is consistent with existing technologies, and the specific method of updating network parameters will be explained in detail below. In order to meet the requirements of cross-device quality parameter detection, the model training loss of this invention includes at least the source domain task prediction loss, the domain adversarial loss, and the selective alignment loss. The specific details of the source domain task prediction loss, the domain adversarial loss, and the selective alignment loss will be explained in detail below.

[0133] Figure 6The structure of the domain discriminator is shown. As illustrated, the domain discriminator may include a first fully connected layer, a batch normalization layer, a Leaky ReLU activation function, a Dropout layer, a second fully connected layer, and a LogSoftmax activation function, connected in sequence. Figure 6 In this model, QL1 is the first fully connected layer and QL2 is the second fully connected layer. During domain discrimination, the source domain depth features and target domain depth features are received through the first fully connected layer. The first fully connected layer, batch normalization layer, LeakyReLU activation function and Dropout layer are used as hidden layers, and the second fully connected layer and LogSoftmax activation function are used as output layers.

[0134] Specifically, the source domain depth features and target domain depth features have the same data format. In each batch, the depth feature data output by the feature extraction network can be [b, 128], where b represents the number of spectra, i.e., the batch size, and 128 represents the feature dimension output by the feature extraction network. During domain discrimination, the 128-dimensional deep features can be linearly mapped to 64-dimensional hidden features through the first fully connected layer, so the data format output by the first connected layer can be [b, 64]. Batch normalization is performed on the 64-dimensional hidden features through a batch normalization layer to accelerate model convergence and improve stability. The LeakyReLU activation function is used to perform non-linear activation on the normalized features and avoid gradient vanishing. The Dropout layer is used to enhance the generalization ability of the model and prevent overfitting. The slope parameter of the LeakyReLU activation function can be set to a negative slope with a slope value of 0.2, and the deactivation probability of the Dropout layer can be 0.5.

[0135] The second fully connected layer can linearly map the 4-dimensional features output by the Dropout layer to a 2-dimensional output. The data format at this time can be [b,2]. The LogSoftmax activation function can be used to calculate LogSoftmax and output the log probability that the deep features belong to two different domains (source domain or target domain).

[0136] In one embodiment of the present invention, when performing local feature distribution matching based on a local fine alignment strategy and generating a batch of locally aligned feature sets, the alignment processing module includes at least sequential sample screening and feature selection processing, wherein...

[0137] When performing sample screening, based on the source domain quality parameter labels of all source domain training samples in the current batch, the predicted values ​​of target domain quality parameters in the current batch quality parameter prediction set are screened to obtain several predicted values ​​of target domain quality parameters that match the source domain quality parameter labels of the current batch. A target domain screening sample set is formed based on all the screened target domain quality parameter prediction values, wherein each screened target domain quality parameter prediction value forms a screening sample in the target domain screening sample set.

[0138] When performing feature selection processing, the target domain depth features corresponding to each selected sample in the target domain selection sample set are obtained, and the source domain depth features that match the target depth features of the selected samples are obtained.

[0139] The target domain depth features and the source domain depth features that match the target domain depth features are weighted and aligned to generate weighted target domain features and weighted source domain features respectively after weighted alignment. The generated weighted target domain features and weighted source domain features are then used as a local aligned feature pair.

[0140] Depend on Figure 7 It is known that when performing local feature distribution matching based on the local fine alignment strategy, sample screening and feature selection processing should be included. It should be noted that the local fine alignment strategy of this invention is used in the training of each batch. Therefore, when performing sample screening, the predicted values ​​of the target domain quality parameters in the current batch quality parameter prediction set should be screened based on the source domain quality parameter labels of all source domain training samples in the current batch.

[0141] In one embodiment of the present invention, when performing sample screening processing and generating a target screening sample set, the process includes sequentially performing global output consistency screening and local feature-output consistency screening, wherein...

[0142] When performing global output consistency filtering, the following are included:

[0143] Based on the source domain quality parameter labels of all source domain training samples in the current batch, calculate the source domain label mean and source domain label standard deviation;

[0144] For any predicted value of a target domain quality parameter within the batch quality parameter prediction set, if the predicted value of the target domain quality parameter satisfies the global output consistency screening condition, then the target domain training sample corresponding to the predicted value of the target domain quality parameter is configured as an initial subsample.

[0145] When the predicted values ​​of the target domain quality parameters meet the global output consistency screening criteria, then:

[0146] ,

[0147] in, For the predicted values ​​of quality parameters in the target domain, The average value of the source domain labels. The standard deviation of the source domain labels. This is the absolute value of the difference between the predicted value of the quality parameter of the target domain and the mean value of the label of the source domain.

[0148] When performing local feature-output consistency filtering, the following is included:

[0149] For any initial subsample, obtain the target domain depth feature corresponding to the initial subsample;

[0150] The acquired target domain depth features are matched with the source domain depth features in the batch depth feature set to determine the source domain depth features that match the target domain depth features, and the source domain training samples corresponding to the determined source domain depth features are configured as source domain matching samples.

[0151] The predicted target domain quality parameters of the initially selected subsamples are compared with the source domain quality parameter labels of the source domain matching samples using confidence level screening. When the confidence level screening passes, the initially selected subsamples are configured as a screening sample.

[0152] When performing confidence level filtering, we have:

[0153] If the initial subsamples satisfy the local feature-output consistency screening condition, then:

[0154]

[0155] in, The source domain quality parameter labels for the samples matched to the source domain. The confidence threshold. This is the absolute value of the difference between the predicted value of the target domain quality parameter and the source domain quality parameter label of the matching sample in the source domain.

[0156] As can be seen from the above description, each source domain training sample contains known source domain quality parameter labels. Therefore, for a given batch, the source domain label mean and source domain label standard deviation can be calculated based on the source domain training samples of the current batch. The method and process for calculating the source domain standard mean and source domain label standard deviation can be consistent with existing technologies and will not be elaborated here.

[0157] After the task predictor predicts the current batch depth feature set, it can obtain the batch quality parameter prediction set, and then obtain the predicted values ​​of all target domain quality parameters within the batch quality parameter prediction set. Subsequently, the calculated source domain label mean and source domain label standard deviation can be used to filter all target domain quality parameter prediction values ​​within the batch quality parameter prediction set. When the filtering meets the global output consistency filtering condition, the target domain training sample corresponding to the target domain quality parameter prediction value is configured as the initial subsample; otherwise, the corresponding target domain training sample is not selected as the initial subsample.

[0158] Within the current batch, once a target domain training sample is selected as an initial sub-sample, a local feature-output consistency screening is performed. During this screening, the target domain depth feature corresponding to the initial sub-sample is matched with the source domain depth features corresponding to all source domain training samples in the current batch. After feature matching, a corresponding source domain depth feature is selected, and the corresponding source domain training sample is configured as the source domain matching sample. Subsequently, a confidence score screening is performed on the initial sub-sample and the source domain matching sample. If the confidence score screening passes, the current initial sub-sample should be used as the screening sample.

[0159] As can be seen from the above explanation, the number of samples selected in the target domain screening sample set will not exceed the number of target domain training samples loaded into the basic model for quality parameter detection in the batch. The specific details can be determined based on the actual sample screening process, and will not be elaborated here.

[0160] It should be noted that the confidence threshold The confidence threshold can be determined through experiments or other methods, such as when the sample to be tested is bauxite. It can generally be set to 1.5. When the sample to be tested is another type of substance, it can be selected and determined according to experience or experimental method. Examples will not be given here.

[0161] When performing local feature-output consistency screening, a source domain depth feature that matches the feature of each initially selected subsample should first be found. In one embodiment of the present invention, the feature matching process includes:

[0162] For each initially selected subsample, calculate the Euclidean distance between the target domain depth feature and all source domain depth features in the current batch depth feature set;

[0163] The source domain depth feature corresponding to the minimum Euclidean distance is configured as the source domain depth feature that matches the target domain depth feature.

[0164] For each initially selected subsample, the corresponding target domain depth feature can be found within the batch depth feature set. Then, the Euclidean distance between the target domain depth feature and each source domain depth feature within the batch depth feature set is calculated. Since the target domain depth feature and source domain depth features are as described above, commonly used techniques in this field can be employed for Euclidean distance calculation. When the batch size is 64, as explained above, 32 corresponding Euclidean distances can be calculated. These calculated Euclidean distances are then compared, and the source domain depth feature corresponding to the smallest Euclidean distance is configured as the source domain depth feature matching the target domain depth feature.

[0165] In practice, the source domain training samples corresponding to the determined source domain depth features are configured as source domain matching samples. Therefore, when performing feature selection processing, the source domain depth features that match the target depth features of the selected samples are obtained, specifically the source domain depth features corresponding to the source domain matching samples.

[0166] In one embodiment of the present invention, the weighted alignment of the target domain depth features and the source domain depth features matching the target domain depth features includes:

[0167] Calculate the L1 distance between the target domain depth features and the corresponding source domain depth features to obtain the difference vector representing the L1 distance of the features;

[0168] The difference vector is input into the weight generation network to generate a dynamic weight vector.

[0169] The target domain depth features and source domain depth features are respectively multiplied by the generated dynamic weight vector using the Hadamard product to generate weighted target domain features and weighted source domain features, respectively.

[0170] It should be noted that each dimension value of the difference vector reflects the inconsistency between the target domain depth features and the source domain depth features along that feature dimension. A smaller difference vector indicates more stable and transferable features. When calculating the difference vector, we can have:

[0171]

[0172] in, For the difference vector, To filter the target domain depth features of the samples, These are the source domain depth features determined by feature matching. The L1 distance is the feature L1 distance between the target domain depth features and the corresponding source domain depth features.

[0173] After calculating the difference vector, a corresponding dynamic weight vector can be generated using an input weight network. In one embodiment of the present invention, when generating the dynamic weight vector using a weight generation network, the following applies:

[0174]

[0175] in, For dynamic weight vectors, For the difference vector, , All are fully connected layers. This is a non-linear activation function used to enable the weight generation network to learn more complex feature difference relationships. for An activation function is used to normalize the output values ​​of the weight generation network to the (0,1) interval to form the final weighting coefficients.

[0176] As can be seen from the expression for generating dynamic weight vectors by the weight generation network described above, the weight generation network can include sequentially connected fully connected layers. ReLU activation function, fully connected layer as well as The activation function, of course, the weight generation network can also take other forms, depending on whether it can satisfy the above-mentioned dynamic weight vector generation.

[0177] To generate weighted target domain features, the target domain depth features of the selected samples should be multiplied by the dynamic weight vector using the Hadamard product. The Hadamard product operation can be represented as follows:

[0178] in, For weighted target domain features, This represents the Hadamard product operation. For instructions on generating weighted source domain features, please refer to this section for guidance on generating weighted target domain features.

[0179] As can be seen from the above description, in each round of model training, the deep feature extraction, task prediction, domain discrimination, and local feature distribution matching are performed for each batch of source domain training samples and target domain training samples. Thus, after a round of model training, the model training loss function can be calculated.

[0180] Understandably, besides the inherent complexity of near-infrared spectral data samples, the interplay between domain-specific artifacts (such as sensor noise) introduced by different spectrometers and the crucial chemical information of the samples in spectral features also poses an objective challenge to cross-instrument analysis. When all feature dimensions are aligned indiscriminately, these noises are used as alignment targets, thereby weakening the effective representation of crucial chemical information in near-infrared spectra and leading to a decline in model generalization performance. This invention achieves a dynamic weighting mechanism by performing Hadamard product operations on dynamic weight vectors and deep features. This mechanism intelligently identifies and assigns high weights to stable, transferable shared chemical information, while assigning low weights to inconsistent dimensions such as instrument noise. This selective alignment method ensures that knowledge transfer focuses on the most reliable discriminative information.

[0181] In one embodiment of the present invention, when updating the network parameters of the detection base model based on the model training loss, the method includes:

[0182] The network parameters of the feature extraction network are updated based on source domain task prediction loss, domain adversarial loss, and selective alignment loss.

[0183] When updating the network parameters of the feature extraction network based on the domain adversarial loss, at least the gradient inversion processing of the domain adversarial loss should be performed, and the update direction should be configured to maximize the domain adversarial loss when updating the network parameters of the feature extraction network.

[0184] Figure 7 The diagram illustrates an embodiment of gradient inversion using a gradient inversion layer. It should be noted that during the forward propagation phase, the gradient inversion layer may function as an identity transformation layer or not at all. During the backpropagation phase, the gradient inversion layer can be used to flip the gradient of the neighborhood adversarial loss. During backpropagation, it multiplies the neighborhood adversarial loss from the neighborhood discriminator by a preset negative constant (e.g., -1) before passing it to the feature extraction network.

[0185] Figure 7 middle, The gradient of the network parameters of the domain adversarial loss with respect to the domain regressor. The gradient of the domain adversarial loss is applied to the network parameters of the feature extraction network after passing through the gradient flipping layer.

[0186] It's important to note that gradient inversion is crucial for achieving adversarial processing. When optimizing the parameters of the domain discriminator, the goal is to minimize its classification error, i.e., to minimize the domain adversarial loss. However, after receiving this inverted domain adversarial loss, the feature extraction network's optimization goal becomes maximizing that loss. Through this adversarial joint optimization, the feature extraction network is ultimately forced to learn a domain-invariant feature representation that can confuse the source and target domains.

[0187] As can be seen from the above description, by combining the synergistic effect of the feature extraction network, the domain discriminator and the gradient reversal layer, the model training aims to enable the feature extraction network to initially learn a domain-invariant feature representation. This feature representation can effectively confuse the source domain and the target domain, making them difficult to distinguish in the feature space, thereby laying the foundation for subsequent domain adaptation tasks.

[0188] For the source domain task prediction loss, we have:

[0189]

[0190] in, Predict the loss for the task in the source domain. For the first Source domain quality parameter labels within each source domain training sample. For the first The predicted source domain quality parameters of each source domain training sample are output by the task predictor.

[0191] As shown in the above calculation expression, when calculating the source domain task prediction loss, only the source domain quality parameter labels within the source domain dataset and the predicted values ​​of the source domain quality parameters output by the task predictor are used. The source domain task prediction loss uses mean squared error as a metric. By minimizing the difference between the predicted values ​​of the source domain quality parameters and the source domain quality parameter labels, the feature extraction network can learn feature representations that are sensitive to changes in chemical composition and have discriminative power for downstream regression tasks.

[0192] In one embodiment of the present invention, the domain adversarial loss is as follows:

[0193]

[0194] in, The number of training samples in the source domain. The number of training samples for the target domain. For the domain discriminator to distinguish the first Each source domain deep feature Source domain category information, For the domain discriminator to distinguish the first Deep features of each target domain Target domain category information;

[0195] For the selective alignment loss, we have:

[0196]

[0197] in, For selective alignment loss, For MMD loss function, For regularization loss, This represents the total number of locally aligned feature pairs generated after each round of model training. The dimension of the dynamic weight vector. To form the first The dynamic weight vector used in the local alignment feature pair Each weight value For the first Weighted source domain features within each local alignment feature pair No. Weighted target domain features within each local alignment feature pair To weighted source domain features Weighted target domain features The Gaussian kernel function operation was performed. , This is the loss weighting coefficient.

[0198] As can be seen from the above calculation expression for domain adversarial loss, it is possible to achieve feature alignment between the depth features of the source domain and the depth features of the target domain at a global scale through domain adversarial loss. This measures the probability that a deep feature of the source domain is correctly identified as the "source domain". This measures the probability that the target domain's deep features are incorrectly identified as the "source domain." It should be noted that when updating the network parameters of the domain discriminator and the feature extraction network using the domain adversarial loss, the gradient inversion layer inverts the domain adversarial loss, thereby driving it to "deceive" the domain discriminator, making the distribution of the source domain's deep features and the target domain's deep features globally more consistent.

[0199] Loss weighting coefficient Loss weighting coefficient Generally, an empirical value can be used as the loss weight coefficient. Loss weighting coefficient The specific values ​​can be selected as needed, and will not be elaborated here.

[0200] The selective alignment loss consists of two parts: the weighted MMD loss function and the regularization loss. The MMD loss function measures the distributional difference between the weighted source domain features and the weighted target domain features. The regularization loss penalizes excessively small weights, encouraging the model to retain the main feature dimensions and reduce weights only on dimensions where feature differences are significant, thereby achieving an adaptive balance.

[0201] In one embodiment of the present invention, when updating the network parameters of the basic model for quality parameter detection, the method further includes:

[0202] The source domain task prediction loss is used to update the network parameters of the task predictor first, and then the source domain task prediction loss is propagated to the feature extraction network.

[0203] First, the network parameters of the domain discriminator are updated using the domain adversarial loss. Then, the domain adversarial loss after gradient inversion is propagated to the feature extraction network. When updating the network parameters of the domain discriminator, the update direction is configured to minimize the domain adversarial loss.

[0204] Using the MMD loss function and regularization loss First, update the network parameters of the weight generation network within the alignment processing module. Then, apply the MMD loss function. Backpropagation is performed to the feature extraction network;

[0205] The network parameters of the feature extraction network are jointly updated based on the source domain task prediction loss, the domain adversarial loss of gradient inversion, and the source domain task prediction loss.

[0206] In practice, when updating the network parameters of the task predictor using the source domain task prediction loss, it is generally necessary to calculate the gradient of the source domain task prediction loss with respect to the network parameters of the task predictor. Subsequently, the network parameters of the task predictor are updated using the calculated gradient. The method of calculating the gradient and the method of updating the network parameters using the gradient are consistent with the existing technology. Other methods for updating network parameters can be found here.

[0207] As explained above, the alignment processing module includes at least a weight generation network, and may also include other forms, depending on whether it can achieve the local feature distribution matching processing described above. These details will not be elaborated here. The local fine alignment strategy avoids inappropriate matching at the sample level and removes domain-specific artifacts at the feature level. Since the selective alignment loss is generated after the aforementioned local feature distribution processing, updating the network parameters of the feature extraction network using the selective alignment loss can effectively solve the heterogeneity problem between the sample and feature levels. This further enables the feature extraction network to learn general, domain-invariant features that can confuse the source and target domains.

[0208] In constructing the cross-device quality parameter detection model of this invention, the alignment processing module enables sample screening and feature selection, effectively avoiding negative transfer problems caused by sample heterogeneity. Simultaneously, the dynamic weight vector enables a dynamic weighting mechanism, effectively mitigating feature information loss caused by domain-specific artifacts such as instrument noise. Therefore, the basic quality parameter detection model ultimately learns domain-invariant features, achieving effective cross-instrument transfer of the basic quality parameter detection model.

[0209] From the perspective of application cost and promotion value, this invention overcomes the limitations of traditional methods that require the time-consuming and expensive re-modeling or correction of a large number of labeled samples when replacing or adding instruments. It can achieve knowledge transfer from the source domain to the target domain under unsupervised conditions where the labels of the training samples in the target domain are completely missing, thereby enabling the basic model for quality parameter detection to accurately predict data in the target domain. With the non-destructive and data-driven characteristics of near-infrared spectroscopy, the model can be quickly transferred and deployed without any chemical experimental labeling for the new instrument, thus significantly reducing the overall application cost of the detection system and possessing good application and promotion value.

Claims

1. A method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation, characterized in that, The method for constructing the cross-device quality parameter detection model includes: A basic model for quality parameter detection is constructed, and a training dataset is built for training the basic model for quality parameter detection, wherein, The training dataset includes a source domain dataset created based on a source domain spectrometer and a target domain dataset created based on a target domain spectrometer. The source domain dataset includes several source domain training samples. Each source domain training sample includes source domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the source domain training sample based on the source domain spectrometer, as well as source domain quality parameter labels characterizing the corresponding quality parameters of the source domain training sample. The target domain dataset includes several target domain training samples, and each target domain training sample includes target domain training near-infrared spectral data generated by acquiring near-infrared spectral data of the target domain training sample based on a target domain spectrometer. When training the basic model for quality parameter detection using the training dataset, at least an unsupervised domain adaptation training method should be used, and a corresponding target model for quality parameter detection should be generated after the model is trained. During quality parameter detection, the near-infrared spectral data of the sample to be tested is acquired, and the near-infrared spectral data is loaded into the quality parameter detection target model so as to use the quality parameter detection target model to predict and output the quality parameter information of the sample to be tested. The basic model for quality parameter detection includes at least a feature extraction network, a task predictor, a domain discriminator, and an alignment processing module. When training a model using an unsupervised domain adaptation training method, each round of model training includes a forward propagation phase and a backpropagation phase. The forward propagation phase of each round of model training includes: Source domain training samples and target domain training samples are loaded into the feature extraction network in batches so that the feature extraction network can perform deep feature extraction and generate batch deep feature sets. The batch deep feature sets include source domain depth features corresponding to the source domain training near-infrared spectral data in each source domain training sample, and target domain depth features corresponding to the target domain near-infrared spectral data in each target domain training sample. A task predictor is used to perform task prediction on the batch deep feature set to generate a batch quality parameter prediction set. Simultaneously, a domain discriminator is used to perform domain discrimination on the batch deep feature set to generate a batch domain category set. The batch quality parameter prediction set includes the predicted source domain quality parameters corresponding to each source domain depth feature and the predicted target domain quality parameters corresponding to each target domain depth feature; The batch domain category set includes source domain category information corresponding to each source domain depth feature and target domain category information corresponding to each target domain depth feature; Based on the current batch depth feature set and batch quality parameter prediction set, the alignment processing module performs local feature distribution matching processing based on a local fine alignment strategy to generate a batch local alignment feature set after local feature distribution matching processing. The batch local alignment feature set includes several local alignment feature pairs, each of which includes weighted source domain features and weighted target domain features. The feature dimensions of the weighted source domain features and the weighted target domain features are consistent with the feature dimensions of the source domain depth features and the target domain depth features. When performing local feature distribution matching based on the local fine alignment strategy and generating batch locally aligned feature sets, the alignment processing module includes at least sequential sample screening and feature selection processing. When performing sample screening, based on the source domain quality parameter labels of all source domain training samples in the current batch, the predicted values ​​of target domain quality parameters in the current batch quality parameter prediction set are screened to obtain several predicted values ​​of target domain quality parameters that match the source domain quality parameter labels of the current batch. A target domain screening sample set is formed based on all the screened target domain quality parameter prediction values, wherein each screened target domain quality parameter prediction value forms a screening sample in the target domain screening sample set. When performing feature selection processing, the target domain depth features corresponding to each selected sample in the target domain selection sample set are obtained, and the source domain depth features that match the target depth features of the selected samples are obtained. The target domain depth features and the source domain depth features that match the target domain depth features are weighted and aligned to generate weighted target domain features and weighted source domain features respectively after weighted alignment. The generated weighted target domain features and weighted source domain features are then used as a local aligned feature pair.

2. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation as described in claim 1, characterized in that: The backpropagation phase of each round of model training includes: Calculate the model training loss for the current round, which includes at least the source domain task prediction loss, domain adversarial loss, and selective alignment loss. Update the network parameters of the quality parameter detection base model based on the model training loss. The source domain task prediction loss is calculated and generated based on the predicted values ​​of source domain quality parameters and the corresponding source domain quality parameter labels in all batch quality parameter prediction sets. Domain adversarial loss is calculated and generated based on all batch domain category sets; The selective alignment loss is calculated based on the local alignment feature set of all batches.

3. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation as described in claim 1, characterized in that, When performing sample filtering and generating the target sample set, the process includes sequential global output consistency filtering and local feature-output consistency filtering. When performing global output consistency filtering, the following are included: Based on the source domain quality parameter labels of all source domain training samples in the current batch, calculate the source domain label mean and source domain label standard deviation; For any predicted value of a target domain quality parameter within the batch quality parameter prediction set, if the predicted value of the target domain quality parameter satisfies the global output consistency screening condition, then the target domain training sample corresponding to the predicted value of the target domain quality parameter is configured as an initial subsample. When the predicted values ​​of the target domain quality parameters meet the global output consistency screening criteria, then: , in, For the predicted values ​​of quality parameters in the target domain, The average value of the source domain labels. The standard deviation of the source domain labels. This is the absolute value of the difference between the predicted value of the quality parameter of the target domain and the mean value of the label of the source domain. When performing local feature-output consistency filtering, the following is included: For any initial subsample, obtain the target domain depth feature corresponding to the initial subsample; The acquired target domain depth features are matched with the source domain depth features in the batch depth feature set to determine the source domain depth features that match the target domain depth features. The source domain training samples corresponding to the determined source domain depth features are configured as source domain matching samples. The predicted target domain quality parameters of the initial subsamples are compared with the source domain quality parameter labels of the source domain matching samples using confidence level screening. When the confidence level screening passes, the initial subsamples are configured as a screening sample. When performing confidence level filtering, we have: If the initial subsamples satisfy the local feature-output consistency screening condition, then: in, The source domain quality parameter labels for the samples matched to the source domain. The confidence threshold. This is the absolute value of the difference between the predicted value of the target domain quality parameter and the source domain quality parameter label of the matching sample in the source domain.

4. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation according to claim 3, characterized in that, Feature matching processing includes: For each initially selected subsample, calculate the Euclidean distance between the target domain depth feature and all source domain depth features in the current batch depth feature set; The source domain depth feature corresponding to the minimum Euclidean distance is configured as the source domain depth feature that matches the target domain depth feature.

5. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation according to any one of claims 1 to 4, characterized in that, When performing weighted alignment of the target domain depth features and the source domain depth features that match the target domain depth features, the following steps are included: Calculate the L1 distance between the target domain depth features and the corresponding source domain depth features to obtain the difference vector representing the L1 distance of the features; The difference vector is input into the weight generation network to generate a dynamic weight vector. The target domain depth features and source domain depth features are respectively multiplied by the generated dynamic weight vector using the Hadamard product to generate weighted target domain features and weighted source domain features, respectively.

6. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation according to claim 5, characterized in that, When using a weight generation network to generate dynamic weight vectors, we have: in, For dynamic weight vectors, For the difference vector, , All are fully connected layers. This is a non-linear activation function used to enable the weight generation network to learn more complex feature difference relationships. for An activation function is used to normalize the output values ​​of the weight generation network to the (0,1) interval to form the final weighting coefficients.

7. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation according to claim 6, characterized in that, When updating the network parameters of the basic model based on the model training loss to detect quality parameters, the following are included: The network parameters of the feature extraction network are updated based on source domain task prediction loss, domain adversarial loss, and selective alignment loss. When updating the network parameters of the feature extraction network based on the domain adversarial loss, at least the gradient inversion processing of the domain adversarial loss should be performed, and when updating the network parameters of the feature extraction network, the update direction should be configured to maximize the domain adversarial loss. The quality parameter detection target model includes a feature extraction network and a task predictor. During quality parameter detection, the near-infrared spectral data to be detected is loaded into the feature extraction network within the quality parameter detection target model, and the quality parameter information of the sample to be detected is output by the task predictor.

8. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation according to claim 7, characterized in that, Regarding the domain adversarial loss, we have: in, The number of training samples in the source domain. The number of training samples for the target domain. For the domain discriminator to distinguish the first Each source domain deep feature Source domain category information, For the domain discriminator to distinguish the first Deep features of each target domain Target domain category information; For the selective alignment loss, we have: in, For selective alignment loss, For MMD loss function, For regularization loss, This represents the total number of locally aligned feature pairs generated after each round of model training. The dimension of the dynamic weight vector. To form the first The dynamic weight vector used in the local alignment feature pair Each weight value For the first Weighted source domain features within each local alignment feature pair No. Weighted target domain features within each local alignment feature pair To weighted source domain features Weighted target domain features The Gaussian kernel function operation was performed. , This is the loss weighting coefficient.

9. The method for constructing a cross-device quality parameter detection model based on unsupervised domain adaptation as described in claim 8, characterized in that, When updating the network parameters of the basic model for quality parameter detection, the following is also included: The source domain task prediction loss is used to update the network parameters of the task predictor first, and then the source domain task prediction loss is propagated to the feature extraction network. First, the network parameters of the domain discriminator are updated using the domain adversarial loss. Then, the domain adversarial loss after gradient inversion is propagated to the feature extraction network. When updating the network parameters of the domain discriminator, the update direction is configured to minimize the domain adversarial loss. Using the MMD loss function and regularization loss First, update the network parameters of the weight generation network within the alignment processing module. Then, apply the MMD loss function. Backpropagation is performed to the feature extraction network; The network parameters of the feature extraction network are jointly updated based on the source domain task prediction loss, the domain adversarial loss of gradient inversion, and the source domain task prediction loss.

Citation Information

Patent Citations

  • Transferable calculation meat quality near infrared detection method and device

    CN104914069A

  • Rolling bearing cross-domain fault diagnosis method based on self-supervised learning

    CN116975718A