# Deep Learning Methods for Bug Bite Classification: An End-to-End System
## 2 Materials and Methods
### CNN Variants Used for Bug Bite Classification
#### 2.6.1 Convolutional Neural Network Architectures  
**MobileNet-v2. ** One of the chosen base models in this research is MobileNet-v2 [37]. We selected this model since it is lightweight, less complex, and, at the same time, has high execution speed. It is specifically tailored to fit the exceptionally limited performances of mobile devices and other constrained-resource environments. The model consists of 3,538,984 parameters in total and has a depth of 88 layers. For this research, we used the implementation of the initial model from the Python library Keras [38], on top of which we built the custom layers. Transfer learning was performed using the ImageNet dataset,and the weights learned on this dataset were used to initialize the MobileNet-v2 model. Then, we added custom layers over the pre-trained Mobilenet-v2 to be able to fine-tune the existing network for our specific task of bug bite image classification. In fact, the output of the last layer of the MobileNet-v2 model, consisting of 1280 feature maps that were 7 units in width and height, was fed into a two-dimensional convolutional layer with 256 kernels of size 3 \(\times\) 3 with ReLU [39] as an activation function. Then, global average pooling was performed, which resulted in a feature vector with 256 features, each generated from one of the feature maps produced in the previous convolutional step. In the next step, a dense layer with 64 neurons and ReLU as an activation function, along with a connection dropout rate of 10%, was used. Another dense layer with 32 neurons and a ReLU activation function was then added, the result of which was finally fed into a softmax layer (usually used for multi-label classification) with 9 neurons, representing a normalized probability of each of the 9 classes. The complete model architecture, including the custom layers, is depicted in Figure 5.  
The training process was executed by freezing all of the parameters of the pre-trained MobileNet-v2 model and updating only the weights of the additionally stacked layers. The resulting model has a total of 2,968,168 trainable and 2,257,984 non-trainable parameters. The loss function that was optimized was categorical cross-entropy loss, calculated as: \(L_{CE}=-\sum_{i=1}^{n}t_{i}log(p_{i})\), where \(t_{i}\) is the true label, \(p_{i}\) is the softmax probability for the \(i\)th class, \(n\) is the number of classes, and log is calculated to base 2. The Adam optimizer was used for the gradient descent algorithm [40] and initialized with a learning rate of 3 \(\times\) 10\({}^{-7}\). The model was fit to the training dataset using 150 epochs. A model summary based on MobileNet-v2 with custom layers is given in Table 3.  
Figure 5: Architecture of the complete model with pre-trained MobileNet-v2 model and added custom layers on top of it. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Layer** & **Output Shape** & **Number of Parameters** \\ \hline Conv2D & (None, 7, 7, 1280) & 409,600 \\ Conv 1 BatchNormalization & (None, 7, 7, 1280) & 5120 \\ Out ReLU & (None, 7, 7, 1280) & 0 \\ Conv2D & (None, 7, 7, 256) & 2,949,376 \\ Global average pooling2d & (None, 256) & 0 \\ Dense & (None, 64) & 16,448 \\ Dropout & (None, 64) & 0 \\ Dense & (None, 32) & 2080 \\ Dense & (N, 9) & 264 \\ \hline \hline Total parameters: 5,226,152 & \\ Trainable parameters: 2,968,168 & \\ Non-trainable parameters: 2,257,984 & \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Summary of the custom layers added to the pre-trained MobileNet-v2 model. **VGG16. ** One of the most popular and widely used CNN models, also considered to be one of the best computer vision models, is VGG16 [41; 42]. This model achieved 92.7% test accuracy on the ImageNet dataset. Although it is a very extensive network, containing 138 million parameters and 21 layers, VGG16 is characterized by simplicity and fast convergence, in addition to its power. This is the reason why we also chose this architecture for our research.