A multiscale counter-decoupling near-infrared spectroscopy model transfer method and system thereof

CN120995133BActive Publication Date: 2026-10-09CHINESE ACAD OF AGRI MECHANIZATION SCI GRP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511092288.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-05
Publication Date
2026-10-09
Estimated Expiration
2045-08-05

AI Technical Summary

Technical Problem

[0005]为了解决非线性仪器响应及高频噪声耦合问题以及目标仪器数据不足问题,提升模型跨仪器泛化能力,增强模型在时空维度上的鲁棒性

Benefits of technology

[0047] (1) The spatiotemporal data allocation strategy proposed in this invention divides the spectral dataset to ensure that the training set contains the full concentration and matrix, thus avoiding distribution drift.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120995133B_ABST
    Figure CN120995133B_ABST
Patent Text Reader

Abstract

The application discloses a multi-scale anti-decoupling near-infrared spectrum model transfer method, comprising the following steps: acquiring near-infrared spectrum data sets of a source domain and a target domain, performing a time-space data allocation strategy in time and space dimensions, proportionally dividing the spectrum data sets, and pre-training a near-infrared spectrum model; extracting instrument-independent features and instrument-dependent features respectively through a neural network, performing anti-training, minimizing domain difference loss, and outputting a domain-invariant subset; inputting the instrument-dependent features, the near-infrared spectrum data set of the target domain and the domain-invariant subset into a generator to generate virtual spectrum data; adopting a dynamic weighted sampling strategy to adaptively adjust the sampling probability of the virtual spectrum data and real spectrum data, performing model training fine-tuning, deploying the fine-tuned model to a target instrument, and realizing cross-instrument transfer of the near-infrared spectrum model. The method greatly improves the cross-instrument generalization ability of the model and enhances the robustness of the spectrum model in time and space dimensions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of instrument calibration and chemometrics model transfer technology, and particularly to a near-infrared spectroscopy model transfer method and system. Background Technology

[0002] In recent years, near-infrared spectroscopy has been widely used in the detection of material characteristics in pharmaceuticals, agricultural products, and chemicals due to its rapid, non-destructive, and environmentally friendly characteristics. However, the attenuation of light sources and differences in detector sensitivity between different devices lead to spectral nonlinear distortion, and the distribution differences of spectral characteristics among different instruments necessitate repeated modeling for each instrument, increasing costs. This results in a current architecture of "one product, one model, single-machine operation," where the model is fixed and cannot be updated, failing to adapt to product changes or evolving needs. This leads to high costs of repeated modeling, difficulties in cross-category application, and an inability to meet the needs of multi-scenario, multi-target detection. To make a model applicable to one instrument applicable to another, model transfer is necessary to ensure the accuracy and consistency of prediction results across multiple instruments.

[0003] Among near-infrared model transfer methods, spectral correction methods are the most effective. However, traditional linear correction methods (such as Direct Correction (PDS) and Direct Normalized Partial Least Squares (DS-PLS)) cannot handle nonlinear instrument responses and high-frequency noise coupling issues; the initial sample size of the target instrument is insufficient to support deep learning model training; virtual spectra generated by traditional data augmentation methods and virtual spectra synthesized by conventional generative adversarial networks (GANs) lack instrument-specific noise characteristics, leading to overfitting of the model during fine-tuning and a negative transfer risk >20%.

[0004] Therefore, to address the problems existing in the above-mentioned technologies, there is an urgent need to propose a novel architecture for near-infrared spectral model transfer methods based on multi-scale adversarial decoupling and virtual enhancement. The key challenge in this research is how to separate instrument-related and irrelevant features using a dual-branch CNN, improve CycleGAN synthesis of target instrument-specific noise data, and achieve highly robust model transfer requiring only 10% of the target sample size. Summary of the Invention

[0005] To address the issues of nonlinear instrument response, high-frequency noise coupling, and insufficient target instrument data, and to improve the model's cross-instrument generalization ability and enhance its robustness in the spatiotemporal dimensions, this invention proposes a multi-scale adversarial decoupling near-infrared spectroscopy model transfer method and system.

[0006] In a first aspect, embodiments of this application provide a multi-scale adversarial decoupling near-infrared spectral model transfer method, the method comprising:

[0007] Model pre-training steps: Obtain near-infrared spectral datasets of source and target domains from the instrument, implement spatiotemporal data allocation strategy, divide the spectral dataset proportionally in time and space dimensions, and perform near-infrared spectral model pre-training based on the divided spectral dataset;

[0008] The steps for constructing a multi-scale adversarial feature decoupling network are as follows: Based on the near-infrared spectral dataset of the source domain, instrument-independent features and instrument-related features are extracted separately through a neural network, and adversarial training is performed to minimize the domain difference loss and output a domain-invariant subset.

[0009] The virtual spectral enhancement step involves inputting the instrument-related features, the near-infrared spectral dataset of the target domain, and the domain-invariant subset into the generator to generate virtual spectral data.

[0010] Dynamic weighted sampling fine-tuning steps: A dynamic weighted sampling strategy is adopted to adaptively adjust the sampling probabilities of virtual spectral data and real spectral data, perform model training and fine-tuning, and deploy the fine-tuned model to the target instrument to realize the cross-instrument transfer of the near-infrared spectral model.

