A study of transfer learning in digital rock properties measurement

The measurement of physical parameters of porous rock, which constitute reservoirs, is an essential part of hydrocarbon exploration. Typically, the measurement of these physical parameters is carried out through core analysis in a laboratory, which requires considerable time and high costs. Another approach involves using digital rock models, where the physical parameters are calculated through image processing and numerical simulations. However, this method also requires a significant amount of time for estimating the physical parameters of each rock sample. Machine learning, specifically convolutional neural network (CNN) algorithms, has been developed as an alternative method for estimating the physical parameters of porous rock in a shorter time frame. The advancement of CNN, particularly through transfer learning using pre-trained models, has contributed to rapid prediction capabilities. However, not all pre-trained models are suitable for estimating the physical parameters of porous rock. In this study, transfer learning was applied to estimate parameters of sandstones such as porosity, specific surface area, average grain size, average coordination number, and average throat radius. Six types of pre-trained models were utilized: ResNet152, DenseNet201, Xception, InceptionV3, InceptionResNetV2, and MobileNetV2. The results of this study indicate that the DenseNet201 model achieved the best performance with an error rate of 2.11%. Overall, this study highlights the potential of transfer learning to ultimately lead to more efficient and effective computation.


Introduction
The study of rock physical parameters, such as porosity and permeability, is essential in analyzing the physical properties of reservoirs [1,2], as they help to understand the reservoir characteristics including their resource capacity and production feasibility [3]. Petroleum reservoirs are naturally formed subsurface rock structures that comprise interconnected pore and fracture networks [4].
Typically, effective properties, such as porosity and permeability, are measured in porous rocks by laboratory testing of rock samples obtained from drilling sites. During laboratory testing, fluid is carefully injected into the porous rock to determine its characteristics, avoiding any potential structural damage to rock samples. Therefore, low-pressure fluid injection is used to minimize the potential for structural destruction of the porous rock [5].
The x-ray micro-computed tomography (micro-CT) technique has been utilized for the past two decades as an alternative method for investigating physical properties and fluid flow in porous rocks [6]. Micro-CT images provide three-dimensional (3D) internal geometry information of porous rocks, allowing the pore structure to be observed with a resolution of up to several micrometers [7]. These 3D images are also known as digital rocks and have been widely used for non-destructive research of rock physical parameters through numerical computing methods and image processing techniques [8][9][10][11]. However, utilizing both methods to study the physical properties of rocks can be time-consuming and demands substantial computational resources [12].
Machine learning (ML) has emerged as an alternative solution in various fields, including healthcare [13], education [14], and science and engineering, for hydrocarbon production, drilling optimization, reservoir characterization, well log data analysis for litho-facies interpretation, and solving geophysical problems [15]. ML has also been applied to simplify and accelerate the computational process of estimating the physical parameters of porous rocks [12]. One popular ML model used to handle complex cases is the artificial neural network (ANN), algorithms inspired by human nerves that learn adaptively to perform a task through training. ANNs have a typical structure consisting of a series of layers, where each layer contains several perceptrons, the main building blocks of ANNs, with the output of one layer serving as the input for the next layer [16]. Some transport properties of porous media, such as permeability, are simply a function of the pore geometry, therefore, it is possible to predict permeability using a neural network approach by developing a model to predict the relationship between pore geometry and physical parameters [17]. ML has been previously applied to predict the physical parameters of rocks digitally [12,18] with an ML model created using a convolutional neural networks (CNNs) algorithm to predict digital rock physical parameters including porosity, permeability, and tortuosity using a dataset of 100 000 samples in the form of two-dimensional images measuring 400 × 400 pixels.
CNN is a type of ANN that has gained popularity in recent years for image processing and analysis tasks due to its ability to learn complex features from images [19]. Digital rock images obtained through the x-ray micro-CT technique provide a powerful means for non-destructive research of rock physical parameters but manual processing and interpretation of these images can be time-consuming and prone to error. CNNs offer an effective solution to automate the process of analyzing digital rock images to estimate the physical properties of porous rocks, such as porosity, permeability, and grain size. These algorithms can learn to identify features in images that are relevant to the target parameter and provide accurate predictions with minimal human intervention [18]. The recognition accuracy of a CNN model in identifying the relationship between pore-matrix patterns in rocks and physical parameter values, such as permeability, has demonstrated superior performance compared to several other image recognition algorithms [20]. In particular, four algorithms including gradient boosting, gradient boosting with logarithmic permeability, multi-layer perceptron, and CNN were compared in recognizing rock patterns with their permeability values, and their performance was evaluated using the normalized absolute permeability error metric. The CNN algorithm achieved the lowest error value of 3.37% and could predict the physical parameters of three-dimensional porous rocks, which consist of several other physical parameters, with an average error of less than 6% [18].
One of the challenges in digital rock analysis is the large size of the 3D images, which can result in computationally expensive analysis and slow down the process of extracting properties of interest. One approach to address this challenge is the use of transfer learning in digital rock properties measurement. Transfer learning is a ML technique where a model is trained on one task and then reused on a second related task. In transfer learning, features from a network trained on a previous neural network task are transferred to a second neural network in the hope that the new problem will benefit from the features learned [21][22][23][24][25]. Transfer learning is also utilized in other scientific fields including seismic modeling and imaging [26]. In the context of digital rock analysis, transfer learning can be used to develop models for estimating rock properties by training on a smaller dataset or pre-trained models. Transfer learning can also be used to improve the accuracy of models by leveraging the knowledge learned from pre-trained models.
The application of transfer learning has seen notable success in various image classification and recognition tasks, including object identification in images, face recognition, and natural language processing. However, its application in digital rock analysis is still nascent, and further research is required to explore its potential in this field. The pre-trained models employed in transfer learning are usually built on large datasets, and their knowledge can be transferred to smaller datasets for more efficient analysis, thereby considerably reducing the training time required for the development of models for estimating rock properties.
Several pre-trained models have been developed and applied in transfer learning for digital rock analysis. For instance, ResNet152, DenseNet201, Xception, InceptionV3, InceptionResNetV2, and MobileNetV2 models have been utilized to build models for estimating rock properties of sandstones such as porosity, specific surface area (SSA), average coordination number (ACN), average grain size (AGS), and average throat radius (ATR). These models have demonstrated promising results in accurately estimating rock properties, reducing computational requirements, and enhancing the efficiency of digital rock analysis. Overall, transfer learning has the potential to enhance the accuracy and efficiency of digital rock analysis by utilizing pre-trained models on larger datasets but further research is necessary to investigate the potential of transfer learning in digital rock analysis, including optimizing existing models for improved performance. This study employed the CNN algorithm with a transfer learning strategy to estimate the physical properties of 3D porous rocks including porosity, SSA, AGS, ACN, and ATR. Porosity refers to the ratio of the empty space in a rock to its volume, SSA refers to the ratio of the surface area of grains to their volume, and AGS indicates the diameter of the constituent grains of the rock, whereas the coordination number indicates the level of connectivity between pores and their neighbors, while the average distance between a pore and its neighboring pores is defined as the ATR. Porosity, SSA, and AGS were selected because they play a crucial role in calculating permeability using the Kozeny-Carman equation, while the ACN and ATR parameters reflect the connectivity between pores in rocks that affect fluid mobility. Faster and more efficient calculations can be achieved by using the CNN and transfer learning model, therefore, we propose an ML modeling approach that utilizes CNN as an alternative method to estimate the physical properties of three-dimensional porous digital rocks.

