# Detecting Image Forgery over Social Media Using U-NET with Grasshopper Optimization
## 2 Materials and Methods
### Models and Architecture
#### 2.2.1 Cross-Entropy (XE) Training  
In the first step, two-dimensional (2D) convolution is applied to the input image along with batch normalization and the nonlinear ReLU function, which reduces the number of channels. Then, the max-pooling operation is performed to obtain the pooled (integrated) feature map. Downsampling reduces the size of the input, and this sequence of operations is repeated four times in the encoder path. The output of the last encoder layer with smaller dimensions is considered as the input of the connected module with more weight. In this way, a local representation of the feature map generated from the last block of the proposed encoder path is obtained. The integrated module is placed in the bottleneck layer of U-Net because the input transmitted in the module reduces in size and dimension, which decreases the amount of time required for training and the complexity of the space in the feature maps. The bottleneck layer is a part of the encoder-decoder architecture proposed for image forgery detection. The bottleneck layer is placed after the last encoder layer and before the decoder layers in U-Net. The input to the bottleneck layer is the output of the last encoder layer with smaller dimensions. The proposed model improves the image forgery dataset's segmentation efficiency by increasing the convolutional layers and modifying the connected encoder-decoder added to the model. Figure 4 shows the encoder-decoder connection module. The last merged feature map enters the module, which is a convolutional layer with a filter size of 3 \(\times\) 3. The feature map of the last layer in the proposed model is in accordance with the SoftMax function, which produces the number of feature channels equal to the number of semantic segmentation label classes. In the last layer, an image with a size of 512 \(\times\) 512 is obtained, which is equal to the image's original dimensions. Each convolutional layer comprises feature maps, and C is the convolutional layer. Equation (1) expresses the first layer's convolution with its constituents:  
\[C_{j}^{(1)}=f\left(B_{j}^{(1)}+K_{j}^{(1)}\times I\right)\,\,where\,j=1,\dots,M^{(n)} \tag{1}\]  
Here, j is the number of feature maps, and f(y) is the linear function applied to the filtered output before passing it to the convolution layer; I represents the input neuron; M  
Figure 4: Encoder connection module. Figure 3: Encoder Flow Diagram. denotes the feature map, and n denotes the number of layers. The feature map in the first layer C(1) is obtained by convolution of the input matrix in the kernel K(1) and adding the bias component B(1). In the first convolution layer, the input is convoluted with the weight matrix to obtain a feature map. The feature map is obtained by sliding over different positions of the input matrix based on the value of the stride setting. Features, thus extracted, and the weight parameters are shared between all classes of the dataset. Therefore, this layer has a property equal to the variance and is unchangeable to image transformations. The loss function based on the Dice coefficient uses every 200 cycles to express the Dice loss, which is also included in the evaluation matrix given in Equation (2). \[Dice\ loss=1-dice(a,c)=1-2\times\frac{a\cap c}{a+c} \tag{2}\]  
In Equation (2), a represents the ground truth or target binary mask, and c represents the predicted binary mask produced by the model. The intersection of a and c represents the number of pixels that are correctly classified as the object of interest in both the ground truth and predicted masks. The sum of a and c represents the total number of pixels classified as the object of interest in both masks. The Dice coefficient loss function is implemented after the final upsampling layer in the decoder part of the U-Net network. The final upsampling layer produces a predicted segmentation mask, which is compared to the ground truth mask using the Dice coefficient loss function.