[0011] In this embodiment of the invention, the above-mentioned model pre-training step further includes:

[0012] The near-infrared spectral dataset of the source domain is divided according to the data acquisition order in the time dimension and clustered by a dimensionality reduction algorithm in the spatial dimension. After uniformly distributing the samples, it is divided into training set, validation set and test set according to a custom ratio for model pre-training.

[0013] In this embodiment of the invention, the step of constructing a multi-scale adversarial feature decoupling network further includes:

[0014] Irrelevant feature extraction steps: Input the near-infrared spectral dataset from the source domain into the first branch of the dual-branch neural network to extract instrument-irrelevant features; the first branch uses spectral-spatial decomposition of residual blocks;

[0015] Relevant feature extraction steps: Input the near-infrared spectral dataset of the source domain into the second branch of the dual-branch neural network to extract instrument-related features; the second branch uses a noise-aware residual module;

[0016] Feature adversarial training steps: Input the extracted instrument-independent features and instrument-related features into the gradient inversion layer, and perform adversarial training through the domain discriminator and feature extractor in the gradient inversion layer to minimize the domain difference loss.

[0017] In this embodiment of the invention, the above-mentioned irrelevant feature extraction step further includes:

[0018] The first branch performs low-pass filtering on near-infrared spectral data to obtain a high-dimensional signal. It then performs principal component analysis on the spectral data to obtain a projection matrix, extracts the top-ranked principal components of a predetermined number, and converts the filtered high-dimensional signal into spectral data of a predetermined number of dimensions.

[0019] By applying a gated attention mechanism to the spectrum, wavelengths that do not contain material characteristic information in the converted spectral data are masked, the effective wavelength range is automatically identified, and global pooling is performed. The results of the spectral and spatial dimension processing are then connected in a skip connection to obtain instrument-independent features that retain the original spectral information.

[0020] In this embodiment of the invention, the above-mentioned related feature extraction step further includes:

[0021] The second branch performs second-order differentiation on the near-infrared spectral data to extract instrument-related noise features caused by instrument aging.

[0022] The noise features after second-order differentiation are reduced from high-dimensional noise features to a low-dimensional noise matrix containing high-frequency noise information through residual convolution.

[0023] The near-infrared spectral data are encoded using an instrument fingerprint encoding function to extract the instrument's inherent characteristics;

[0024] By fusing instrument noise features with inherent features through feature splicing, relevant instrument features can be extracted.

[0025] In this embodiment of the invention, the above-mentioned feature adversarial training step further includes:

[0026] The feature extractor learns the instrument-related features of the input, corrects its own parameters, generates noise information, and incorporates it into the instrument-independent features;

[0027] The domain discriminator improves its ability to distinguish between source and target domain spectra by learning the instrument-independent features of the input and correcting its own parameters.

[0028] The feature extractor and the domain discriminator learn adversarially. The feature extractor continuously maximizes the adversarial training loss function, and the domain discriminator continuously minimizes the adversarial training loss function. When a dynamic balance is reached between maximizing and minimizing the adversarial training loss function, the output domain-invariant subset is achieved.

[0029] In this embodiment of the invention, the above-mentioned spectral virtual enhancement step further includes:

[0030] The instrument-related features, the unlabeled spectral dataset of the target domain, and the domain-invariant subset are input into the generator, where dimensions are concatenated and the instrument-related features are expanded.

[0031] The wavelength dimension features are preserved, and the spliced ​​generator output values ​​are encoded and decoded. The noise features in the instrument-related features are injected into the unlabeled spectral dataset and the domain-invariant subset in the target domain to output a virtual spectrum.

[0032] In this embodiment of the invention, the above-mentioned dynamic weighted sampling fine-tuning step further includes:

[0033] A dynamic weighted sampling strategy is used to fine-tune the sampling weights of the fully connected layer. The formula for the weights is as follows:

[0034] Sampling weight = α(t) × virtual data sampling probability + (1-α(t)) × real data sampling probability; where α(t) is the dynamic weight coefficient of virtual data, t is the number of training rounds, and the value of α(t) is determined by the dynamic weighted sampling strategy.

[0035] In this embodiment of the invention, the above-mentioned dynamic weighted sampling strategy is as follows:

[0036] When t is in the first value range, α(t) = 0.9-0.02t. In each round, samples with values ​​greater than or equal to 90% are randomly collected from the virtual spectral data, and samples with values ​​less than or equal to 10% are collected from the real spectral data.

[0037] When t is in the second value range, α(t) = 0.7-0.02(t-10), the virtual spectrum collection value in each round gradually decreases from 70% to 30%, and the real fine-tuning set collection value gradually increases from 30% to 70%.

[0038] When t is in the third value range, α(t) = 0.3, and the sampling ratio of the virtual spectrum and the real fine-tuned spectrum is taken according to the preset threshold.

[0039] Secondly, embodiments of this application provide a multi-scale adversarial decoupling near-infrared spectral model transfer system. Employing the aforementioned multi-scale adversarial decoupling near-infrared spectral model transfer method, the system includes:

[0040] Model pre-training module: used to acquire near-infrared spectral datasets of source and target domains from the main instrument and target instrument, execute spatiotemporal data allocation strategy, divide the spectral dataset into proportional parts in time and space, and pre-train the near-infrared spectral model based on the divided spectral dataset;

