Crude oil origin identification method and system based on near infrared spectroscopy

Based on deep learning methods based on near -infrared spectrum, the U -shaped network model of feeling wild and transformer is established to solve the problem of cumbersome and low accuracy of crude oil origin. Accuracy.

CN118503839BActive Publication Date: 2025-01-28CHINA UNIV OF MINING & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410568907.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-09
Publication Date
2025-01-28
Estimated Expiration
2044-05-09

AI Technical Summary

Technical Problem

In the prior art, the identification process of crude oil origin is complicated, with low accuracy and low efficiency, and the traditional methods have problems such as complex operation, high cost and long time.

Method used

Adopting the identification method of crude oil based on near -infrared spectrum, by collecting near -infrared spectrum data from crude oil samples, and establishing a U -shaped network model of feeling wild and Transformer in combination with deep learning technology, the rapid and accurate traceability of crude oil production areas.

Benefits of technology

While maintaining high accuracy, the analysis cost is reduced, the interference of human factors is eliminated, the speed and identification accuracy of crude oil traceability is improved, and the lack of traditional methods is overcome.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503839B_ABST
    Figure CN118503839B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for identifying the origin of crude oil based on near-infrared spectroscopy, aiming to meet the needs of multiple fields such as crude oil trade, customs management, and industrial production. The traditional traceability method has cumbersome preparation work, expensive analytical instruments, and high requirements for the test environment, which limits its application in scientific research, industry, and management fields. The process of crude oil origin tracing in the present invention is: collecting crude oil near-infrared spectrum data, and comprehensively determining the origin information of the crude oil sample through industrial analysis and other methods; according to the characteristics of high-dimensional crude oil spectrum data, using the improved Mahalanobis distance elimination method to pre-process the sample set; building a U-shaped network deep learning model based on multi-receptive fields and Transformer, so that it is suitable for capturing the nonlinear relationship between crude oil spectrum and origin information. The present invention can simply and efficiently realize the rapid identification of the origin of crude oil samples.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of crude oil origin tracing, near infrared spectrum analysis and artificial intelligence, and more specifically to a crude oil origin identification method and system based on near infrared spectrum. Background Art

[0002] As a basic energy and industrial raw material, crude oil trade is an important part of the global energy market. The geological conditions under which crude oil is formed vary, resulting in differences in combustion characteristics, which is a key factor affecting trade prices. However, deceptive trade practices such as counterfeiting the origin of crude oil in order to avoid high taxes will bring huge economic losses and security risks to importing countries. In order to regulate the crude oil trade market, relevant countries have put forward strict requirements for the traceability of crude oil origins. Through advanced signal measurement methods and artificial intelligence technology to deeply perceive the chemical fingerprint information of crude oil, rapid detection of inbound crude oil can be achieved, which is of great significance for identifying deceptive trade practices and building an inbound crude oil safety early warning system. Traditional crude oil origin traceability methods require qualified laboratories to analyze its chemical composition according to national standards, comprehensively evaluate and issue crude oil origin traceability reports. Although these traditional detection methods are highly accurate, they often have disadvantages such as complex operation, high cost, and long time consumption, and are difficult to meet the needs of real-time detection.

[0003] The chemometric method based on near infrared spectroscopy is a fast, simple and non-destructive method for tracing the origin of the sample. -1 By using near-infrared light, we can obtain near-infrared spectral curves containing chemical and structural information of the sample. Then, we build a model with deep learning technology to find the nonlinear mapping relationship between the near-infrared spectrum of crude oil and its origin, so as to achieve rapid and accurate traceability of the origin of crude oil. The benefit of using near-infrared spectroscopy combined with deep learning technology is not only to improve the traceability speed and recognition accuracy of crude oil, but also to reduce analysis costs and eliminate interference from human factors. Therefore, this technology brings new opportunities and prospects for the research on crude oil origin traceability, and is expected to promote greater progress in scientific research. However, existing related methods still face problems such as insufficient robustness, making it difficult to accurately trace the origin of crude oil.

[0004] The Chinese patent application, publication number CN 114280000 A, records a method and system for tracing the origin of crude oil. The method provided collects crude oil samples from different countries to obtain the sample terahertz spectrum of the crude oil samples; uses a continuous wavelet algorithm to transform the sample terahertz spectrum into a wavelet space, extracts features from the wavelet space through cluster analysis and deep learning methods, and constructs a standard spectrum library of crude oil samples from different countries based on the weighted least squares method, and traces the origin of the crude oil samples based on the standard spectrum library. However, the terahertz spectroscopy analysis instrument used in this method is relatively expensive, and the sample preparation process is complicated; the feature extraction capability of the deep learning network used is weak, and the noise processing capability is poor. Summary of the invention

