## 2 Methodology and Networks
### Model Architecture  
In our approach to digital rock reconstruction, the model architecture is meticulously designed to ensure precision and efficiency. The entire process is streamlined by using a series of components, each specialized for its task. The generator, illustrated in Figure 3, stands as the central component of the model, tasked with synthesizing the digital rock images. Starting from a noise input, the generator consists of a series of convolutional layers, complemented by Batch Normalization (BatchNorm3d) and activation functions such as ReLU. Two core components of the generator are the DoubleConvBlock and ConvAttentionBlock. A noteworthy inclusion in our model is the fully convolutional self-attention network. By executing the self-attention mechanism across the entire input image, the model is equipped to discern long-range dependencies between different positions within the image. This capability empowers the model with a refined understanding of the image's content and contextual information, leading to an enhancement in the quality of generated images. Through the self-attention mechanism, the model autonomously designates which areas of the image merit heightened focus and importance weighting. This selective attention minimizes the generation of ambiguous or implausible details, bolstering the accuracy and realism of the produced images. Conclusively, the implementation of this mechanism provides meaningful improvement to the model. The generator's final output undergoes a tanh activation to ensure normalization of the generated image values. Presented in Figure 4, the discriminator plays a pivotal role in evaluating the genuineness of the generated rock images. It is designed to differentiate between the real and synthesized images. With its convolutional layers, LeakyReLU activations, and Batch Normalization (BatchNorm3d), it efficiently classifies images as 'Real' or 'Fake', guiding the generator in its training phase. Figure 3: Architecture of the generator with fully convolutional self-attention network. The DoubleConvBlock module, visualized in Figure 5, is a specialized architecture that involves two sequential convolution operations. With Group Normalization (GroupNorm3d) and ReLU activation sandwiched between them, this block aids in extracting more nuanced features from the input while retaining spatial hierarchies, ensuring better texture and detail in the generated rock structures. The ConvAttentionBlock, depicted in Figure 6, integrates an attention mechanism into the convolutional process. This innovative block assigns distinct attention weights to different regions of the input, enhancing the model's ability to discern and focus on the essential features in the data. This attention-centric approach ensures that the generated rock samples encapsulate the intricate details reminiscent of real-world structures. Figure 4: Architecture of the discriminator. Figure 5: DoubleConvBlock. Figure 6: ConvAttentionBlock. The traditional self-attention mechanism, also known as SA, is a mechanism used to process sequence data. Its basic principle is to split the vector representation of each position in the input sequence into three parts: query, key, and value. Then, by calculating the correlation score between each position and others in the sequence, a weight vector is obtained, and the values are weighted and summed according to this weight vector to obtain the representation of each position. Specifically, given an input sequence \(x_{1}\), \(x_{2}\), \(\ldots\), \(x_{n}\), the output of each position \(i\) can be calculated as follows:  
1. Use the vector representation \(x_{i}\) of the current position \(i\) as query, key, and value, respectively, and calculate their similarity scores with other positions. 2. Based on these scores, compute the weight vector \(Wi\) between the current position \(i\) and other positions. 3. Weight the values according to the weight vector and sum them up to obtain the output vector \(\mathrm{Y}i\) of the current position \(i\).