[0041] Multi-scale adversarial feature decoupling network module: used for source domain-based near-infrared spectral datasets, it extracts instrument-independent features and instrument-dependent features through neural networks, performs adversarial training, minimizes domain difference loss, and outputs a domain-invariant subset;

[0042] Virtual Augmentation Controller Module: Used to input instrument-related features, near-infrared spectral datasets of the target domain, and domain-invariant subsets into the generator to generate virtual spectral data;

[0043] Dynamic Partitioning Module: Used to adopt a dynamic weighted sampling strategy to adaptively adjust the sampling probabilities of virtual spectral data and real spectral data, perform model training and fine-tuning, and deploy the fine-tuned model to the target instrument to realize cross-instrument transfer of near-infrared spectral models.

[0044] Thirdly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of a multi-scale adversarial decoupling near-infrared spectral model transfer method.

[0045] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of the multi-scale adversarial decoupling near-infrared spectral model transfer method as described above.

[0046] Compared with existing technologies, it has the following outstanding advantages:

[0047] (1) The spatiotemporal data allocation strategy proposed in this invention divides the spectral dataset to ensure that the training set contains the full concentration and matrix, thus avoiding distribution drift.

[0048] (2) The method of this invention proposes to extract instrument-independent features and instrument-dependent features separately through a dual-branch convolutional neural network (CNN), and then perform adversarial training through the domain discriminator and feature extractor in the gradient inversion layer to achieve domain invariance of the features. This solves the problems of nonlinear instrument response and high-frequency noise coupling;

[0049] (3) The method of this invention proposes to adaptively adjust the sampling probability of virtual data and real data through a dynamic weighted sampling strategy, which effectively reduces the risk that the initial sample size of the target instrument is insufficient and it is difficult to support the training of deep learning models.

[0050] (4) The present invention proposes a novel architecture for near-infrared spectral model transfer using multi-scale adversarial decoupling and virtual enhancement. By separating instrument-related and irrelevant features through a dual-branch CNN, and improving CycleGAN to synthesize target instrument-specific noise data, a highly robust model transfer method requiring only 10% of the target samples is achieved. Attached Figure Description

[0051] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0052] Figure 1 This is a schematic diagram of the near-infrared spectral model transfer method for multi-scale adversarial decoupling according to the present invention;

[0053] Figure 2 This is a schematic diagram of the near-infrared spectral model transfer method for multi-scale adversarial decoupling according to an embodiment of the present invention;

[0054] Figure 3 This is a schematic diagram of the near-infrared spectral model transfer system for multi-scale adversarial decoupling according to the present invention;

[0055] Figure 4 This is a schematic diagram of the computer hardware of the present invention. Detailed Implementation

[0056] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.

[0057] It should also be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.

[0058] It should also be understood that, in various embodiments of the present invention, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0059] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0060] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0061] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0062] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0063] To make the above-mentioned features and effects of the present invention clearer and easier to understand, specific embodiments are described below in conjunction with the accompanying drawings. This specification discloses one or more embodiments incorporating the features of the present invention. The disclosed embodiments are merely illustrative. The scope of protection of the present invention is not limited to the disclosed embodiments, but is defined by the appended claims.

[0064] The following are system embodiments corresponding to the above method embodiments. This embodiment can be implemented in conjunction with the above embodiments. The relevant technical details mentioned in the above embodiments are still valid in this embodiment, and will not be repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in this embodiment can also be applied to the above embodiments.

[0065] This invention aims to propose a novel architecture for near-infrared spectroscopy model transfer using multi-scale adversarial decoupling and virtual enhancement. By separating instrument-related and irrelevant features through a dual-branch CNN and improving CycleGAN synthesis of target instrument-specific noise data, a highly robust model transfer method requiring only 10% of the target sample size is achieved.

[0066] This invention relates to a cross-instrument adaptive migration and inter-instrument consistency calibration technology for near-infrared spectral models in scenarios such as pharmaceuticals and agricultural product testing.

[0067] The methods of this application will be described in detail below with reference to specific embodiments:

[0068] Example 1

[0069] like Figure 1 and Figure 2 As shown in the embodiments of this application, a near-infrared spectral model transfer method with multi-scale adversarial decoupling is provided, the method comprising:

[0070] Model pre-training step 101: Obtain near-infrared spectral datasets of source and target domains from the instrument, execute spatiotemporal data allocation strategies in time and space dimensions, divide the spectral dataset proportionally, and perform near-infrared spectral model pre-training based on the divided spectral datasets;

[0071] Specifically, in this embodiment of the invention, a spatiotemporal data allocation strategy is implemented, strictly dividing the data according to the data acquisition order in the time dimension, and uniformly distributing the samples after t-SNE clustering in the spatial dimension. In the dynamic data partitioning strategy, the temporal sequence segmentation simulates the effects of instrument aging, and feature space clustering ensures the consistency of chemical component concentration distribution across the training set, validation set, and test set.

[0072] Step 102 of constructing a multi-scale adversarial feature decoupling network: Based on the near-infrared spectral dataset of the source domain, extract instrument-independent features and instrument-related features through a neural network, perform adversarial training, minimize domain difference loss, and output a domain-invariant subset;