[0005] 1. Technical issues to be solved

[0006] In view of the problems existing in the prior art, such as the cumbersome process, low precision and low efficiency of crude oil origin identification, the present invention provides a method and system for crude oil origin identification based on near infrared spectroscopy. The method can capture the nonlinear relationship between crude oil spectrum and origin through deep learning modeling method, and realize accurate identification of crude oil origin.

[0007] 2. Technical solution

[0008] The purpose of the present invention is achieved through the following technical solutions.

[0009] One aspect of the present invention provides a method for identifying the origin of crude oil based on near infrared spectroscopy, comprising the following steps:

[0010] S1: Collect near-infrared spectral data of crude oil samples, determine the origin information of crude oil samples, generate origin information labels, and construct crude oil data sets. The origin information of crude oil samples can be determined by industrial analysis and other methods.

[0011] S2: According to the origin information of the samples in the crude oil dataset, they are grouped into subsets based on the origin, abnormal samples are removed in each subset, and the subsets after removal are merged to obtain the normal crude oil dataset.

[0012] Furthermore, the abnormal sample elimination method used is a method based on iterative regularized Mahalanobis distance and sub-band weighted elimination, which mainly includes: aiming at the masking effect and swamp effect that are prone to occur in traditional elimination methods, an iterative method is used to perform multiple rounds of abnormal sample elimination on the subset; in view of the problem that the matrix cannot be inverted in the Mahalanobis distance calculation of high-dimensional spectral sets, a regularization term is added to the covariance matrix in the Mahalanobis distance calculation; a method of giving higher weights to key areas such as the peak of the near-infrared spectrum of crude oil.

[0013] The steps of the iterative regularized Mahalanobis distance and sub-band weighted elimination method are as follows:

[0014] (1) Calculate the average spectrum of the rth wave number band as the center vector μ of the sample distribution (r) :

[0015]

[0016] m represents the total number of samples in this category. represents the rth spectral wavenumber band of the i-th sample;

[0017] (2) Calculate each near-infrared spectral wavenumber band To the average spectrum μ (r) The Mahalanobis distance

[0018]

[0019] is the regularized covariance matrix of the rth wave number band data set, defined as:

[0020]

[0021] X (r) represents the data set matrix, λ represents the regularization parameter, and I represents the identity matrix;

[0022] (3) Sort the Mahalanobis distance set in descending order and determine the lower quartile Q1 (r) and upper quartile Q3 (r) , and calculate the interquartile range IQR (r) =Q3 (r) -Q1 (r) ;

[0023] (4) Define the distance greater than Q3 (r) +2.5*IQR (r) The sample is an outlier, return index O r ;

[0024] (5) The outlier sample labels obtained from r different bands are taken as the union, that is, O = O 1 ∪O 2 ∪…∪O r , get the outlier sample number of the final iteration and remove it from the data set;

[0025] (6) Recalculate the average samples of the three wavenumber segments and the Mahalanobis distance between each sample and the new average sample for the eliminated sample set, and eliminate outliers again, that is, repeat steps (1) to (5) until no abnormal samples are produced.

[0026] S3: Divide the crude oil normal data set into training set, validation set and test set.

[0027] S4: Use the normal spectrum of crude oil and its origin information labels in the training set to input into the deep learning model for training, and use the validation set to input into the model for model verification to obtain the final model.

[0028] Furthermore, the deep learning model is a U-shaped network based on multiple receptive fields and Transformer, including feature extraction, feature fusion and classification head parts.

[0029] Among them, the backbone network of the feature extraction part adopts a multi-scale receptor block (MRFB) and a scSE (Concurrent Spatial and Channel Squeeze & Excitation) attention mechanism module, including a convolution layer, a batch normalization layer, an activation function layer, and a pooling layer; the multi-receptive field convolution block captures the information of near-infrared data from at least two different scales; the scSE attention mechanism module processes the output of the multi-receptive field convolution block and screens out important features. MRFB uses no less than two parallel convolution layers with different receptive fields, and the final extracted features are obtained by adding matrix elements to obtain the output of MRFB. The scSE attention mechanism module is used to process the output of MRFB, which not only screens out important features, but also enhances the network's anti-noise ability. The scSE attention mechanism module includes a channel attention (Spatial Squeeze and Channel Excitation Block, cSE) block and a spatial attention (Channel Squeeze and Spatial Excitation Block, sSE) block.

