## 2 Material and Methods
### Methods
#### 2.2.5 The Training Workflow  
As said above, this paper aims to evaluate and explore the performance of direct training that receives the image of a ruined temple and returns that temple reconstructed by adding the missing architectonical elements. So, for the training, we need pairs of a temple in ruins and the same temple complete. This algorithm comprises 4 stages that are repeated for each epoch with batches of n images from the training dataset. The 4 stages are described as follows:  
1. n images of ruins \(\{x_{1},\ldots,x_{n}\}\) are taken from the training dataset;
2. n equivalent images of the reconstructed temple \(\{y_{1},\ldots,y_{n}\}\) are taken from the training dataset;
3. The generator's hyperparameters are tuned with the gradient descent;
4. The discriminator's hyperparameters are tuned with the gradient descent.  
In depth, the training dataset is introduced in the generator autoencoder until it finds a mapping between both types of images (the image with the temple in ruins and its reconstruction). This is achieved by benefiting from the encoder, which reduces the input data size by applying convolutional layers (encoder) until the information is reduced to a small piece of data containing the main features. Then, this piece of data is upscale (decoder), trying to convert it to the output data (restored temple). This output image is what needs to be evaluated. This task is performed by the discriminator, which will evaluate if the image belongs to the original dataset or has been created by the generator. This information provided by the discriminator is used by the generator to improve its performance by tuning its hyperparameters. Figure 4 describes the training process.  
If we consider \(x\in X\) as the input image of the model that represents the temple in ruins belonging to the training dataset, then \(y\in Y\) will be the expected results, which, in this case, is the same temple with missing architectonical elements. The generator \(G\) reconstructs image \(y_{\text{gen}}\) and also denotes \(G(x)=y_{\text{gen}}\). The discriminator produces two outputs that measure the distances between images. First, how different are the image of the ruined temple \(x\) and its corresponding image of a complete temple \(y\) denoted by \(D([x,y])=m_{\text{real}}\). Second, the same calculation between the ruined temple and the reconstruction made by the generator, \(D([x,y_{\text{gen}}])=m_{\text{gen}}\). In both cases, the outputs represent matrices of \(0\)'s and \(1\)'s. To evaluate the generator's loss, the following function is used.  
\[G_{\text{loss}}=-\frac{1}{n}\sum_{i=1}^{n}\log(D(x,G(x)))+\lambda L_{1}(G) \tag{6}\]  
where \(\mathcal{L}_{1}\) is the \(L_{1}\) distance between the expected value \(y\) and \(G(x)\) to minimize it.  
Then, the loss of the discriminators is evaluated. For this task, both the generated image and the expected image (one from the training dataset) are used, and \(D_{\text{loss}}\) is evaluated using the following equation that scales the results by \(\frac{1}{2}\) based on the pix2 pix paper.  
\[D_{\text{loss}}=-\frac{1}{2}[-\sum_{i=1}^{n}\log(D(x,y))+\log(1-D(x,G(x)))] \tag{7}\]  
To evaluate the direct training, we have designed several experiments that differ in the activation function. During this training, the dataset was split into training, validation, and test by using 2 complete temples for validation and 1 for the test. This decision has been taken considering the similarity between the images of one temple. The test temple has not been chosen randomly due to this condition. In this way, we have ensured that this temple is sufficiently different from those used in training. In terms of number, the training set comprises 9720 images, the validation set 720, and the test set 360.