Dataset
The datasets were created using various types of digital rock samples by preprocessing which involves data type conversion, resampling, and feature creation. The physical parameters of porous rocks are then calculated using image processing techniques and serve as labels or outputs in the ML model architecture. The raw digital rock data obtained from micro-CT scans are converted into an array to facilitate processing in the next stage. Resampling involves dividing the digital rock data into smaller sizes to reduce the computational load and generate a larger dataset. The subsequent step involves training the ML model by varying six types of pre-trained models to identify the best-performing model that learns the relationship between input and output. Finally, the model's performance was evaluated by estimating the physical parameters of previously determined porous rocks. These primary results are the estimated values of the physical parameters of porous rocks, which include porosity, SSA, AGS, ACN, and ATR. Figure 1 depicts the workflow of this research. For this study, a digital rock dataset comprising eight sandstone types was utilized. These samples were obtained from Kocurek Industries and made available through the www. digitalrocksportal.orgprojects [27,28]. Micro-CT imaging technology was employed to scan these digital rocks, resulting in binary 3D images where 0 represents pore space and 1 represents rock matrix. Each voxel in the image corresponds to a real rock size of 2.25 µm. The sandstone types included Bandera Brown, Berea, Bentheimer, Buff Berea, Castlegate, Kirby, Leopard, and Parker, of which, the first five samples were used to train the ML model, while the remaining three were utilized to test its performance.
To create the training dataset, the 1000 × 1000 × 1000 voxels 3D digital rock data was partitioned into smaller sub-samples of the same size by selecting a 128 × 128 × 128 voxel portion of the sample and shifting it by 65 voxels along the x, y, and z axes to generate new identical but smaller samples (figure 2). The resampling was performed using an image processing technique that yields 10 000 sub-samples for the training dataset and 2400 sub-samples for the testing dataset. The samples in the testing dataset were selected based on the standard deviation of the porosity distribution for the three testing rock types, thus eliminating rocks with excessively low and high porosity. The elimination of outliers was carried out to improve the dataset distribution and to make the CNN model perform better in recognizing pore-matrix patterns in rocks. Outliers are data points that fall outside the range of the majority of the data. They can be caused by errors in the data collection process or by unusual events. By removing outliers, the dataset distribution can be made more uniform, which can help the CNN model to learn more effectively. Table 1 summarizes the rock dataset composition for the CNN modeling and shows that the five rock types used for training have an equal number of sub-samples to facilitate the learning of each rock's pattern during the training process.
To avoid using the entire 3D array of digital rocks as input, only specific parts of the array that can represent it were selected, the XY, YZ, and XZ plane slices, each with a size of 128 × 128, as shown in figure 2. The slices were then combined into a three-channel image to create a synthetic RGB image to prevent data size explosion during the training stage and reduce the computational process [18]. For the model training labels, the porosity (ϕ), SSA, AGS, ACN, and ATR were calculated for both the training and testing datasets. To calculate porosity, the zero-valued pixels representing pores in a rock sample are first added up to find the total pore volume. This volume is then divided by the sample volume to obtain the porosity value. The SSA was calculated as the ratio of the surface area of the grain particles (A) to the volume of each grain (V), as shown in equation (1). The AGS, ACN, and ATR were determined through the segmentation stage using image processing. Figure 3 illustrates the steps involved in calculating the physical parameters of rocks using image processing techniques for model training labels  The calculation of AGS, ACN, and ATR, which require the segmentation stage, was performed using image processing techniques. Figure 3 illustrates the steps involved in calculating these physical parameters for CNN model training labels. To calculate AGS, the grains were segmented with each segmented grain region measured for diameter to calculate the average. Segmentation was performed on the rock pores for ACN and ATR. The segmented pore regions are then subjected to connectivity analysis by evaluating the connectivity of each pore with its neighboring pores. Both pore and grain segmentation used the watershed segmentation algorithm [29,30].