[0030] The backbone network of the feature fusion part adopts the Global-Multiscale Transformer Block (GMTB), including MRFB, self-attention block, batch normalization layer, and forward propagation block. The self-attention module in the GMTB is connected in parallel with the multi-receptive field convolution block to capture local information of different receptive fields. The self-attention module includes position encoding, linear layer, softmax layer and scSE attention mechanism module. The feature fusion part adopts the skip connection mechanism, which fuses the output of the feature extraction module of the corresponding layer and the feature fusion module of the previous layer as the input of the feature fusion module of this layer, realizing the fusion of low-level detail information and high-level semantic information.

[0031] The backbone network of the classification head consists of no less than two linear layers.

[0032] S5: Input the test set into the final model to obtain the origin information corresponding to the crude oil samples.

[0033] Another aspect of the present invention further provides a crude oil origin identification and analysis system based on near infrared spectroscopy, which applies a crude oil origin identification method based on near infrared spectroscopy provided in the first aspect of the present invention. The software system that can be developed based on the above algorithm integrates near infrared spectroscopy technology and deep learning technology, and the user can obtain the crude oil origin tracing analysis results by directly connecting to a near infrared spectrometer to measure the oil sample or submitting the near infrared spectrum of the crude oil.

[0034] 3. Beneficial effects

[0035] Compared with the prior art, the advantages of the present invention are:

[0036] (1) The present invention uses near-infrared spectroscopy combined with deep learning technology to apply to the task of crude oil origin tracing. While maintaining high accuracy, it overcomes the problems of traditional identification methods such as cumbersome preparation work, expensive analytical instruments, and high requirements for the test environment.

[0037] (2) The present invention designs a method for removing outliers specifically for high-dimensional near-infrared spectral data. An iterative method is used to remove abnormal samples from subsets in multiple rounds to deal with the masking effect and swamp effect that are prone to occur in traditional removal methods; by adding regularization to the covariance matrix in the Mahalanobis distance calculation, the problem that the covariance matrix of the high-dimensional near-infrared spectral data set cannot be inverted is solved; by giving higher weights to key areas such as near-infrared spectral peaks, a more accurate removal of outliers is achieved.

[0038] (3) Aiming at the characteristics of one-dimensional data of crude oil near-infrared spectrum, the present invention designs a U-shaped network based on multi-receptive fields and Transformer for classification. The feature extraction part adopts MRFB to capture more information of near-infrared data from multiple different scales. The output of MRFB is processed by using the scSE attention mechanism module, which not only screens out important features but also enhances the anti-noise ability of the network. The feature fusion part adopts GMTB to capture global and local comprehensive information at the same time. The jump connection mechanism is introduced, and the output of the feature extraction module of the corresponding layer and the feature fusion module of the previous layer are fused as the input of the feature fusion module of this layer, thereby realizing the fusion of low-level detail information and high-level semantic information. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] Figure 1 The flowchart of the method for identifying the origin of crude oil based on near infrared spectroscopy is shown;

[0040] Figure 2 This is a schematic diagram of the near infrared spectrum of some crude oils;

[0041] Figure 3 This is a box diagram of the first round of iteration of the improved abnormal sample elimination method based on Mahalanobis distance;

[0042] Figure 4 This is a box diagram of the second round of iteration of the improved abnormal sample elimination method based on Mahalanobis distance;

[0043] Figure 5 This is a box diagram of the third round of iteration of the improved abnormal sample elimination method based on Mahalanobis distance;

[0044] Figure 6 This is a U-shaped network structure diagram based on multiple receptive fields and Transformer;

[0045] Figure 7 Schematic diagram of a multi-scale receptor block (MRFB);

[0046] Figure 8 This is a schematic diagram of the scSE (Concurrent Spatial and Channel Squeeze & Excitation) attention mechanism module;

[0047] Fig. 9 Schematic diagram of the global-local Transformer (Global-Multiscale Transformer Block, GMTB). DETAILED DESCRIPTION

[0048] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0049] Example 1

[0050] Figure 1 This is a flow chart of the crude oil origin identification method based on near-infrared spectroscopy.

[0051] The present invention provides a crude oil origin identification method and software system based on near infrared spectroscopy, which can quickly analyze and predict the origin of crude oil, and specifically includes the following steps:

[0052] S1: Collect near-infrared spectral data of crude oil samples, and comprehensively determine the origin information labels of crude oil samples through industrial analysis and other methods to construct a crude oil dataset.

[0053] The present invention selects samples based on the common crude oil types in China's customs imports and exports. As shown in Table 1, near-infrared spectral data of 890 crude oil samples were collected from 11 different sampling points around the world, covering major oil-producing areas such as the Arabian Peninsula in western Asia, western Africa, eastern South America, and West Texas in North America. At the same time, the selected crude oil data set covers three different densities, light, medium, and heavy, as well as a variety of types of crude oil samples with two different sulfur contents, high sulfur and sulfur-containing, ensuring data diversity.