[0073] Specifically, in this embodiment of the invention, a multi-scale adversarial feature decoupling network is constructed. First, a dual-branch convolutional neural network (CNN) is used to extract instrument-independent features and instrument-dependent features respectively. The first branch uses a spectral-spatial decomposition residual block (SSD-ResBlock) to process the input spectral data and output instrument-independent features. The second branch uses a noise-aware residual module (NA-ResBlock) to extract instrument-dependent features, processes the original spectrum, and outputs instrument-dependent features. Then, the output features of the two branches are fused and connected to a domain discriminator via a gradient inversion layer (GRL) for adversarial training to minimize domain difference loss.

[0074] Spectral virtual enhancement step 103: Input the instrument-related features, the near-infrared spectral dataset of the target domain, and the domain-invariant subset into the generator to generate virtual spectral data;

[0075] Specifically, in this embodiment of the invention, spectral virtual enhancement transfer is performed. An improved CycleGAN is used to simulate the noise distribution of the target instrument, generating virtual spectral data based on a pre-trained master instrument model.

[0076] Step 104 of the dynamic weighted sampling fine-tuning: Adopt a dynamic weighted sampling strategy to adaptively adjust the sampling probability of virtual spectral data and real spectral data, perform model training fine-tuning, and deploy the fine-tuned model to the target instrument to realize the cross-instrument transfer of the near-infrared spectral model.

[0077] Specifically, in this embodiment of the invention, the virtual spectral data is mixed with 10% of the target instrument's real data, and a dynamic weighted sampling strategy is used to fine-tune the fully connected layer. The fine-tuned model is then deployed to the target instrument to verify the transfer effect, achieving "one model for multiple instruments".

[0078] In this embodiment of the invention, the above-mentioned model pre-training step 101 further includes:

[0079] The near-infrared spectral dataset of the source domain is divided according to the data acquisition order in the time dimension and clustered by a dimensionality reduction algorithm in the spatial dimension. After uniformly distributing the samples, it is divided into training set, validation set and test set according to a custom ratio for model pre-training.

[0080] More specifically, in this embodiment of the invention, a spatiotemporal data allocation strategy is implemented to divide the source domain spectral dataset. In the temporal dimension, the dataset is segmented according to the acquisition order: the source domain spectral dataset is strictly arranged in ascending order of timestamps, and sequentially divided into a training set (data from the first 60% of the time period), a validation set (data from the middle 20% of the time period), and a test set (data from the last 20% of the time period). This ensures that the test set covers future states, avoids the risk of time leakage, and allows the model to maintain relative stability in a long-term continuous dynamic prediction environment. In the spatial dimension, t-SNE clustering uniform sampling is adopted: the full-band high-dimensional spectral data is organized into a high-dimensional vector matrix (for N spectra at X wavelengths, the high-dimensional vector matrix is ​​N×X), the similarity between samples is calculated to form a distance matrix (N×N), t-SNE nonlinear dimensionality reduction is performed on the full-band spectral data, density clustering is performed, forming chemical composition similarity sub-clusters, and samples are randomly selected from each cluster in a 6:2:2 ratio as the training set, validation set, and test set. This ensures that the training set contains full concentration and matrix, avoiding distribution drift. Then, the data samples from the time and space dimensions are finally mixed and input into the model for model pre-training.

[0081] In this embodiment of the invention, step 102 of constructing a multi-scale adversarial feature decoupling network further includes:

[0082] Irrelevant feature extraction steps: Input the near-infrared spectral dataset from the source domain into the first branch of the dual-branch neural network to extract instrument-irrelevant features; the first branch uses spectral-spatial decomposition of residual blocks;

[0083] Relevant feature extraction steps: Input the near-infrared spectral dataset of the source domain into the second branch of the dual-branch neural network to extract instrument-related features; the second branch uses a noise-aware residual module;

[0084] Feature adversarial training steps: Input the extracted instrument-independent features and instrument-related features into the gradient inversion layer, and perform adversarial training through the domain discriminator and feature extractor in the gradient inversion layer to minimize the domain difference loss.

[0085] In this embodiment of the invention, the above-mentioned irrelevant feature extraction step further includes: the PCA-constrained residual block performs the following operations: principal component dimensionality reduction on the input spectral slice; learning the nonlinear mapping of the dimensionality-reduced features through a convolutional layer; and adding skip connections to preserve the original spectral information.

[0086] In the first branch, the near-infrared spectral data is low-pass filtered to obtain a high-dimensional signal. The projection matrix is ​​obtained by performing principal component analysis on the spectral data, and the top-ranked principal components are extracted. The filtered high-dimensional signal is then converted into spectral data of a preset number of dimensions.

[0087] By applying a gated attention mechanism to the spectrum, wavelengths that do not contain material characteristic information in the converted spectral data are masked, the effective wavelength range is automatically identified, and global pooling is performed. The results of the spectral and spatial dimension processing are then connected in a skip connection to obtain instrument-independent features that retain the original spectral information.

[0088] More specifically, in this embodiment of the invention, the instrument-independent feature F is extracted using the spectral-spatial decomposition residual block (SSD-ResBlock). inv The formula is:

[0089]

[0090] Spectral-empty coupled convolutional layer:

[0091] Principal Component Attention Gating: M spec =sigmoid(W T att U k );

[0092] Where X is the input spectrum, ⊙ represents spectral dimension convolution, ⊙ represents spatial dimension convolution, and K low W represents a low-pass filter. pca Let M be the projection matrix.spec U is the spectral attention mask, P is the pooling operation, and U is the spectral attention mask. k These are the first k PCA feature vectors. W T pca The transpose of the projection matrix reduces the high-dimensional features after spectral convolution to a low-dimensional form while preserving the main spectral information.

[0093] Y: The fusion result of spectral and spatial features, used for subsequent feature extraction. W T att The transpose of the attention projection matrix will transform the principal component U extracted by PCA. k Mapping to the attention space generates a weight vector that matches the number of bands.

[0094] The following is a detailed explanation using the formula:

[0095] First, a low-pass filter is applied to the near-infrared spectrum X. The intrinsic signal in the near-infrared spectrum is a low-frequency signal, while the instrument noise is a high-frequency signal. The high-frequency signal is filtered out by the low-pass filter, retaining the low-frequency intrinsic signal. The formula is as follows: The filtered low-frequency signal is still a high-dimensional signal. By performing PCA principal component analysis on the instrument's spectral data to obtain the projection matrix, the first d principal components are extracted, and the high-dimensional signal is converted into a d-dimensional signal. The formula is as follows: In full-band spectral data, not all wavelengths contain material characteristic information. By applying a gated attention mechanism to the spectrum, wavelengths lacking material characteristic information are masked, effectively identifying the relevant wavelength range and performing global pooling, as shown in the formula P(X⊙M). spec The results of processing the spectral and spatial dimensions are then skipped to obtain instrument-independent features that retain the original spectral information.

[0096] The value of d (the number of the first d principal components) typically ranges from 10 to 100. The optimal value needs to be determined based on the "cumulative variance contribution rate," that is, selecting the minimum number of principal components with a cumulative variance contribution rate ≥ 95% (or 98%, 99%). The selection of the number of principal components in PCA is based on the "cumulative variance contribution rate," which means "the proportion of the original data variance explained by the first d principal components." In near-infrared spectroscopy analysis, a cumulative variance contribution rate ≥ 95% is a conventional threshold (which can retain most of the essential information), while ≥ 98% is more stringent (suitable for scenarios with high accuracy requirements).

[0097] If the cumulative variance contribution rate is required to be 95%, d is usually taken as 20 to 50; if it is required to be 98%, d is usually taken as 30 to 70; if it is required to be 99%, d is usually taken as 50 to 100.

[0098] In this embodiment of the invention, the above-mentioned related feature extraction step further includes:

[0099] In the second branch, the near-infrared spectral data are subjected to second-order differentiation to extract the instrument-related noise characteristics caused by instrument aging.

[0100] The noise features after second-order differentiation are reduced from high-dimensional noise features to a low-dimensional noise matrix containing high-frequency noise information through residual convolution.

[0101] The near-infrared spectral data are encoded using an instrument fingerprint encoding function to extract the instrument's inherent characteristics;

[0102] By fusing instrument noise features with inherent features through feature splicing, relevant instrument features can be extracted.

[0103] More specifically, in this embodiment of the invention, the instrument-related features F are extracted using the noise-perceived residual module (NA-ResBlock). dep The formula is:

[0104]

[0105] in, H is a second-order differential operator. res For residual convolution, For feature concatenation, δ is the instrument fingerprint encoding function. A detailed explanation of the formula follows:

[0106] Instrument noise in near-infrared spectroscopy typically manifests as changes in spectral curvature. The magnitude of curvature reflects the rate of instrument aging. Instrument-related features derived from instrument noise are extracted by performing second-order differentiation on the spectrum X. The noise features after second-order differentiation contain a large amount of high-frequency noise information. Residual convolution is then used to reduce the dimensionality of the high-dimensional noise features to a low-dimensional noise matrix containing high-frequency noise information. The formula is as follows: In addition to the noise characteristics caused by instrument aging, it also includes the inherent characteristics of the instrument. The inherent characteristics of the instrument are extracted by encoding the spectrum X through the instrument fingerprint coding function, with the formula δ(X). The noise characteristics caused by instrument aging and the inherent characteristics of the instrument are fused by feature splicing to realize the extraction of relevant instrument features.

[0107] In this embodiment of the invention, the above-mentioned feature adversarial training step further includes:

[0108] The feature extractor learns the instrument-related features of the input, corrects its own parameters, generates noise information, and incorporates it into the instrument-independent features;

[0109] The domain discriminator improves its ability to distinguish between source and target domain spectra by learning the instrument-independent features of the input and correcting its own parameters.

[0110] The feature extractor and the domain discriminator learn adversarially. The feature extractor continuously maximizes the adversarial training loss function, and the domain discriminator continuously minimizes the adversarial training loss function. When a dynamic balance is reached between maximizing and minimizing the adversarial training loss function, the output domain-invariant subset is achieved.