Transfer learning
A transfer learning approach that utilized six pre-trained model architectures to obtain the best model was used to reduce training time and accelerate model development with minimal error rates. Transfer learning is a technique where a model is trained for one task and then applied to a related task to improve optimization [31]. The six pre-trained models used were ResNet152, DenseNet201, Xception, InceptionV3,   InceptionResNetV2, and MobileNetV2. ResNet152 utilizes residual connections to prevent information loss during model training, thus enhancing performance [32]. InceptionV3 is an improvement of GoogLeNet and InceptionV2 with the addition of batch normalization and factorization [33]. InceptionResNetV2 combines ResNet and Inception architectures to further enhance performance [34]. DenseNet201 is designed with dense connection techniques, where each layer is connected to subsequent layers, and is effective in mitigating overfitting with small datasets [35,36]. Xception employs Depthwise Separable Convolution and consists of Entry Flow, Middle Flow, and Exit Flow, which has fewer parameters but outperforms InceptionV3 [37]. MobileNetV2 uses depthwise separable convolution that combines depthwise convolution and pointwise convolution. The pre-trained model architectures were used in the initial layer for image recognition, and the last layer was modified by a dense layer to convert the classification function to regression, with the model output being a single prediction value for each input, as depicted in figure 4. Each pre-trained model architecture was trained using 75 epochs, 256 batch sizes, Adam optimizer, and mean squared error as loss functions for all five modeled physical parameters. The layer arrangement in each pre-trained model architecture was fine-tuned as listed in tables 5-10 in the appendix. The mean absolute percentage error (MAPE) metric was used to measure the model performance and is a unit-free metric that calculates the percentage of errors resulting from the difference between the predicted and reference values. MAPE is a widely used metric in petrophysics and rock studies due to its clarity of percentages, ease of interpretation, and unit-free nature. It has also been used in the prediction of the elastic behavior of sandstone rocks [38], the characterization of rock mechanical properties [39], and the prediction of cumulative production profiles in multistage hydraulic fracturing wells [40]. The best CNN transfer learning model for each physical parameter estimation was selected based on its performance.