[0054] like Figure 2 The figure shows the schematic diagram of the near infrared spectrum of some crude oils. The near infrared spectrum is a typical one-dimensional data, the horizontal axis represents the wave number range of the near infrared spectrum, and the vertical axis represents the absorbance value of the sample at the corresponding wave number point.

[0055] S2: According to the origin information of the samples in the crude oil dataset, they are grouped into subsets based on the origin, abnormal samples are removed in each subset, and the subsets after removal are merged to obtain the normal crude oil dataset.

[0056] Abnormal samples will interfere with data analysis and mislead the model training process, thus affecting the final prediction results. In order to deal with masking and swamping effects, an iterative method will be used for elimination. The average spectrum and the Mahalanobis distance of each sample to the new average spectrum are recalculated for the sample set after the first elimination, until no abnormal samples are produced, and it is determined that the outliers are completely eliminated. When the data dimension exceeds the number of samples, the covariance matrix in the Mahalanobis distance is prone to being insufficient rank, resulting in the phenomenon that the matrix cannot be inverted. In this regard, based on the idea of ​​regularization, regular terms are added to the calculation of the covariance matrix, so that the covariance matrix becomes a non-singular matrix, thereby solving the problem that the Mahalanobis distance cannot be calculated for high-dimensional data. Some abnormal samples are far away from the average spectrum at the peak, but are very close to the average spectrum in other wavenumber bands, resulting in the overall distance of the abnormal sample being less than the set threshold and will not be eliminated. This embodiment is for 4500-4000cm -1 、6000-5500cm -1 (two peak areas) and 7500-4000cm -1 (Complete band) The above method is used to remove outliers respectively, and the union of the outlier removal results of the three wave number bands is taken as the outlier removal result O of this round of iteration. By giving higher attention to the peak area of ​​the near infrared spectrum, potential abnormal samples are detected and the accuracy of outlier removal is improved.

[0057] The improved Mahalanobis distance abnormal sample removal is performed in the data set of each category, and its specific steps are as follows:

[0058] (1) Calculate the average spectrum of the rth wave number band as the center vector μ of the sample distribution (r) :

[0059]

[0060] m represents the total number of samples in this category. Represents the rth spectral wavenumber band of the i-th sample.

[0061] (2) Calculate each near-infrared spectral wavenumber band To the average spectrum μ (r) The Mahalanobis distance

[0062]

[0063] is the regularized covariance matrix of the rth wave number band data set, defined as:

[0064]

[0065] X (r) is the dataset matrix, λ represents the regularization parameter, and I represents the identity matrix.

[0066] (3) Sort the Mahalanobis distance set in descending order and determine the lower quartile Q1 (r) and upper quartile Q3 (r) , and calculate the interquartile range IQR (r) =Q3 (r) -Q1 (r) .

[0067] (4) Define the distance greater than Q3 (r) +2.5*IQR (r) The sample is an outlier, return index O r .

[0068] (5) The outlier sample labels obtained from the three different bands are taken as the union, that is, O = O 1 ∪O 2 ∪O 3 , get the outlier sample number of the final iteration and remove it from the data set.

[0069] (6) Recalculate the average samples of the three wavenumber segments and the Mahalanobis distance between each sample and the new average sample for the eliminated sample set, and eliminate outliers again, that is, repeat steps (1) to (5) until no abnormal samples are produced.

[0070] The improved abnormal sample elimination method based on Mahalanobis distance was used to clean the crude oil data set used in the present invention, and three rounds of iterations were performed on three near-infrared spectral wavenumber bands of 11 categories. Figures 3 to 5The figure shows a box diagram of three rounds of iterations of the improved Mahalanobis distance-based abnormal sample elimination method. Figure 3 Taking Sarir as an example, the horizontal axes A, B, and C represent the 7500-4000cm in the Sarir category. -1 4500-4000cm -1 、6000-5500cm -1 Regularized Mahalanobis distance datasets for three wave number bands. From the overall trend, the red median horizontal line of most categories is located in the lower half of the blue box, proving that most samples have a high similarity with the average sample, the data quality is high, and the model can better capture the common features between data rather than sample-specific noise or outliers. In addition, it can be clearly seen from the box plot that the red solid origin in the figure is mostly kept at a relatively far distance from the blue box, which means that the data points classified as abnormal samples are significantly different from the main part of the data, and the confidence of data cleaning is high. Table 2 shows the results of improved outlier removal based on Mahalanobis distance. The entire cleaning process was carried out under 11 categories, and a total of 46 abnormal samples were removed.

