# A Multiscale CNN-Based Intrinsic Permeability Prediction in Deformable Porous Media
## 4 Model (1): \(\left[K^{S}-n^{F}\right]\)-CNN Model
### CNN Model Architecture and Hyperparameters  
The CNN model comprises several key components, which are described as follows:  
* _Convolution Operation_: This step involves the application of a 2D filter (also known as a kernel or feature detector) to the input data, resulting in the generation of a feature map. This process highlights important features within the CT images by detecting patterns and edges that are crucial for permeability and porosity predictions.
* _Pooling Operation_: After the convolution operation, a pooling layer is applied to the feature map. This process aims to down-sample the feature map by calculating, for instance, their maximum or average values and sending only the significant features to the next CNN layer.
* _Multi-Layer Perceptron (MLP)_: The MLP consists of fully connected (dense) layers that take the pooled feature map as input and produce a 1D feature vector as output.  
The architecture of the proposed CNN model is illustrated in Figure 4 and is in line with the model presented in [42].  
Figure 4: Architecture of the 3D CNN illustrating the flow of information from the input image through multiple convolutional layers, max pooling layers, and fully connected layers. The input image is a 3D volume with dimensions \(256\times 256\times 32\), which passes through four convolutional layers (Conv1 to Conv4), each followed by max pooling to reduce spatial dimensions. After flattening, the feature maps are processed by two fully connected (FC) layers before generating the final output predictions (\(n^{F}\), \(K^{S}_{11}\), \(K^{S}_{22}\), \(K^{S}_{33}\)).  
The following details are associated with the underlying model:  
* Data preparation:
* The image-related input data are transposed and reshaped to ensure compatibility with the 3D CNN model architecture.
* Before splitting into training, validation, and test subsets, data indices are shuffled to randomize the samples.
* After Splitting, the output data (\(n^{F}\) and \(K^{S}_{kk}\)) are scaled using the MinMaxScaler, class of the sklearn.preprocessing toolkit [68], to normalize the values between 0 and 1, which is essential for stabilizing the training process.
* Model architecture:
* The CNN model features four convolutional blocks, each comprising two 3D convolutional layers with increasing filter sizes (32, 64, 128, 256) and a kernel size progressively increasing from \(3\times 3\times 3\) to \(7\times 7\times 7\).
* Each convolutional layer employs _ReLU_ activation and same padding to maintain spatial dimensions.
* Following each convolutional block, a MaxPooling3D layer with a pool size of 2 \(\times\) 2 \(\times\) 2 is incorporated to down-sample the spatial dimensions, reducing computational load and mitigating overfitting.
* Fully-connected (dense) layers:
* Post convolutional and pooling operations, a Flatten layer transforms the 3D feature maps into a 1D feature vector.
* This 1D vector is then fed into a series of fully connected (Dense) layers, configured with 64 and 32 units respectively, both employing _ReLU_ activation and \(L_{2}\) regularization to prevent overfitting.
* The final Dense layer contains four units (related to \(n^{F}\) and \(K^{S}_{kk}\) with \(k=1,2,3\)) with a \"linear\" activation function, suitable for regression tasks.
* Loss Function and Optimization:
* The model is compiled using the mean squared error (MSE) loss function, i.e., \[\mathcal{D}_{\text{MSE}}=\frac{1}{n}\sum_{i=1}^{n}\left[\left(n_{i}^{F,p}-n_{i}^ {F,t}\right)^{2}+\left(K^{S,p}_{kk,i}-K^{S,t}_{kk,i}\right)^{2}\right]\,,\] (28) where \(n\) is the number of output data points and \(k=1,2,3\).
* Optimization is managed by the Adam optimizer, configured with a learning rate of 0.00001.
* Training and Callbacks:
* The training process spans up to 500 epochs, i.e., 500 complete passes through the entire training dataset, with a batch size of 16, comprising validation data to monitor performance.
* Callback mechanisms such as _ReduceLROnPlateau_, _ModelCheckpoint_, and _EarlyStopping_ are implemented.