Results and discussions
In this section, we present the performance of the six types of pre-trained models in estimating the five rock physical parameters and discuss various aspects of the models, such as accuracy in estimating each rock physical parameter, training loss and validation loss curves, computation time and resources, and error analysis. Figure 5(a) shows that during training, the CNN model for porosity estimation improved its accuracy for each epoch in recognizing the feature patterns of the pore-matrix relationship. All pre-trained models reached the plateau quickly but based on the training-validation loss curve in figure 5(a), the DenseNet201 architecture had the lowest error per epoch compared to other pre-trained models. Although the validation loss curve fluctuated, as shown in figure 5(a), the error per epoch was low. In contrast, the ResNet152 architecture shows the highest loss value compared to the other six pre-trained model architectures, both in training loss and validation loss. Table 2 compares the results of the physical properties estimation model using the CNN model to its reference value calculated using image processing. The DenseNet201 architecture had the smallest error with a MAPE of 3.93% and the ResNet152 model had the largest error with a MAPE of 10.94%. Based on the resulting MAPE, the pre-trained DenseNet201 model was chosen as the best model.

Porosity
The distribution of absolute error (APE) values for 2400 samples of rock porosity prediction by DenseNet201 as the best architecture is shown in figure 6(a). APE values were less than 10% for 92.54% of samples, 10%-20% for 7.16% of samples, and above 20% for 0.29% of samples. The coefficient of determination (R 2 ) for the performance of the CNN model in predicting porosity by DenseNet201 was 0.81 as shown in figure 6(b). One of the factors that could affect the porosity model performance was the number of zero array elements that represented rock pores in the three-dimensional dataset porosity value. The CNN model studied features using slices of 3D data fields that represented the entire three-dimensional array data to avoid data explosion. If the CNN model architecture was less capable of learning the relationship between features and their labels, there could be a possibility of a decrease in the norm in estimating porosity values. A significant decrease in performance was evident in the ResNet152V2 model.

SSA
The accuracy of CNN models for SSA estimation improved during their training as they became better at recognizing the patterns in the relationship between the pore matrix and features. Figure 7(a) shows that all pre-training models quickly reached a plateau. By examining the loss curves for training and validation shown in figure 7(b), it is clear that the six pre-trained models achieved better loss reduction than the training model for porosity estimation. Among the pre-trained models, DenseNet201 had the lowest loss per epoch, whereas the ResNet152 architecture shows the highest loss compared to the other six pre-trained model architectures, both in training loss, as well as achieving high epoch values in validation loss. This result was the same for both the ResNet152 and InceptionV3 architectures. The DenseNet201 model continues to produce the SSA estimate with the smallest error, with a MAPE value of 3.41%, and the InceptionV3 model resulted in the largest error, with a MAPE value of 9.97% as shown in table 2.
The APE values for 2400 samples of rock SSA prediction by DenseNet201 as the best architecture are shown in figure 7(a). APE values were less than 10% for 94.75% of samples, 10%-20% for 5.04% of samples, and above 20% for 0.20% of samples. The R 2 for the performance of the CNN model in predicting SSA by DenseNet201 was 0.89 as shown in figure 8(b). The accuracy of the CNN model in estimating SSA can be affected by several factors, one of which is the level of similarity in characteristics between the patterns of the pore matrices in the training and testing datasets. The difference in grain shape between the training and test rocks may result in the CNN model misinterpreting grain information, including surface area and volume, resulting in SSA values that are too high or too low.
The APE values for 2400 samples of rock SSA prediction by DenseNet201 as the best architecture is shown in figure 8(a). APE values were less than 10% for 94.75% of samples, 10%-20% for 5.04% of samples, and above 20% for 0.20% of samples. The R 2 for the performance of the CNN model in predicting SSA by DenseNet201 was 0.89 as shown in figure 8(b). The accuracy of the CNN model in estimating SSA can be affected by several factors, one of which is the level of similarity in characteristics between the patterns of the pore matrices in the training dataset and the testing dataset. The difference in grain shape between the training rock and the test rock may result in the CNN model misinterpreting grain information, including surface area and volume, resulting in SSA values that are too high or too low.

