Coal rock near infrared spectrum identification method based on Transform model
By adopting a near-infrared spectral identification method for coal and rock based on the Transformer model, combined with preprocessing and multi-layer Transformer encoder, the problem of high-precision identification of coal and rock in complex environments is solved, achieving high accuracy and robust identification results, which is suitable for real-time application in coal mines.
Patent Information
- Application Number
- CN202511568155.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-02-17
AI Technical Summary
Existing coal and rock identification methods have limited recognition capabilities in high dust, low light, and complex backgrounds, and traditional methods are difficult to meet the needs of mining areas for high-precision identification.
A near-infrared spectral identification method for coal and rock based on the Transformer model is adopted, which includes a combination of preprocessing, feature extraction, position encoding and multi-layer Transformer encoder. The method utilizes techniques such as standard normal transformation, Savitzky-Golay filtering and multi-head self-attention mechanism to improve feature modeling ability and recognition accuracy.
It significantly improves the accuracy of coal and rock identification to 97.8%, enhances the robustness and deployment adaptability of the model, and is suitable for real-time spectral identification tasks in coal mining sites.
Smart Images

Figure CN121544931A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent sensing and image recognition technology in coal mines, and in particular to a method for identifying coal and rock near-infrared spectra based on the Transformer deep learning model. Background Technology
[0002] In coal mining, rapid and accurate identification of coal and rock is crucial for intelligent mining, safety control, and resource assessment. Traditional methods such as image recognition, gamma-ray sensing, or vibration sensing have limited capabilities under conditions of high dust, low light, and complex backgrounds. Near-infrared spectroscopy (NIR) technology, due to its non-contact nature, high sensitivity, and sensitivity to the molecular structure of substances, has become an important means of coal and rock identification.
[0003] However, near-infrared spectral data are typically high-dimensional, noisy, and exhibit significant nonlinear characteristics, which limits the performance of traditional methods such as Principal Component Analysis (PCA) and Support Vector Machines (SVM) when dealing with complex band couplings, making it difficult to meet the practical needs of high-precision identification in mining areas. Therefore, there is an urgent need for a coal and rock identification method that integrates deep learning structures and has global modeling capabilities. Summary of the Invention
[0004] This application proposes a near-infrared spectral identification method for coal and rock based on the Transformer model, aiming to improve the accuracy, robustness, and practicality of coal and rock identification.
[0005] In a first aspect, this application provides a method for identifying coal and rock near-infrared spectra based on the Transformer model, including: The raw near-infrared spectral data of coal and rock were acquired and preprocessed to obtain the first data. Extract the initial features from the first dataset and add trainable classification labels to obtain the second dataset; A learnable position encoding vector is added to the second data to embed wavelength order information, resulting in the third data. The third data is input into multiple stacked Transformer encoders to obtain the output results; The vectors at the classification marker positions in the output results are classified to obtain the identification results of coal or rock.
[0006] In one possible implementation, the preprocessing includes: The raw near-outer infrared spectral data of coal and rock were subjected to standard normal transformation to obtain the first preprocessed data; The first preprocessed data is subjected to Savitzky-Golay filtering to obtain the second preprocessed data; The second preprocessed data is averaged and normalized to obtain the first data.
[0007] In one possible implementation, the extraction of initial features from the first data includes: extracting initial features from the first data using an initial feature extraction module; the initial feature extraction module is configured to include a first convolutional layer, a ReLU activation function, a second convolutional layer, and a normalization layer.
[0008] In one possible implementation, the third data is also processed by regularization.
[0009] In one possible implementation, the Transformer encoder includes a multi-head self-attention mechanism, a first residual connection and normalization layer, a feedforward network (FFN), and a second residual connection and normalization layer.
[0010] In one possible implementation, classifying the vectors of classification marker positions in the output result to obtain the identification result of coal or rock includes: The vector of the classification marker position in the output result is input into the classification head module for classification to obtain the identification result of coal or rock; the classification head module includes an average pooling layer, a normalization layer and a linear layer.
[0011] Secondly, a near-infrared spectral identification device for coal and rock based on the Transformer model is provided, comprising: The preprocessing module is used to acquire raw near-infrared spectral data of coal and rock, perform preprocessing, and obtain the first data. The extraction module is used to extract initial features from the first data and add trainable classification labels to obtain the second data; The position encoding module is used to add a learnable position encoding vector to the second data to embed wavelength order information and obtain the third data. The output module is used to input third data into multiple stacked Transformer encoders to obtain the output result; The identification module is used to classify the vectors of the classification marker positions in the output results to obtain the identification results of coal or rock.
[0012] Thirdly, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the near-infrared spectral identification method for coal and rock based on the Transformer model as described in the first aspect.
[0013] Fourthly, a non-transitory computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the coal and rock near-infrared spectral identification method based on the Transformer model as described in the first aspect.
[0014] Fifthly, a computer program product is provided, comprising a computer program that, when executed by a processor, implements the near-infrared spectral identification method for coal and rock based on the Transformer model as described in the first aspect.
[0015] The beneficial effects of this application are as follows: 1. The method provided in this application is based on the Transformer structure and combines local convolution and global attention mechanisms, which significantly improves the feature modeling ability of high-dimensional near-infrared spectral sequences and achieves a recognition accuracy of up to 97.8%.
[0016] 2. The method provided in this application employs a combined SNV and SG preprocessing strategy, which effectively reduces the impact of noise and enhances the model training stability and generalization performance.
[0017] 3. The method provided in this application has a clear overall model structure, adjustable parameters, and good deployment adaptability, making it suitable for real-time spectral identification tasks in coal mine mining sites. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating the near-infrared spectral identification method for coal and rock based on the Transformer model provided in this application embodiment.
[0019] Figure 2 This is a comparison chart of spectral data before and after using SNV and SG combined processing in the embodiments of this application; where the left side is the original spectral data chart; and the right side is the spectral data chart after SNV and SG combined processing.
[0020] Figure 3 This is a schematic diagram of the structure of the coal and rock deep learning model based on Transformer in an embodiment of this application.
[0021] Figure 4 This is a classification result diagram of the method described in the embodiments of this application.
[0022] Figure 5 The curves show the comparison of training and testing performance between the method (CRNIR-TransNet) described in the embodiments of this application and LSTM and CNN models.
[0023] Figure 6 This is a schematic diagram of the structure of the near-infrared spectral identification device for coal and rock based on the Transformer model provided in the embodiments of this application; Figure 7 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0024] The technical solution of this application will be further described in detail below through embodiments and in conjunction with the accompanying drawings.
[0025] Existing coal and rock identification methods, such as principal component analysis (PCA) and support vector machine (SVM), have limited performance when dealing with complex band coupling, making it difficult to meet the actual needs of mining areas for high-precision identification.
[0026] Therefore, this application provides a method for identifying coal and rock near-infrared spectra based on the Transformer model.
[0027] See Figure 1 This application provides a method for identifying coal and rock near-infrared spectra based on the Transformer model, including the following steps: S101. Obtain the original near-infrared spectral data of coal and rock, perform preprocessing, and obtain the first data.
[0028] In one possible approach, the raw near-infrared spectral data of coal and rock is obtained by using an Avantes-NIR-512-HSC-EVO spectrometer to collect coal and rock reflectance data in the wavelength range of 1000-2500 nm, with a resolution better than 2.6 nm and a sampling interval of less than 2 nm to ensure spectral continuity.
[0029] In one possible implementation, the preprocessing includes: (1) Perform standard normal transformation (SNV) on each spectral data, normalize the mean to zero and the standard deviation to one, eliminate the light intensity difference between samples, and obtain the first preprocessed data; (2) The first preprocessed data was smoothed using Savitzky-Golay filtering with a window width of 11 and a fitting order of 2 to obtain the second preprocessed data; (3) The second preprocessed data is averaged and compressed to a uniform length; the LayerNorm normalization layer is used to normalize the data and enhance the stability of the features to obtain the first data.
[0030] For example, the formula for the standard normal transform (SNV) is as follows:
[0031] in, For the first i Reflectance at a wavelength point Indicates the first The original spectral values of each sample, This is the mean of the spectrum. s Its standard deviation.
[0032] For example, the formula for Savitzky-Golay filtering (SG) is as follows:
[0033] in, For the output sequence at the th i The value at each position, For the first in the window j The original data points at relative positions, i For the first i Each wavelength point, k The index for summation represents the relative center point. i The offset, ranging from m arrive m , a k Filtering coefficients obtained by fitting a polynomial using the least squares method; m Half the width of the window (window size is 11). m Take 5).
[0034] Figure 2 The accompanying diagram shows a comparison of the preprocessing results before and after the preprocessing in this embodiment of the application. As can be seen from the diagram, after preprocessing, the spectral characteristics of coal and rock show significant differences, with a markedly improved discriminability, providing a good foundation for subsequent data processing.
[0035] S102. Extract the initial features from the first data and add trainable classification labels to obtain the second data.
[0036] In one possible implementation, S200 includes: extracting initial features from the first data using an initial feature extraction module; the initial feature extraction module is configured to include a first convolutional layer, a ReLU activation function, a second convolutional layer, and a normalization layer.
[0037] S103. Add a learnable position encoding vector to the second data to embed wavelength order information to obtain the third data.
[0038] In one possible implementation, the learnable location encoding vector in S300 refers to setting the vector corresponding to each location as a trainable parameter, which is updated along with other parameters of the model during training, thus better adapting to spectral recognition tasks.
[0039] In one possible implementation, a method for adding a learnable location-coded vector to the second data includes: using a learnable location-coded sequence token ( Figure 2The Classification Token is appended to the beginning of the second data.
[0040] In another possible implementation, S103 includes: adding a learnable position encoding vector to the second data to embed wavelength order information, and then performing regularization to obtain the third data.
[0041] Specifically, the regularization is implemented through the Dropout layer.
[0042] Understandably, the regularization process introduced in S103 can effectively avoid data overfitting and can add random deactivation to enhance generalization ability.
[0043] S104. Input the third data into multiple stacked Transformer encoders to obtain the output results.
[0044] In one possible implementation, in S104, the Transformer encoder includes a multi-head self-attention mechanism, a first residual connection and layer normalization, a feedforward network FFN, and a second residual connection and layer normalization.
[0045] For example, the Transformer encoder sequentially includes: (1) Multi-head self-attention mechanism (8 heads); (2) Perform the first residual connection with the input; (3) First-level normalized LayerNorm; (4) Feedforward Network (FFN): The structure is Linear → GeLU → Dropout → Linear → Dropout; (5) Perform a second residual connection with the FFN input; (6) Second layer normalization LayerNorm.
[0046] S105. Classify the vectors of the classification marker positions in the output results to obtain the identification results of coal or rock.
[0047] In one possible implementation, S105 includes: inputting the vector of the classification marker position in the output result into the classification head module for classification to obtain the identification result of coal or rock; the classification head module is configured to include an average pooling layer, a normalization layer and a linear layer.
[0048] It should be noted that the vector of the classification label position is a learnable vector, located at the beginning of the Transformer input sequence, and aggregates global information through the Transformer as the final classification basis.
[0049] Understandably, the overall model described in this application can be built using the PyTorch framework, with cross-entropy as the loss function, Adam as the optimizer, and a mature model obtained through model training.
[0050] See Figure 3 The diagram below illustrates the structure of the coal and rock deep learning model based on Transformer, as described in this application embodiment. The relevant test results of the aforementioned method are presented below.
[0051] See Figure 4 The figure shows the classification results of the method described in the embodiments of this application. As can be seen from the figure, the method provided in the embodiments of this application can effectively classify coal and rock.
[0052] Test the model on the test set to verify its performance in real-world applications and ensure that the model has good generalization ability. Figure 5 The paper demonstrates the guessing performance of the model (CRNIR-TransNet model) provided in the embodiments of this application in actual surface sampling, and the results show that the model has good recognition and segmentation performance.
[0053] To comprehensively evaluate the advantages of the models provided in this application, CNN (Convolutional Neural Network) and LSTM (Long Short-Term Memory Network) were used as comparison models, and a performance testing scheme was designed under a unified experimental environment. All models were trained and tested on the same near-infrared spectroscopy dataset, and the evaluation metrics included accuracy, precision, recall, and F1 score.
[0054] The comparison results are summarized in Table 1: Table 1 Comparison of recognition performance of each model
[0055] As shown in Table 1, the CRNIR-TransNet model provided in this application significantly outperforms traditional CNN and LSTM models in all four key performance indicators. Specifically, the accuracy is improved by 10.5 percentage points compared to CNN and by 7.7 percentage points compared to LSTM; the F1 score is improved by 15.7 and 11.1 percentage points respectively, indicating that the model described in this application has stronger recognition stability and robustness in complex mining environments.
[0056] Furthermore, since the model provided in this application combines local convolution and Transformer coding structure, it not only improves the ability to model global spectral features, but also realizes an end-to-end spectral classification process, making it suitable for real-time online deployment scenarios.
[0057] The coal and rock near-infrared spectral identification device based on the Transformer model provided by the present invention will be described below. The coal and rock near-infrared spectral identification device based on the Transformer model described below can be referred to in correspondence with the coal and rock near-infrared spectral identification method based on the Transformer model described above.
[0058] Figure 6 This is a schematic diagram of the structure of the near-infrared spectral identification method for coal and rock based on the Transformer model provided in this embodiment of the invention, as shown below. Figure 6 As shown, it includes: a preprocessing module 61, an extraction module 62, a position encoding module 63, an output module 64, and a recognition module 65, wherein: Preprocessing module 61 is used to acquire raw near-infrared spectral data of coal and rock, perform preprocessing, and obtain the first data; Extraction module 62 is used to extract initial features from the first data and add trainable classification labels to obtain the second data; The position encoding module 63 is used to add a learnable position encoding vector to the second data to embed wavelength order information and obtain the third data. Output module 64 is used to input the third data into multiple stacked Transformer encoders to obtain the output result; The identification module 65 is used to classify the vectors of the classification marker positions in the output results to obtain the identification results of coal or rock.
[0059] Figure 7 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 7 As shown, the electronic device may include a processor 710, a communications interface 720, a memory 730, and a communications bus 740. The processor 710, communications interface 720, and memory 730 communicate with each other via the communications bus 740. The processor 710 can call logical instructions from the memory 730 to execute a near-infrared spectral identification method for coal and rock based on the Transformer model.
[0060] Furthermore, the logical instructions in the aforementioned memory 870 can be implemented as software functional units and, when sold or used as independent products, 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.
[0061] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the near-infrared spectral identification method for coal and rock based on the Transformer model provided by the above methods.
[0062] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the near-infrared spectral identification method for coal and rock based on the Transformer model provided by the above methods.
[0063] The device embodiments described above are merely illustrative. 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0064] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0065] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A coal rock near-infrared spectrum recognition method based on a Transformer model, characterized in that, The method comprises the following steps: Obtaining original near-infrared spectrum data of coal and rock, preprocessing the data to obtain first data; Extracting initial features in the first data and adding trainable classification labels to obtain second data; Adding a learnable position encoding vector to the second data to embed wavelength order information to obtain third data; Inputting the third data into a plurality of stacked Transformer encoders to obtain an output result; Classifying the vector at the classification label position in the output result to obtain a recognition result of coal or rock.
2. The coal rock near-infrared spectrum recognition method based on the Transformer model according to claim 1, characterized in that, The preprocessing comprises: Performing standard normal transformation on the original near-infrared spectrum data of coal and rock to obtain first preprocessed data; Performing Savitzky-Golay filtering on the first preprocessed data to obtain second preprocessed data; Performing average pooling and normalization on the second preprocessed data to obtain the first data.
3. The coal rock near-infrared spectrum recognition method based on the Transformer model according to claim 1, characterized in that, The initial features in the first data are extracted by an initial feature extraction module; the initial feature extraction module is configured to include a first convolutional layer, a ReLU activation function, a second convolutional layer, and a normalization layer.
4. The coal rock near-infrared spectrum recognition method based on the Transformer model according to claim 1, characterized in that, The third data is further processed by regularization.
5. The coal rock near-infrared spectrum identification method based on the Transformer model according to claim 1, characterized in that, The Transformer encoder comprises a multi-head self-attention mechanism, a first residual connection and normalization layer, a feedforward network FFN, and a second residual connection and normalization layer.
6. The coal rock near-infrared spectrum identification method based on the Transformer model according to claim 1, characterized in that, The vector at the classification label position in the output result is classified to obtain a recognition result of coal or rock, which comprises: The vector at the classification label position in the output result is input into a classification head module for classification to obtain a recognition result of coal or rock; the classification head module comprises an average pooling layer, a normalization layer, and a linear layer.
7. A coal rock near-infrared spectrum recognition device based on a Transformer model, characterized in that, The method comprises the following steps: A preprocessing module is configured to obtain original near-infrared spectrum data of coal and rock, preprocess the data, and obtain first data; An extraction module is configured to extract initial features in the first data and add trainable classification labels to obtain second data; A position encoding module is configured to add a learnable position encoding vector to the second data to embed wavelength order information to obtain third data; An output module is configured to input the third data into a plurality of stacked Transformer encoders to obtain an output result; An identification module is configured to classify the vector at the classification label position in the output result to obtain a recognition result of coal or rock.
8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the coal and rock near-infrared spectrum recognition method based on the Transformer model according to any one of claims 1 to 6. 9.A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the coal and rock near-infrared spectrum recognition method based on the Transformer model according to any one of claims 1 to 6.
10. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the coal and rock near-infrared spectrum recognition method based on the Transformer model according to any one of claims 1 to 6.