[0071] S3: The present invention adopts five-fold stratified cross validation, and in each fold, 20% of the data is used for testing. Of the remaining 80% of the data, 10% is used as a validation set to select the hyperparameters of the corresponding model, and the rest of the data is used to train the model. By stratifying the data when dividing the normal crude oil data set, the proportion of samples of different categories in the training set, validation set, and test set is ensured to be similar, thereby improving the generalization ability of the model on real data.

[0072] S4: The normal spectrum of crude oil and its origin information labels in the training set are input into the U-shaped network based on multi-receptive fields and Transformer to train the model, and the validation set is input into the network to verify the model. After multiple training and verification, the final model is obtained. Figure 6 As shown in the figure, the U-shaped network based on multi-receptive fields and Transformer includes three key parts: feature extraction, feature fusion and classification head. Among them, L and C represent the sequence length and number of channels of the feature matrix respectively.

[0073] In the feature extraction stage, preferably, this embodiment uses four feature extraction modules, and other numbers of feature extraction modules may also be used in other embodiments. Each module includes MRFB and scSE attention mechanism modules. MRFB converts the original near-infrared signal into deep semantic information based on receptive fields of different scales, thereby improving the abstract representation ability of the data. The scSE attention mechanism module is responsible for further filtering features and suppressing noise from two dimensions, channel and space, to ensure that the extracted features have higher quality and distinguishability. Assume that the original near-infrared spectral input is defined as The number of channels is expanded to 2 after the linear layer. The output features of each feature extraction module are defined as Among them, a = 1, 2, 3, 4, corresponding to the four stages of feature extraction. During the entire feature extraction stage, the channel dimension of the feature matrix is ​​doubled through MRFB, and the sequence length is halved through average pooling, with a step size of 16. This design aims to reduce the computational burden and network complexity while retaining key information.

[0074] like Figure 7 Shown is a schematic diagram of a multi-receptive field convolution block. In this embodiment, MRFB has four parallel branches, each of which contains two convolution blocks, and each convolution block includes a convolution layer with a convolution kernel of k, a batch normalization layer, and a Mish activation function layer. Among them, the batch normalization layer is used to standardize the input data so that the network can converge faster. The Mish activation function layer introduces a nonlinear relationship into the model, and improves the expressive power of the model by retaining smaller negative inputs to a certain extent. The first convolution block of each branch not only extracts the corresponding receptive field features, but also has the function of expanding the number of channels. The structure of the second convolution block of the branch is similar to the first one, but the number of channels of its input and output is the same. Finally, the output features of the four branches are added by matrix elements to obtain the total output MRFB (F a ). The mathematical expression of the MRFB module is as follows:

[0075] MRFB(F a )=Conv2 k=1 (Conv1 k=1 (F a ))⊕Conv2 k=3 (Conv1 k=3 (F a ))⊕Conv2 k=5 (Conv1 k=5 (F a ))⊕Conv2 k=7 (Conv1 k=7 (F a ))

[0076] Among them, Conv1 k (·) indicates a convolution block whose output channels are twice as many as the input channels, Conv2 k (·) represents a convolutional block with the same number of output and input channels, k is the convolution kernel parameter of the convolution layer in the convolutional module, and ⊕ represents the addition of matrix elements.

[0077] Through four convolutional layers with different receptive fields, MRFB can not only better cope with the changes and noise of near-infrared spectral data at different scales and obtain diversified features, but also avoid the model's over-reliance on features of a single scale, making the model more generalizable.

[0078] like Figure 8 As shown in Figure 1, the scSE attention mechanism module includes a channel attention (cSE) block and a spatial attention (sSE) block. In cSE, the input data is processed by an adaptive average pooling layer to obtain a feature matrix of dimension (C, 1), which is used to capture the global context information of each channel in the feature. Since there is no weight parameter inside the adaptive average pooling, a convolutional layer is also needed to process the feature matrix so that this part can optimize the weight through back propagation to enhance the expressiveness of the module. Two convolutional layers with a convolution kernel of 1 are used to first halve the number of channels in the feature matrix and then restore it to obtain a weight matrix. The weight matrix is ​​then converted using the Sigmoid function to obtain the weight distribution of different channels. The new weight matrix is ​​multiplied by the input data to obtain the channel weight output. In sSE, the input data is processed by a convolutional layer with both the output channel and the convolution kernel of 1 to obtain a weight matrix of dimension (1, L). The weight matrix is ​​converted to a probability distribution between 0 and 1 by the Sigmoid function to assign corresponding weights to different positions in the sequence space. The weight matrix is ​​multiplied by the input data to obtain the spatial weight output matrix after the sequence spatial attention distribution. Finally, the spatial weight output is added to the channel weight output matrix elements to obtain the output of scSE with dimension (C, L). scSE can filter out important features without changing the dimension of the input data, thus enhancing the network's ability to resist noise. Assume X a is the input of scSE, F a+1 = scSE(X a ) is the output of scSE. The mathematical expression of scSE is as follows:

