## 2 Materials and Methods
### Experimental Setup Description
#### 2.2.2 Fine-Tuning of the CNN  
Pre-trained networks can be exploited to recognize classes the system is not (initially) trained on, thanks to the fine-tuning process.  
The convolutional layers had already learned discriminative filters. After choosing the hyperparameters, described in the previous section (Section 2.2.1), we replaced the final set of fully connected layers of the pre-trained CNN. We introduced a new set of fully-connected layers using random weights. By doing so, the fully connected layers could act entirely randomly. If the gradient backpropagates from these random values and the whole network, the pre-trained network's powerful features risked being destroyed. To avoid this problem, we re-trained the CNN performing the following steps (Figure 5):  
1. Training of the last layer: we started with the pre-trained model's weights (pre-trained on ImageNet), freezing all layers in the network's body except the last layer. In this step, we trained only the last layer.
2. Unfreezing and training the whole model: in this step, after the last layer had started to learn patterns of our medical dataset, we unfroze all the weights and trained the entire model with a very small learning rate. We wanted to avoid altering the convolutional filters dramatically.  
For the fine-tuning of the network, we used the total dataset described in Section 2.1. In particular, the training dataset consisted of 8023 slices labeled as \"fracture\" and 34,962 labeled as \"noFracture\", for a total of 148 patients. The training and validation datasets used in the k-fold cross validation were a subset of this total training dataset. Since the two classes were no longer balanced, we used the CrossEntropyLoss as loss function with different weights for the \"fracture\" and \"noFracture\" classes (w\({}_{\text{f}}\) and w\({}_{\text{nf}}\), respectively):  
\[[\text{w}_{\text{f}},\text{w}_{\text{nf}}]=[\frac{|\text{noFracture}|}{| \text{fracture}|},\frac{|\text{noFracture}|}{|\text{fracture}|}]=[\frac{34,96 2}{8023},\frac{34,962}{34,962}]=[4.36,1.0] \tag{1}\]  
The validation dataset, used for the error evaluation, consisted of 1660 slices labeled as \"fracture\" and 7910 labeled as \"noFracture\", for a total of 30 patients.  
During the second step, we performed an additional fine-tuning, re-training the model twice by changing the learning rate to improve the model's performance. Before each re-train of the model, we loaded the network's weights that gave us the best performance in terms of accuracy. In particular, we used the learning rate finder [27; 28] of the Fastai library to choose the learning rate at each step. Since some features remain unchanged (such as the edges and the corners of an image learned in the first layers of the network),  
Figure 5: ResNet50 was used as a pre-trained network and, after loading the network, the fine-tuning process was started. We froze all the layers in the network except the fully-connected layers, useful for capturing high-level features on the current dataset. After the fully-connected layers have had a chance to learn patterns from our dataset, we then unfroze all the architecture layers; even the convolutional layers that had initially learned discriminative filters. We allowed each layer to be fine-tuned by performing two training steps and using differential learning rates.  
we applied the concept of differential learning rates implemented by the Fastai library. Using this approach, we could assign different learning rates to the various layers of our network. In particular, we passed a slice function inside the fit method and: (a) assigned a lower learning rate to the first layer, (b) assigned a higher learning rate to the last layer, and (c) distributed the values for the learning rate among all the other layers in between.