AGS
The CNN model for AGS estimation exhibited a trend of decreasing training loss as the number of epochs increased, as demonstrated in figure 9(a). This indicates that the model improved its ability to recognize the relationship between pore-matrix patterns and their corresponding AGS values. The training loss curves for all pre-trained models quickly reach a plateau, as shown in figure 9(a)  Among the physical parameters examined in this study, AGS exhibits the best performance, as shown in figure 10 with the DenseNet201 model delivering the best APE distribution estimates. Figure 10(a) depicts that over 99% of the data samples have APE values below 10%, with only 0.62% of the samples having APE values exceeding 10%. The coefficient of determination (R 2 ) for the CNN model's prediction of AGS by DenseNet201 outperforms the porosity estimation model with R 2 = 0.82 as shown in figure 10(b). AGS is a relatively straightforward parameter compared to the other five modeled parameters and can be determined directly after the matrix segmentation stage using image processing techniques. The rock grain size can be directly observed from the dataset images used in training, thus this physical parameter outperforms the other five parameters in this study.

ACN
The CNN model for ACN estimation showed a trend of decreasing training loss with increasing epochs, as depicted in figure 11(a), indicating that all pre-trained models reached a plateau quickly. However, the validation loss curve shown in figure 11(b) showed volatile movement as the number of epochs increased, with a shape similar to the training curve for AGS. The fluctuation graph of the validation loss for the six models shows a similar pattern, with DenseNet201 having a relatively lower loss compared to other architectures. MAPE was used to evaluate the performance of the ACN estimation model, showing that the DenseNet201 model produces the smallest error with a MAPE value of 5.77% and the InceptionV3 model yields the largest error with a value of 17.20% as shown in table 2.
The ACN is the physical parameter with the lowest CNN model performance compared to the other five models since it is the most complex parameter of the five. As the problem becomes more complex, it becomes more difficult for the ML model to learn the relationship between the feature pattern and its label. The complexity of the ACN lies in the connection between the pores, as not all neighboring pores coordinate with each other. The APE distribution of the ACN estimation using DenseNet201 in figure 12(a) shows that only around 81.54% of the samples have APE values of less than 10%, which is smaller than the five other physical parameter estimation models in this study. The CNN model for estimating the ACN has the lowest coefficient determination, with an R 2 = 0.26 as shown in figure 12(b).

ATR
The training loss curve of the ATR estimation model reaches a plateau in a short time, as shown in figure 13(a). Among the six pre-trained models, most of them have similar loss per epoch values but the ResNet152 model has a relatively higher loss per epoch value than the others, as depicted in figure 13(b). In terms of the validation loss curve, the curve shape fluctuates, with the DenseNet201 and MobileNetV2  figure 14(a) shows that more than 70% of the rock samples have APE values of less than 10%, and only 3% of the data samples have APE of more than 20%. Based on the coefficient determination, the CNN model for estimating ATR performs as well as the SSA estimation model with R 2 = 0.60 as shown in figure 14(b). The scatter plot shows that the CNN model tends to predict lower ATR values than the actual value.