[0079]

[0080] in, represents a convolutional layer with the same number of output and input channels, represents a convolutional layer whose output is half the number of input channels, represents a convolutional layer whose output is twice the input channel, k represents the convolution kernel parameter, Pool(·) represents adaptive average pooling, σ represents the Sigmoid activation function, Represents matrix multiplication.

[0081] The feature fusion part includes four feature fusion modules, and its backbone structure is GMTB. The input of the first feature fusion module comes directly from the fourth feature extraction block F 4 , the inputs of other feature fusion modules come from the output of the feature fusion module of the previous layer and the output of the feature extraction module of its corresponding layer. Among them, the output feature of the feature fusion module is defined as Where b = 1, 2, 3, 4. For example, the input of feature fusion block 2 comes from the output of feature fusion block 1 and the output of feature extraction block 3 The concatenation operation is used to concatenate the two in the channel dimension to obtain a feature matrix with a dimension of (L / 8, 8C). The convolution block with a convolution kernel of 3 is used to reduce the channel dimension to achieve a preliminary fusion of low-level detail information and high-level semantic information, and obtain the input of GMTB. The mathematical expression of this process is as follows:

[0082] X b ′=Conv2 k=3 (concat(F b ' -1 ,F 5 ' -b )),b=2,3,4

[0083] Among them, concat represents the matrix concatenation at the channel level. Through skip connections, the feature fusion block can obtain low-level detail information and high-level semantic information. This concatenation of different levels can retain the detailed information such as the waveform in the spectrum to the greatest extent, providing a richer feature representation for the subsequent classification head. At the same time, this structure is similar to the skip connection of ResNet, which helps to alleviate the gradient vanishing problem, allowing deeper networks to learn useful features more effectively.

[0084] like Fig. 9 The figure shows a schematic diagram of the Global-Multiscale Transformer Block (GMTB). In addition to the batch normalization layer, residual connection and feedforward neural network in the Transformer architecture, GMTB also includes a self-attention module and an MRFB module.

[0085] The self-attention block is a core of Transformer, which can capture the dependencies between different positions and better understand the global information. Position encoding information is given to assist the self-attention mechanism, which enables the model to effectively capture the correlation between different positions. Commonly used position encoding includes a combination of sine and cosine functions. Since near-infrared spectral data is a one-dimensional sequence data, the formula for adding position encoding to the feature matrix obtained after feature extraction can be simplified as follows:

[0086] PE=sin(pos)

[0087] Among them, pos represents the position index matrix of the sequence space dimension. The broadcast mechanism is used to connect PE and X b ″, we can get the feature matrix X with position encoding information. b ″′. Feature matrix X b After linear transformation, ″′ obtains the feature matrix Q, K, and V. Through self-attention calculation, the output Attention(Q, K, V) of the self-attention module is obtained, and its mathematical expression is as follows:

[0088]

[0089] Among them, d K Indicates the feature dimension size of the input matrix K, which is used to scale the matrix multiplication result. After scaling, the calculation is not affected by the input dimension d K impact.

[0090] The self-attention module is connected in parallel with the MRFB, so that the feature fusion module can not only integrate the global context information, but also capture the local information of different receptive fields, further enriching the feature representation. Compared with the MRFB of the feature extraction module, the MRFB in the GMTB lacks the first convolution module, and its mathematical expression is as follows:

[0091] MRFB′(X b ″)=Conv2 k=1 (X b ″)⊕Conv2 k=3 (X b ″)⊕Conv2 k=5 (X b ″)

[0092] In the entire feature fusion part, the number of channels of the feature matrix is ​​halved, the sequence length is doubled, and the step length is 16. The changes in the sequence space and channel dimensions are both implemented through ConvTranspose. In the feature fusion module, changing the sequence space and channel dimensions can not only save computing resources, but also align the feature matrix with the output of the corresponding feature extraction module, improving the feature fusion efficiency between low-level detail information and high-level semantic information.

[0093] The classification head is the tail of the entire network architecture. It uses two fully connected layers and the Mish activation function to process the output of the feature fusion module, map the feature vector to the category probability space, and generate the final category prediction.

[0094] S4: Based on the above five-fold stratified cross-validation strategy, in each fold, the test set is input into the final model to obtain the origin information corresponding to the crude oil sample, and the average value of the evaluation index obtained from the five test sets is used as the final test set evaluation index.

[0095] Preferably, the deep learning network used in steps S2 to S4 in this embodiment is based on the PyTorch framework, and uses the Adam optimizer with a regularization weight of 0.001. The initial learning rate is set to 0.0001, and the ReduceLROnPlateau learning rate decay strategy is used to dynamically adjust the learning rate according to the loss value of the validation set. The size of each batch is 64, and the maximum number of iterations is set to 150.

