## 4 Image Classification with CNN Using Optimized Transfer Learning  
To solve the problem of classifying similar sports images into proper disciplines, we developed the adaptive CNN training method, which is based on an adopted CNN architecture, trained using the transfer learning approach where the hyper-parameters for fine tuning are optimized with the use of DE--we named the method CNN-TL-DE. The pseudo-code of the whole method is presented in Algorithm 1. The method accepts as input a training dataset, a pre-trained CNN model, and the number of hyper-parameters to be optimized. The control parameters for both the DE (Np, CR, F,and number of model evaluations) and CNN training (number of epochs for each individual within the DE, number of epochs for the final model, early stopping criteria, and batch size) also need to be defined. The output of the method is the trained CNN model for the classification of sports images. ```
1:splitting dataset D in ratio 80% (trainD) to 20% (validationD)
2:initialize DE (generate initial population \(P^{(0)}=\{x_{1}^{(0)},x_{2}^{(0)},...,x_{Np}^{(0)}\}\))
3:\(t=0\)
4:for each individual \(x_{i}^{(t)}\) in the population \(P^{(t)}\)do
5: train CNN model using the parameters from \(x_{i}^{(t)}\) on trainD
6: evaluate each trained CNN model on validationD and use it as fitness score
7:endfor
8:repeat
9:for each individual \(x_{i}^{(t)}\) in the population \(P^{(t)}\)do
10: generate three random integers \(r_{1},r_{2},r_{3}\in\{1,2,\ldots,N_{p}\}\setminus i\), with \(r_{1}\
eq r_{2}\
eq r_{3}\)
11: generate a random integer \(j_{rand}\in\{1,2,...,n\}\)
12:endfor
13:for each parameter \(j\in\{1,2,\ldots,n\}\)do
14: pick a uniformly distributed random number \(r_{j}\sim U(0,1)\)
15:if\(r_{j}<CR\) or \(j=j_{rand}\)then
16:\(u_{i}^{(t+1)}=u_{r_{1},j}^{(t)}+F\times(u_{r_{2},j}^{(t)}-u_{r_{3},j}^{(t)})\)
17:else
18:\(u_{i}^{(t+1)}=x_{i,j}^{(t)}\)
19:endif
20:endfor
21: train CNN model using the parameters from \(u_{i}^{(t+1)}\) on trainD
22: evaluate the trained CNN model on validationD and use it as fitness score
23:if\(u_{i}^{(t+1)}\) is better than \(x_{i}^{(t)}\)then
24: replace \(x_{i}^{(t)}\) with \(u_{i}^{(t+1)}\) in the population \(P^{(t+1)}\)
25:endif
26:\(t=t+1\)
27:until the termination condition (predefined number of model evaluations) is achieved
28: pick the individual \(x\) from the population \(P\) that has the best fitness
29: train the final CNN model using the hyper-parameters from \(x\) on the whole training dataset \(D\)
```  
**Algorithm 1** CNN-TL-DE algorithm. The architecture of our CNN model is presented in Figure 1 and is based on a well known and often used CNN model VGG19 by [PERSON] et. al. [52]. While we kept the convolutional layers, represented by the blocks from _Block1_ to _Block5_, as defined in VGG19, the classification part of the adopted VGG19 model, consisting of six layers, was tailored to our specific task of identifying sports disciplines from image. On top of _Block5_, we appended the spatial two-dimensional dropout layer denoted in the figure as \(SDO\_2D\), two-dimensional global average pooling layer denoted as \(GAP\_2D\), batch normalization layer denoted as \(BN\), fully-connected layer denoted as \(FC\_1\), dropout layer, and finally fully-connected output layer with a sigmoid activation function denoted as \(FC\_2+Sigmoid\). The introduction of two dropout layers was needed to reduce the over-fitting problem, which commonly occurs when fine-tuning a large CNN architecture such as VGG19 against rather small dataset as in our case. For training our adapted VGG19 CNN model, we applied the transfer learning approach with fine-tuning. In this manner, all the convolutional layers were first pre-trained on the ImageNet dataset [53]. Then, the model was fine-tuned on our sports images dataset. During fine-tuning, the convolutional blocks from _Block1_ to _Block4_ remained disabled (their weights remained unchanged), while the convolutional _Block5_ and all the classification layers were fully trained.