MICROSTRUCTURE RECONSTRUCTION VIA ARTIFICIAL NEURAL NETWORKS: A COMBINATION OF CAUSAL AND NON-CAUSAL APPROACH

. We investigate the applicability of artiﬁcial neural networks (ANNs) in reconstructing a sample image of a sponge-like microstructure. We propose to reconstruct the image by predicting the phase of the current pixel based on its causal neighbourhood, and subsequently, use a non-causal ANN model to smooth out the reconstructed image as a form of post-processing. We also consider the impacts of diﬀerent conﬁgurations of the ANN model (e.g., the number of densely connected layers, the number of neurons in each layer, the size of both the causal and non-causal neighbourhood) on the models’ predictive abilities quantiﬁed by the discrepancy between the spatial statistics of the reference and the reconstructed sample.


Introduction
Multi-scale modelling is a powerful predictive tool that bypasses the need for complex constitutive laws by performing auxiliary calculations at lower scales, using a characteristic sample of a material microstructure [1].Such a sample can be easily extracted when analysing a material with regular, periodic arrangement of material's phases; in case of a material with stochastic microstructure, the representative sample is typically constructed artificially such that it matches selected spatial statistics of the material microstructure [2].
While originally the representative samples were generated via optimization approaches, e.g.[3], recently, reconstruction methods relying on machine learning have started to emerge, using various frameworks including Markov random fields [4], deep adversarial neural networks [5,6], or supervised learning using classification trees [7].Several papers include references to causal and non-causal neighbourhood which both prove to be effective ways of extracting input data for the chosen framework.However, the causal approach generally seems to be the preferred one, with one of these papers even claiming that their model cannot generate valid results if based on a non-causal neighbourhood [4].
The objective of our work is to reconstruct an image of a microstructure from an almost random noise with microscopic properties as similar as possible to the original image.While many of the aforementioned proposed approaches are implementation-complex, we present a simple method using the TensorFlow framework with the Keras sequential API [8].We closely follow the methodology of Bostanabad and coworkers, [7]; however, instead of using classification trees, we use two distinct Artificial Neural Networks (ANNs), where the first network reconstructs the general pattern of the microstructure and the second network denoises and smoothes out the previously reconstructed pattern.For simplicity, we study only two-phase materials, i.e. we test the framework with black and white images.Our implementation and data are publicly available at a GitLab repository [9].

Methodology
The proposed reconstruction method comprises two distinct steps: (1.)The reconstruction of a general shape of the microstructure from a random noise with margins of the reference image used as a seed.
( .)The smoothing procedure of the reconstructed image that improves the local features of the microstructural geometry.

Reconstructing microstructural geometry
In at antecedent positions (thus the causal approach), because such an approach has already proven its merits in microstructural reconstruction, cf.[7].
To this end, we define a rectangular causal neighbourhood of (2h r + 1) × (h r + 1) pixels with parameter h r being the given neighbourhood radius; see Fig. 1 for an illustration.Note that the positions highlighted in red constitute the real input data; the dark grey and yellow pixels are only a padding (without value) such that the whole input features a regular 2D shape and, consequently, pooling layers can be easily applied.The actual value of the dark grey pixel serves as a label during an extraction of the training data from a reference image.
The neural network for predicting the pixel values in Step 1 is designed such that the rectangular input is first subsampled using a n r p × n r p pooling layer, flattened and passed through several densely connected layers.Based on our numerical experiments, the maximum pooling layer consistently delivered better results than the average pooling layer.The setup of the training procedure and the effect of the remaining network parameters, namely the number of densely connected layers n r , the number of neurons in each layer n r n , the size of the pooling layer n r p and the neighbourhood radius h r , are discussed later in Section 4.
Once the network is trained, a new microstructural realization is generated by iterating over pixels of a to-be-reconstructed image in a raster scan order.Consequently, an initial microstructural geometry must be provided in a margin of width h r at the left, top, and bottom edge of the image; the initial values in the remaining part of the image are irrelevant and we generate them as a random binary noise; see Fig. 2b.