[0096] The network from step S2 to step S4 uses classification accuracy (Acc) as the evaluation index of the embodiment of the present invention. Assuming there are N categories, the overall prediction accuracy Acc of the model is:

[0097]

[0098] Among them, TP i N represents the number of true examples of the i-th category, that is, the sample data in the i-th category that is correctly classified as the i-th category, i Represents the total number of the i-th category. Correspondingly, the prediction accuracy of each category can be obtained by dividing the number of true examples of the category by the total number of category samples and then multiplying by 100%.

[0099] In order to verify its performance in crude oil origin tracing, the proposed method was extensively evaluated. The experimental data is a crude oil near-infrared spectrum dataset. Three classic machine learning networks were introduced for comparison, including support vector classification (SVC), random forest (RF) and partial least squares discriminant analysis (PLS-DA).

[0100] For traditional machine learning models, data recovery is usually performed on the data set before the near-infrared spectral data is input into the model to reduce the impact of factors such as particle size and path length changes, thereby improving the prediction accuracy of the model. Two sets of experiments were set up for each traditional machine learning model, one without data recovery (SNV) and one with data recovery, to explore the impact of data recovery on the performance of traditional machine learning. SNV is a commonly used near-infrared spectral data recovery method. The spectrum processed by SNV The calculation formula is as follows:

[0101]

[0102] Among them, x ij and Represents the near infrared spectrum x i The spectral value and average spectral value of the j-th wavelength point.

[0103] The deep learning model has a stronger ability to extract features and, to a certain extent, has the ability to avoid the negative effects of noise, so no data recovery operation is performed.

[0104] Table 3 shows the experimental results of the comparison of different modeling methods. Without data recovery (SNV), the overall accuracy of RF is only 77.61%, while the overall accuracy of SVM and PLS-DA is higher, 94.08% and 95.50% respectively. After SNV is performed on the near-infrared spectrum of crude oil, the overall accuracy of the three traditional machine learning methods has been improved to varying degrees, reaching about 95%. This shows that SNV can reduce the influence of baseline drift and noise in the data, so that traditional machine learning algorithms can more accurately capture the relationship between data and better distinguish samples of different categories, thereby improving the quality and distinguishability of features. The U-shaped network based on multi-receptive fields and Transformer breaks through the bottleneck of the above traditional machine learning methods, and the overall accuracy reaches the highest 96.92%. Moreover, this method is a modeling training for near-infrared spectra without SNV data preprocessing, which proves to a certain extent that this network has a high noise processing ability and can achieve an overall accuracy better than the above three cases without data recovery.

[0105] In addition, the present invention can achieve a classification accuracy of more than 98% in most categories, especially for Rabbi, where its classification accuracy is higher than other methods. The classification accuracy of the methods used in sand weight is not high, which may be due to the fact that the features of the sand weight category overlap more with other categories, or there is more noise, making it difficult for various classification methods to extract effective classification information from it.

[0106] In order to verify the effectiveness of the modules in the proposed method, five sets of ablation experiments were designed to compare with the complete method. Throughout the experiment, the datasets, loss functions, optimizers, etc. used were kept consistent to ensure that the observed performance differences were only due to changes in the network architecture. As shown in Table 4, the overall accuracy of the baseline (ConvU) using convolutional blocks to replace the original modules in the network as the ablation experiment was only 91.94%. By adding MRFB, scSE and GMTB respectively, the overall accuracy was improved to varying degrees, by 1.31%, 2.14% and 3.44% respectively. This shows that the three modules used in this article have a positive effect on the performance of the network when used alone. The overall accuracy of using MRFB and scSE modules at the same time is 94.55%, which is higher than the overall accuracy of 93.25% and 94.08% of the single MRFB and scSE modules respectively. This shows that the fusion of these two modules can better capture the characteristics of the input data and eliminate noise, which has a positive effect on improving the overall accuracy of the network. With the synergistic effect of the three modules, the overall accuracy of the network reached the highest 96.92%.

[0107] Finally, based on the above algorithm, a crude oil origin tracing analysis software can be developed. The software integrates near-infrared spectroscopy technology and deep learning technology. Users can obtain crude oil origin tracing analysis results by directly connecting to a near-infrared spectrometer to measure oil samples or submitting the near-infrared spectrum of crude oil.

[0108] Table 1 Crude oil near infrared spectroscopy data set

[0109]

[0110] Table 2 Improved outlier removal results based on Mahalanobis distance

[0111]

[0112]

[0113] Table 3 Comparison of experimental results of different modeling methods

