# Research on 3D Geological Modeling Method Based on Deep Neural Networks for Drilling Data
## 5 Experiments and Results
### Experiment Parameters
#### 5.1.2 Geologically Constrained Loss  
In this study, the deep neural network comprises three submodels dedicated to classifying geological age, geological genesis, and geotechnical type features. To improve model training and final performance, geological rules and knowledge are integrated. A loss function suitable for geological modeling is developed by introducing constraint terms based on geological features, in addition to the cross-entropy loss function commonly used for classification tasks. The loss function with geological constraints is formulated as shown in Equation (21).  
\[\text{Loss}=\alpha\cdot\text{CE}+\beta\cdot\text{GeoPenalty} \tag{21}\]  
In this equation, CE represents the cross-entropy loss term, GeoPenalty is the penalty term for geological constraints, and \(\alpha\) and \(\beta\) are weight factors that control the relative importance of each subcategory. These weights are typically determined through an iterative process to find the optimal parameter combinations. The cross-entropy loss term, as defined in Equation (22), entails consolidating multiple categories into a single category.  
\[\text{CE}=-\frac{1}{\text{N}}\sum_{i=1}^{\text{N}}y_{i}\log(\hat{y}_{i}) \tag{22}\]  
The data used for training the deep neural network in this study exclusively contain quaternary stratigraphy. These stratigraphic data are represented with numerical codes based on the geological era, where each code carries both classification and sequential significance. The numerical coding is as follows: Holocene: 4; Upper Pleistocene: 3; Middle Pleistocene: 2; Lower Pleistocene: 1. In this coding scheme, a higher code not only indicates the classification of the era but also signifies a more recent geological period, with the Holocene (code 4) being the most recent and the Lower Pleistocene (code 1) being the oldest. In the context of deep neural networks for prediction, when dealing with samples that share the same planar position (i.e., they have identical x and y coordinates but different z coordinates), these samples can be regarded as part of the same borehole. Furthermore, there exists a structured relationship between the geological epochs represented by these boreholes. Specifically, points situated at higher elevations (i.e., those with greater z-coordinates) are inherently associated with more recent geological strata. Consequently, their geological epoch encoding must be greater than that of points situated at lowerelevations. This encoding scheme reflects both the classification of geological eras and their temporal sequence, with higher numerical codes indicating more recent geological periods. Given that training-batch sample data are randomly chosen during the network training process and may not originate from the same borehole, it becomes challenging to compute the sequential loss for all the data. To account for the loss associated with the order of geological epochs in the loss function, it is essential to identify sample points within the same training batch that share identical planar coordinates. By doing so, the geological epochs within this series of sample data can be compared to ensure that the model accurately captures the sequential nature of geological epochs. The geological epoch order loss is calculated as described in Equation (23).  
\[\text{GeoPenalty}=\sum_{i=1}^{N-1}\max(0,\text{label}_{i+1}-\text{label}_{i}) \tag{23}\]  
In this equation, N represents the number of samples in the same training batch, label, denotes the geologic era code of the ith sample, and the difference between neighboring samples' codes is calculated (taking 0 if the difference is less than 0). These differences are then summed to obtain the sequential loss term for the geologic era. When each training batch of samples is fed into the neural network, the samples are sorted based on their planar coordinates. If the training batch contains samples from the same drill, the geological epoch order loss is calculated. Otherwise, the order loss of the batch is disregarded.