[0111] More specifically, in this embodiment of the invention, the instrument-independent features and instrument-dependent features extracted from the source and target domain spectra by the spectral-spatial decomposition residual blocks are respectively input into the gradient inversion layer for feature adversarial training. The feature extractor in the gradient inversion layer continuously learns the input instrument-dependent features, continuously corrects its own parameters, generates noise information that is difficult for the domain discriminator to distinguish, and incorporates it into the instrument-independent features.

[0112] The domain discriminator continuously learns from the instrument-independent features of the input, constantly adjusting its parameters to improve its ability to distinguish between the source and target domain spectra. Through continuous adversarial learning, the feature extractor continuously maximizes the adversarial training loss function, while the domain discriminator continuously minimizes it. When they reach a dynamic equilibrium, the output domain-invariant subset is determined. Where the adversarial training loss function L adv The formula is:

[0113] L adv =E X-S [logD(F(X))]+E X-T [log(1-D(F(X)))]

[0114] Where F is the feature extractor, D is the domain discriminator, X is the input spectrum, S is the main instrument data, and T is the target instrument data. XS: indicates that the input spectrum X comes from the source domain S (i.e., the spectral data acquired by the main instrument); XT: indicates that the input spectrum X comes from the target domain T (i.e., the spectral data acquired by the target instrument); E X-S : Expectation of the source domain samples; E X-T : Expectation of the target domain samples.

[0115] In this embodiment of the invention, the above-mentioned spectral virtual enhancement step 103 further includes:

[0116] The instrument-related features, the unlabeled spectral dataset of the target domain, and the domain-invariant subset are input into the generator, where dimensions are concatenated and the instrument-related features are expanded.

[0117] The wavelength dimension features are preserved, and the spliced ​​generator output values ​​are encoded and decoded. The noise features in the instrument-related features are injected into the unlabeled spectral dataset and the domain-invariant subset in the target domain to output a virtual spectrum.

[0118] More specifically, in a specific embodiment of the present invention, the structured noise feature F dep Compared with the unlabeled data X in the target domain ′ Domain-invariant subsets Input to generator G S→T First, perform dimensional concatenation, then combine F... dep Extended to X via fully connected layers ′ , In the same dimension; using a U-Net structure (which excels at preserving wavelength-dimensional features) to encode and decode the concatenated input, F dep Noise features are injected into the spectrum X. ′ , In the middle, output virtual spectrum

[0119] Among them, the target unlabeled data X ′ : Spectral data acquired by the target instrument, but without corresponding labels obtained through standard laboratory methods. Its function is to provide the generator with "spectral structure information of the target domain," so that the generated virtual spectrum retains both the essential characteristics of the source domain (such as the chemical composition of substances) and conforms to the instrument characteristics of the target domain (such as baseline drift and noise patterns).

[0120] The formula is:

[0121]

[0122] Among them: G S→T For generator, X ′ For the unlabeled target data, It is a domain-invariant subset.

[0123] In this embodiment of the invention, the above-mentioned dynamic weighted sampling fine-tuning step 104 further includes:

[0124] A dynamic weighted sampling strategy is used to fine-tune the sampling weights of the fully connected layer. The formula for the weights is as follows:

[0125] Sampling weight = α(t) × virtual data sampling probability + (1-α(t)) × real data sampling probability; where α(t) is the dynamic weight coefficient of virtual data, t is the number of training rounds, and the value of α(t) is determined by the dynamic weighted sampling strategy.

[0126] In this embodiment of the invention, the above-mentioned dynamic weighted sampling strategy is as follows:

[0127] When t is in the first value range, α(t) = 0.9-0.02t. In each round, samples with values ​​greater than or equal to 90% are randomly collected from the virtual spectral data, and samples with values ​​less than or equal to 10% are collected from the real spectral data.

[0128] When t is in the second value range, α(t) = 0.7-0.02(t-10), the virtual spectrum collection value in each round gradually decreases from 70% to 30%, and the real fine-tuning set collection value gradually increases from 30% to 70%.

[0129] When t is in the third value range, α(t) = 0.3, and the sampling ratio of the virtual spectrum and the real fine-tuned spectrum is taken according to the preset threshold.

[0130] More specifically, in this embodiment of the invention, the virtual data (i.e., the virtual spectrum) is adaptively adjusted through training rounds. The sampling probability of the actual data is given by the formula:

[0131] Sampling weight = α(t) × virtual data sampling probability + (1-α(t)) × real data sampling probability

[0132] Where α(t) is the dynamic weight coefficient of the virtual data, which decreases with the training round t. The decay rate of α(t) is dynamically adjusted by the validation set RMSE: if the validation set RMSE decreases by more than 5% in a certain round, the decay rate of α(t) accelerates; if the RMSE increases, the decay is paused, and the current α(t) is maintained to avoid overfitting due to excessively high weights on the real data. The design is as follows:

[0133] When t is in the first value range, i.e., t = 1-10: α(t) = 0.9-0.02t. At this time, virtual spectral data dominates. In each round, 90% of the samples are randomly collected from the virtual spectral set, and 10% of the samples are collected from the real fine-tuning set to quickly learn noise features.

[0134] When t is in the second value range, i.e., t = 10-30, α(t) = 0.7-0.02(t-10). At this time, the weight of the virtual spectral data gradually weakens, and the virtual spectral data collection in each round decreases from 70% to 30%, while the real fine-tuning data collection decreases from 30% to 70%.

