# Research on Coal Structure Prediction Method Based on Genetic Algorithm-BP Neural Network
## 3 Materials and Methods
### Prediction Model Based on GA-BP Neural Network  
In the process of using GA-BP neural network to predict coal structure, four kinds of logging curve data, namely acoustic time difference (AC), density (DEN), natural gamma (GR), and deep lateral resistivity (RD), are taken as the input. The output is three categories of coal structures. First, the network is used for training, and then the trained network is used to predict relevant data. In order to solve the problems of BP neural network structure and parameters, GA is introduced to optimize BP neural network, and the process of BP neural network optimization by GA is shown in Figure 7.  
(1) Dataset generation. Four types of logging curves are selected from the data of seven wells as sample data and the corresponding three coal structure categories are used as label data, totaling 200 sets of data. Simultaneously, these 200 sets of data are normalized, respectively. The normalization formula for the logging curve is expressed as follows:  
\[X^{*}=\frac{X-X_{\text{min}}}{X_{\text{max}}-X_{\text{min}}} \tag{3}\]  
where \(X^{*}\) represents the normalized well logging data, \(X\) represents the original well logging data, \(X_{max}\) represents the maximum value of the original well logging data, and \(X_{min}\) represents the minimum value of the original well logging data. Through this formula, the logging curve value is normalized to [0, 1], and the original structure, fragmentation structure, and granular structure are defined in the form of One-hot encoding to facilitate subsequent network processing. (2) Define the network structure. According to the specific steps of optimizing the BP neural network using the GA described above, the BP neural network is optimized. The detailed network structure and parameters of the GA-BP neural network are shown in Table 1. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Genetic Algorithm (GA) Parameter Configuration** & **BP Neural Network Parameter Configuration** & **Configuration** \\ \hline Initial population size & 10 & Batch size & 16 \\ \hline Maximum evolution number & 20 & Initial learning rate & 0.005 \\ \hline Crossover rate & 0.5 & Optimizer & Adam \\ \hline Mutation rate & 0.01 & Activation Function & Relu \\ \hline \hline \end{tabular}
\begin{tabular}{c c} \hline \hline Number of hidden layers & 2 \\ \hline Number of neurons in the first layer & 28 \\ \hline Number of neurons in the second layer & 56 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Detailed structure and parameters of GA-BP neural network. Figure 7: Flowchart of GA optimization of BP neural network. (3) Divide the dataset. The 200 sets of data are divided into a training set and a validation set, with the data from one well selected as the test set. The training set is used to train the model and adjust the model's weights; the validation set is used to verify whether the model's performance meets the requirements; the test set is used to test the model's generalization ability on unknown data. (4) Network training. We use Python 3.9 as the programing language and PyTorch as the foundational framework to train the network on a GeForce RTX 1060 GPU with 6 GB of VRAM using the training set data. The training process took 257 s. In this paper, the Cross-entropy loss function is used as the loss function. The Cross-entropy loss function is calculated as follows:  
\[Loss=-\frac{1}{N}\sum_{i=1}^{N}\sum_{c=1}^{c}x_{i,c}\log(y_{i,c}) \tag{4}\]  
where \(N\) represents the number of logging curve data, \(c\) represents the number of categories of coal structure, \(x_{i,c}\) represents the true label of the \(i\)th logging curve data in the \(c\) category, and \(y_{i,c}\) represents the probability value of the \(i\)th logging curve data predicted by the network belonging to the \(c\) category. The total number of iterations is set to 200.