Smoothing procedure
Outputs of the model trained in Step 1 usually contain the main features of the trained microstructural geometry; however, local details are typically polluted by random noise; compare Figs.2a and 2c.For Step 2 we train an additional neural network to smooth out the image and correct irregularities in the image generated in the Step 1.
This time, the model works with a complete, i.e. non-causal, square neighbourhood around the central pixel (illustrated in Figure 3), usually of a smaller neighbourhood radius h s than in the causal model in Step 1. Again, the two-dimensional structure of the input is needed to facilitate a subsampling/pooling layer, which is then followed by flattening and passing through two densely connected layers.The impact of the actual choice (i.e.average vs maximum pooling) of the subsampling layer is discussed in Section 4).
To increase robustness of the trained model and prevent if from learning to simply copy the value of the central pixel, we introduce two errors: (i) the value of the dark grey pixel, which is used as a label in the training, is always randomized in the inputs, and (ii) we also randomly choose value for ξ × 100% of red pixels from Fig. 3.

Error quantification
In order to assess the performance of the proposed models beyond a visual inspection, we compare generated microstructural samples to the reference images in terms of spatial statistics.The most straightforward spatial statistics is a volume fraction φ of a chosen phase (the white phase, i.e. pixels with value 1, in our case).We define error ε φ as an absolute value of the difference between the volume fraction φ ref in the reference sample and the volume fraction φ gen in the generated microstructure, The second spatial statistics considered in our work is the two-point probability function S 2 (x), which states the probability of finding two points separated by x in a given phase.Since all our data are represented as a regular grid of values, the discrete version of S 2 (x) can be easily computed using the Fast Fourier Transform [2].Consequently, we quantify the discrepancy in the reference and a generated microstructure by means of their discrete two-point probability functions where A F is the Frobenius matrix norm [10] Finally, to quantify the effect of our smoothing noncausal model, we add the third error metric ε D that captures the level of local heterogeneity.Assuming a two-phase medium, a microstructure can be represented with a Boolean matrix M ∈ {0, 1} Ni×Nj .For  each pixel we can computed a local quantity D i,j as a sum of the averaged absolute differences between the value of the central pixel and its neighbouring eight pixels, The error ε D is then computed again as an average over the image excluding the one-pixel wide margin, i.e. ( The reasoning behind this error measure is that if we consider the phases of pixels in a very small neighbourhood around the central pixel, the number of pixels whose phase is different to that of the central pixel will be lower if the edges are properly smoothed out.Even though this might not necessarily be true for the pixels which form the edge of the reconstructed pattern (and thus, the black and white phase must switch), it will apply on a larger scale (hence, we compute the sum of the values of D ij, for all pixels in the image).Therefore, in theory, the lower the value of ε D is for an image, the more smoothed out the image should be.

Results
We report the effect of parameters on the quality of the microstructural reconstruction quantified with the error measures introduced in the previous chapter.
First, we focus on parameters of the reconstruction model.Tables 1 and 2   the number of densely connected layers n r and the number of neurons in each layer n r n , while keeping the neighbourhood radius h r and the pooling size n r p constant, on the volume fraction error ε φ and the twopoint probability error ε S2 , respectively.In particular, we set h r = 15 and n r p = 3 as these values produced the most visually appropriate reconstructions in early tests of the model.
The next two tables, Tabs.The next three tables, i.e.Tables 5, 6, and 7, summarize the parametric study for the smoothing model with non-causal neighbourhood.We chose the reconstructed image obtained by the first model using n r = 2 layers, each with n r n = 16 neurons, a neighbourhood radius of h r = 15 and a pooling size of n r p = 3 as an input to the model and compared the resulting smoothed-out image to the original microstructure (before reconstruction), recall Fig. 2a, in terms of the error measures introduced in Section 4. We carried out two sets of test: one for the average and one for the maximum pooling 2D layer.In each set, we altered the radius of the non-causal neighbourhood h s as well as the magnitude of the artificially introduced noise ξ.Each set rendered three tables as we inspected also the level of local heterogeneity ε D , in addition to the errors ε φ and ε S2 already reported for the generative model.Table 6.Values of the two-point probability error ε S 2 , depending on the magnitude of artificially introduce noise ξ, neighbourhood radius h s , and the type of pooling layer used (max or average).

Discussion
First, we add an observation regarding the three error measures defined in Section 3 and our visual perception of the reconstructed microstructures.The first error measure, ε φ , served as a coarse check that the volume fraction in the reconstructed image is similar to the original; however, it could not assess how similar the reconstructed pattern is to the original.For this purpose, we adopted ε S2 , based on the two-point correlation function, as we excepted it ot be better suited to compare the reconstructed pattern to the original.original one.For example, the generative model using n r = 2 layers, each with n r n = 16 neurons, neighbourhood radius of h r = 15 and a pooling size of n r p = 3, could probably be considered as the most accurate in terms of the visual pattern (the image reconstructed using this model is in Figure 2c), but only seventh best according to ε S2 .We conclude that other spatial statistics such as two-point cluster function or lineal path should be added to the suite of error measures as well to capture both the global distribution of a microstructure and its local characteristics.On the other hand, the assessment of the smoothing model by ε D values was generally in accordance with the quality of the visual appearance of the reconstructed images.
Our results show that taking more layers with less neurons in each was favourable to the approach with less but more populated layers.Perhaps as expected, the larger neighbourhood radius was considered during training of the generative model, the better the results were.Surprisingly, n r p = 2 pooling size was better for the largest neighbourhood radius, while larger pooling was preferential in all other cases.
In the case of the smoothing model, considering larger neighbourhood radius h s beyond certain threshold (in our case h s = 7) did not improve its performance.This can be attributed to the different purpose of both models; while the generative model needs information from distant points to properly distribute the material with the sample, the smoothing model is by its nature local.On the other hand, larger pooling layer was consistently outperforming the smaller one in all tests.Most importantly, we noticed that the values of ε D were significantly lower for the smoothing models using an average pooling layer instead of a maximum pooling layer.This is probably due to the fact that the average pooling layer ignores sharp features in the image (e. g. individual pixels whose phase was not correctly identified in the Part 1 of the reconstruction), which allowed us to smooth out the edges of the reconstructed pattern in the image.
However, it is important to emphasize that these observations are specific for the considered microstruc-ture.

Conclusions
Despite the simplicity of the proposed ANN-based model, accompanied by the ease of implementation facilitated by the TensorFlow framework and the Keras Sequential API, the model generates meaningful microstructural geometries.The combination of a causal model used for reconstruction and a noncausal smoothing model in particular yielded satisfying results, cf. Figure 4, considering the fact that the models knew only a limited local information.We believe that even better results can be obtained by, e.g., incorporating the considered errors directly in the loss function during the training process of individual networks.Yet, this remains to be done in our future work.
The need for the margin of initial values during reconstruction might be seen as a limitation restricting the model to generating microstructural samples only as large as the reference one, from which the margin can be easily copied.However, a possible solution is to take the reference sample, dismember it into pieces and reorder the pieces so that they form the margin of desired size.Alternatively, starting from different parts of the reference microstructure, a set of smaller samples can be generated; these samples can be then assembled together while blending the microstructure in their overlaps using, e.g., image quilting [6].

Figure 2 .Figure 3 .
Figure 2. Microstructure reconstruction process using the causal model.After training the neural network model on input data from the initial microstructure (a), the trained model is used to sequentially predict pixel values in a raster scan order using previously predicted pixel values from the causal neighbourhood.

PREPRINT
3 and 4, summarize the sensitivity study investigating the influence of the neighbourhood radius h r and the pooling size n r p

Figure 4 .
Figure 4. Effect of the smoothing network based on the non-causal model: (a) reconstructed image serving as an input, (b) microstructure corrected by the smoothing model.Both images are of size 200 x 200 pixels.

Table 1 .
illustrate the impact of altering Values of the volume fraction error ε φ , depending on the number of layers n r and the number of neurons in each layer n r n .

Table 2 .
Values of the two-point probability error ε S 2 , depending on the number of layers n r and the number of neurons in each layer n r n .

Table 3 .
Values of the volume fraction error ε φ , depending on neighbourhood radius h r and pooling size n r p .

Table 4 .
Values of the two-point probability error ε S 2 , depending on neighbourhood radius h r and pooling size n r p .

Table 5 .
Values of the volume fraction error ε φ , depending on the magnitude of artificially introduce noise ξ, neighbourhood radius h s , and the type of pooling layer used (max or average).

Table 7 .
Nevertheless, we noticed a significant discrepancy between the values of ε S2 for each model and the visual similarity of the reconstructed pattern to the Values of the local heterogeneity error ε D , depending on the magnitude of artificially introduce noise ξ, neighbourhood radius h s , and the type of pooling layer used (max or average).For comparison, the value of ε D for the reference image is 0.097.