Computational issues
The estimated times for estimating physical parameters listed in table 3 are based on the analysis of 2400 rock samples from the test dataset. Each model for estimating the physical properties shown in table 3 was trained using the DenseNet201 architecture with the computer specifications Intel® Xeon® Gold 5118 CPU @2.30GHz× 24, RAM 128 GB. Both methods of estimating rock physical parameters were tested using the same computer resources for the same physical parameters. Computer A with Intel® Xeon® Gold 5118 CPU @2.30GHz processor specifications and 128 GB RAM was used for porosity and SSA estimation, and Computer B with an AMD A9-9425 Radeon R5@3.1Ghz processor specification and 8GB RAM was used for ACN, AGS, and ATR estimation. ML can significantly reduce the estimation time of SSA, ACN, AGS, and ATR compared to using image processing. However, for porosity estimation, image processing still provides a shorter estimation time as the calculation process is relatively simple, directly calculating the number of array elements with zero values representing pores, whereas the other four physical parameters require more complex calculation processes. By using ML, the trained model can learn and remember the relationship The transfer learning strategy used in CNN modeling for estimating five physical parameters of porous rocks is efficient, as CNN model training can be performed on computers with common specifications, even with only one processor. Table 4 shows a comparison of the number of processors on a computer with Intel® Xeon® Gold 5118 CPU @2.30 GHz processor specifications and 128 GB RAM with the training time of a model using DenseNet201. DenseNet201 is a pre-trained model that has shown good performance in estimating the five physical parameters of porous rocks in this study and consists of 18 323 905 parameters and 402 depths in general.
Six types of pre-trained models consisting of ResNet152, DenseNet201, Xception, InceptionV3, InceptionResNetV2, and MobileNetV2 were applied to estimate five rock physical parameters namely porosity, SSA, AGS, ACN, and ATR. The MAPE value assessment outcomes indicate that the DenseNet201 model architecture is more dominant than other pre-trained models, as it exhibits the smallest average error. Based on these results, it can be concluded that the DenseNet201 architecture built with the connection between each layer to the other layers in a feed-forward manner provides better performance in learning the relationship between the features of the digital rock dataset and the physical parameters. The DenseNet201 architecture allowing more connections to be formed at the convolution layer, which improves the propagation of the feature graph, utilizes the feature graph of the previous layer more fully and also plays a role in improving the performance in pattern recognition of the dataset, greatly reducing the number of parameters.
The testing of the six pre-trained models for estimating five physical parameters of porous rocks using CNN shows diverse outcomes. The performance of the pre-trained model measured based on the MAPE value for each physical parameter estimation is shown in table 2 and indicates that the DenseNet201 model has the best performance for estimating four physical parameters: porosity, SSA, AGS, and ACN. It achieved  Table 2 also shows that almost all InceptionV3 architectures have low performance in estimating the value of porous rock physical parameters. This decrease in performance can be caused by several factors, including that the InceptionV3 architecture is not suitable for the size of the dataset used, which is 128 × 128 because InceptionV3 is more effective in recognizing large images, so if used on small images, recognition accuracy can decrease. Another factor is that InceptionV3 can have difficulty in recognizing objects that are very dense or too close to each other, this can occur in rock datasets that have close grain spacing. Also, the InceptionV3 architecture requires a large amount of data to learn patterns and produce accurate predictions.

Conclusions
This study presents a ML approach that uses a CNN algorithm in combination with transfer learning to estimate the physical parameters of 3D digital rock samples of the sandstone type, including porosity, SSA, AGS, ACN, and ATR. The dataset for training consists of 10 000 training data and 2400 testing data. Pre-training model architectures used in transfer learning include ResNet152, InceptionV3, InceptionResNetV2, DenseNet201, Xception, and MobileNetV2, with DenseNet201 architecture achieving the best performance with lower errors, 3.93% for porosity estimation, 3.41% for estimation SSA, 2.11% for AGS estimates, and 5.77% for ACN estimates. As for ATR estimation, the pre-trained model with the lowest error is MobileNetV2 with 7.52%. Meanwhile, the InceptionV3 architecture obtained low performance for the majority of the estimated physical parameter values with the highest error of 17.20% in the ACN estimation. This study also showed that transfer learning is efficient and can be run on cheap computing resources but further research is needed to explore the potential of the ML method in estimating the physical parameters of porous rocks.

Data availability statement
All data that support the findings of this study are included within the article (and any supplementary files). Appendix.