[0114]

[0115] Table 4 Ablation experimental results of the method of the present invention

[0116]

[0117]

[0118] The above schematically describes the invention and its implementation methods, which is not restrictive. Without departing from the spirit or basic features of the invention, the invention can be implemented in other specific forms. What is shown in the accompanying drawings is only one of the implementation methods of the invention. The actual structure is not limited thereto, and any figure mark in the claims should not limit the claims involved. Therefore, if a person of ordinary skill in the art is inspired by it, without departing from the purpose of the invention, a structural method and an embodiment similar to the technical solution are designed without creativity, which should all belong to the protection scope of the present invention. In addition, the word "including" does not exclude other elements or steps, and the word "one" before the element does not exclude the inclusion of "multiple" elements. The multiple elements stated in the product claim can also be implemented by one element through software or hardware. The words first, second, etc. are used to indicate the name, and do not indicate any specific order.

Claims

1. A method for identifying the origin of crude oil based on near infrared spectroscopy, characterized in that: The steps include: S1: Collect near-infrared spectral data of crude oil samples, determine the origin information of crude oil samples, generate origin information labels, and construct crude oil data sets; S2: According to the origin information of the samples in the crude oil data set, the samples are grouped into subsets based on the origin, abnormal samples are removed in each subset, and the removed subsets are merged to obtain the normal crude oil data set; the abnormal sample removal method is based on iterative regularized Mahalanobis distance and sub-band weighted removal method, and the steps are as follows: (1) Calculate the average spectrum of the rth wave number band as the center vector μ of the sample distribution (r) : m represents the total number of samples in this category. represents the rth spectral wavenumber band of the i-th sample; (2) Calculate the wavenumber of each near-infrared spectrum To the average spectrum μ (r) The Mahalanobis distance is the regularized covariance matrix of the rth wave number band data set, defined as: X (r) represents the data set matrix, λ represents the regularization parameter, and I represents the identity matrix; (3) Sort the Mahalanobis distance set in descending order and determine the lower quartile Q1 (r) and upper quartile Q3 (r) , and calculate the interquartile range IQR (r) =Q3 (r) -Q1 (r) ; (4) Define the distance greater than Q3 (r) +2.5*IQR (r) The sample is an outlier, return index O r ; (5) The outlier sample labels obtained in r different bands are taken as the union, that is, O = O1∪O2∪…∪O r , get the outlier sample number of the final iteration and remove it from the data set; (6) Recalculate the average samples of the three wavenumber segments and the Mahalanobis distance between each sample and the new average sample for the eliminated sample set, and eliminate outliers again, that is, repeat steps (1) to (5) until no abnormal samples are produced; S3: Divide the normal crude oil data set into training set, validation set and test set; S4: Use the normal spectrum of crude oil in the training set and its origin information label to input into the deep learning model for training, use the validation set to input into the model for model validation, and obtain the final model; S5: Input the test set into the final model to obtain the origin information corresponding to the crude oil samples.

2. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 1, characterized in that: The deep learning model is a U-shaped network based on multiple receptive fields and Transformer. It includes feature extraction, feature fusion and classification head parts.

3. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 2, characterized in that: The backbone network of the feature extraction part adopts multi-receptive field convolution blocks and scSE attention mechanism modules. The multi-receptive field convolution blocks capture the information of near-infrared data from at least two different scales; the scSE attention mechanism module processes the output of the multi-receptive field convolution blocks and filters out important features.

4. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 3, characterized in that: The backbone network of the feature fusion part of the U-shaped network based on multi-receptive fields and Transformer adopts a global-local Transformer block, including a multi-receptive field convolution block, a self-attention block, a batch normalization layer, and a forward propagation block; a jump connection mechanism is used to fuse the output of the feature extraction module of the corresponding layer and the feature fusion module of the previous layer as the input of the feature fusion module of this layer.

5. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 4, characterized in that: The backbone network of the classification head consists of no less than two linear layers.

6. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 5, characterized in that: The multi-receptive field convolution block uses no less than two parallel convolution layers with different receptive fields; the final extracted features are obtained by adding matrix elements to obtain the output of the multi-receptive field convolution block.

7. The method for identifying the origin of crude oil based on near infrared spectroscopy according to claim 6, characterized in that: Self-attention block in the global-local Transformer block,The self-attention module is connected in parallel with the multi-receptive field convolution block to capture local information of different receptive fields.

8. A crude oil origin identification system based on near infrared spectroscopy, characterized in that: Use the crude oil origin identification method based on near infrared spectroscopy as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Method and system for tracing crude oil producing area

    CN114280000A

  • Near infrared spectrum analysis method and system based on image feature extraction

    CN117078960A