[0135] When t is in the third value range, i.e., t>30, α(t)=0.3. At this time, the real spectral data is dominant. The virtual spectrum: the real fine-tuned spectrum = 3:7 is fixed for sampling to prevent overfitting.

[0136] During fine-tuning, Radam was chosen as the optimizer. By dynamically adjusting the learning rate variance, gradient fluctuations during small-sample training were mitigated. The initial learning rate of the optimizer Radam was 1×10⁻³.

[0137] As described above, the method of the present invention can be implemented well.

[0138] In summary, this invention proposes a novel architecture for near-infrared spectroscopy model transfer using multi-scale adversarial decoupling and virtual enhancement. By separating instrument-related and irrelevant features through a dual-branch CNN and improving CycleGAN synthesis of target instrument-specific noise data, a highly robust model transfer method requiring only 10% of the target sample size is achieved.

[0139] Example 2

[0140] like Figure 3 As shown, this application provides a multi-scale adversarial decoupling near-infrared spectral model transfer system. Employing the aforementioned multi-scale adversarial decoupling near-infrared spectral model transfer method, the system includes:

[0141] Model pre-training module 201: used to acquire near-infrared spectral datasets of source and target domains from the main instrument and the target instrument, execute spatiotemporal data allocation strategies, divide the spectral datasets proportionally in time and space dimensions, and perform near-infrared spectral model pre-training based on the divided spectral datasets;

[0142] Multi-scale adversarial feature decoupling network module 202: used for source domain-based near-infrared spectral datasets, extracts instrument-independent features and instrument-related features through neural networks, performs adversarial training, minimizes domain difference loss, and outputs a domain-invariant subset;

[0143] Virtual Enhancement Controller Module 203: Used to input instrument-related features, near-infrared spectral dataset of the target domain, and domain-invariant subsets into the generator to generate virtual spectral data;

[0144] Dynamic Partitioner Module 204: Used to adopt a dynamic weighted sampling strategy to adaptively adjust the sampling probability of virtual spectral data and real spectral data, perform model training fine-tuning, and deploy the fine-tuned model to the target instrument to realize cross-instrument transfer of near-infrared spectral model.

[0145] The multi-scale adversarial feature decoupling network module includes a dual-branch feature decoupling module, a multi-scale input preprocessing module, and a gradient inversion layer; the virtual augmentation controller module integrates CycleGAN and a hybrid data fine-tuning module; and the dynamic partitioner module fine-tunes the fully connected layer.

[0146] Example 3

[0147] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the multi-scale adversarial decoupling near-infrared spectral model transfer method.

[0148] Example 4

[0149] This application provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps of the multi-scale adversarial decoupling near-infrared spectral model transfer method as described above.

[0150] In addition, combined Figure 1 The multi-scale adversarial decoupling near-infrared spectral model transfer method described in this application embodiment can be implemented by electronic devices, such as computer devices. Figure 4 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of this application.

[0151] In some embodiments, the computer device may further include a communication interface 83 and a bus 80. For example, Figure 4 As shown, the processor 81, memory 82, and communication interface 83 are connected through bus 80 and complete communication with each other.

[0152] Specifically, the processor 81 may include a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits that can be configured to implement the embodiments of this application.

[0153] The memory 82 can be used to store or cache various data files that need to be processed and / or communicated, as well as possible computer program instructions executed by the processor 81.

[0154] The processor 81 reads and executes the computer program instructions stored in the memory 82 to implement any of the multi-scale adversarial decoupling near-infrared spectral model transfer methods in the above embodiments.

[0155] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0156] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.

Claims

1. A near-infrared spectral model transfer method with multi-scale adversarial decoupling, characterized in that, The method includes: Model pre-training steps: Obtain near-infrared spectral datasets of source and target domains from the instrument, execute spatiotemporal data allocation strategies in time and space dimensions, divide the spectral datasets proportionally, and perform near-infrared spectral model pre-training based on the divided spectral datasets; The steps for constructing a multi-scale adversarial feature decoupling network are as follows: Based on the near-infrared spectral dataset of the source domain, instrument-independent features and instrument-related features are extracted through a neural network, and adversarial training is performed to minimize the domain difference loss and output a domain-invariant subset. The virtual spectral enhancement step involves inputting the instrument-related features, the near-infrared spectral dataset of the target domain, and the domain-invariant subset into the generator to generate virtual spectral data. Dynamic weighted sampling fine-tuning steps: A dynamic weighted sampling strategy is adopted to adaptively adjust the sampling probabilities of the virtual spectral data and the real spectral data, perform model training fine-tuning, and deploy the fine-tuned model to the target instrument to realize the cross-instrument transfer of the near-infrared spectral model; The step of constructing a multi-scale adversarial feature decoupling network further includes: Irrelevant feature extraction step: Input the near-infrared spectral dataset from the source domain into the first branch of a dual-branch neural network to extract instrument-irrelevant features; the first branch uses spectral-spatial decomposition residual blocks; Relevant feature extraction steps: Input the near-infrared spectral dataset from the source domain into the second branch of a dual-branch neural network to extract instrument-related features; the second branch uses a noise-aware residual module; Feature adversarial training steps: The extracted instrument-independent features and instrument-related features are input into the gradient inversion layer. Adversarial training is performed through the domain discriminator and feature extractor in the gradient inversion layer to minimize the domain difference loss.

2. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 1, characterized in that, The model pre-training step also includes: The near-infrared spectral dataset of the source domain is divided according to the data acquisition order in the time dimension and clustered by a dimensionality reduction algorithm in the spatial dimension. After uniformly distributing the samples, it is divided into training set, validation set and test set according to a custom ratio for model pre-training.

3. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 1, characterized in that, The irrelevant feature extraction step further includes: In the first branch, the near-infrared spectral data is low-pass filtered to obtain a high-dimensional signal. The projection matrix is ​​obtained by performing principal component analysis on the spectral data, and the top-ranked principal components are extracted. The filtered high-dimensional signal is then converted into spectral data of the preset number of dimensional signals. By applying a gated attention mechanism to the spectrum, wavelengths that do not contain material feature information in the converted spectral data are masked, the effective wavelength range is automatically identified, and global pooling is performed. The results of the spectral and spatial dimension processing are then connected in a skip connection to obtain instrument-independent features that retain the original spectral information.

4. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 1, characterized in that, The relevant feature extraction step further includes: In the second branch, the near-infrared spectral data is subjected to second-order differentiation to extract the instrument-related noise characteristics caused by instrument aging. The noise features after second-order differentiation are reduced from high-dimensional noise features to a low-dimensional noise matrix containing high-frequency noise information through residual convolution. The near-infrared spectral data is encoded using an instrument fingerprint encoding function to extract the instrument's inherent characteristics; By fusing the noise features and inherent features of the instrument through feature splicing, the relevant features of the instrument can be extracted.

5. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 3, characterized in that, The feature adversarial training step also includes: The feature extractor learns the input instrument-related features, corrects its own parameters, generates noise information, and incorporates it into the instrument-independent features; The domain discriminator improves its ability to distinguish between source and target domain spectra by learning the instrument-independent features of the input and correcting its own parameters. The feature extractor and the domain discriminator learn adversarially. The feature extractor continuously maximizes the adversarial training loss function, and the domain discriminator continuously minimizes the adversarial training loss function. When a dynamic balance is reached between maximizing and minimizing the adversarial training loss function, the output domain-invariant subset is generated.

6. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 1, characterized in that, The spectral virtual enhancement step further includes: The instrument-related features, the unlabeled spectral dataset of the target domain, and the domain-invariant subset are input into the generator, where dimensions are concatenated and the instrument-related features are expanded. The wavelength dimension features are preserved, and the spliced ​​generator output values ​​are encoded and decoded. The noise features in the instrument-related features are injected into the unlabeled spectral dataset of the target domain and the domain-invariant subset to output a virtual spectrum.

7. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 1, characterized in that, The dynamic weighted sampling fine-tuning step further includes: A dynamic weighted sampling strategy is used to fine-tune the sampling weights of the fully connected layer. The formula for the sampling weights is: Sampling weight = × Virtual data sampling probability + × Probability of sampling actual data; where... The virtual data dynamic weight coefficients, where t is the number of training rounds, are... The value is determined by the dynamic weighted sampling strategy.

8. The near-infrared spectral model transfer method for multi-scale adversarial decoupling according to claim 7, characterized in that, The dynamic weighted sampling strategy is as follows: When t is in the first range of values In each round, samples with values ​​greater than or equal to 90% are randomly collected from virtual spectral data, while samples with values ​​less than or equal to 10% are collected from real spectral data. When t is in the second range of values In each round, the virtual spectral collection values ​​were gradually reduced from 70% to 30%, while the real fine-tuning collection values ​​were gradually increased from 30% to 70%. When t is in the third value range The sampling ratio of the virtual spectrum to the real fine-tuned spectrum is determined according to a preset threshold.

9. A multi-scale adversarial decoupling near-infrared spectral model transfer system, employing the multi-scale adversarial decoupling near-infrared spectral model transfer method as described in any one of claims 1-8, characterized in that, The system includes: Model pre-training module: used to acquire near-infrared spectral datasets of source and target domains from the main instrument and target instrument, execute spatiotemporal data allocation strategy, divide the spectral datasets proportionally in time and space dimensions, and perform near-infrared spectral model pre-training based on the divided spectral datasets; Multi-scale adversarial feature decoupling network module: used for the near-infrared spectral dataset based on the source domain, extracting instrument-independent features and instrument-related features respectively through a two-branch CNN neural network, performing adversarial training to minimize domain difference loss and output a domain-invariant subset; Virtual Enhancement Controller Module: Used to input the instrument-related features, the near-infrared spectral dataset of the target domain, and the domain-invariant subset into the generator to generate virtual spectral data; Dynamic partitioner module: Used to adopt a dynamic weighted sampling strategy to adaptively adjust the sampling probability of the virtual spectral data and the real spectral data, perform model training and fine-tuning, and deploy the fine-tuned model to the target instrument to realize the cross-instrument transfer of the near-infrared spectral model.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps of the multi-scale adversarial decoupling near-infrared spectral model transfer method as described in any one of claims 1-8.

11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the near-infrared spectral model transfer method with multi-scale adversarial decoupling as described in any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for transferring on-line near infrared spectrum model of assumed standard sample

    CN113158575A