# Double-Shot Transfer Learning for Breast Cancer Classification from X-Ray Images
## 2 Materials and Methods
### Double-Shot Transfer Learning
Unlike TrAdaBoost [27] that filters out instances which are dissimilar to the target domain in source domains, the proposed DSTL adds new instances to the source domain \(\mathcal{D}_{s}\) that are similar to the \(\mathcal{D}_{t}\) to update the weights of the parameters in the pre-trained models in the \(\mathcal{D}_{s}\) and form a distribution similar to the target domain. Figures 3 and 4 show a sketch of the instances transferring in SSTL and DSTL respectively. ```
1:Info, EpochsNumber
2:BestValAccuracy
3:\(Stop\gets false\)
4:\(BestValAccuracy\gets Null\)
5:if\(infoState==start\)then
6:\(BestValAccuracy\gets Null\)
7:\(ValidationLagging\gets Null\)
8:elseif infoValLossthen
9:if\(InfoValAccuracy>BestValAccuracy\)then
10:\(ValidationLagging\gets Null\)
11:\(BestValAccuracy\gets InfoValAccuracy\)
12:else
13:\(ValidationLagging\gets ValidationLagging+1\);
14:endif
15:endif
16:if\(ValidationLagging>=N\)then
17: stop = true;
18:endif
19:endif
20:return\((BestValAccuracy)\)
```  
**Algorithm 1** Validation Accuracy Monitoring  
**Definition 1** (Standard Transfer Learning). : _Given a source domain \(\mathcal{D}_{s}\) and learning task \(\mathcal{T}_{s}\), a target domain \(\mathcal{D}_{t}\) and learning task \(\mathcal{T}_{t}\), transfer learning aims to help improve the learning of the target predictive function \(f(. )\) in \(\mathcal{D}_{t}\) using the knowledge in \(\mathcal{D}_{s}\) and \(\mathcal{T}_{s}\), where \(\mathcal{D}_{s}\
eq\mathcal{D}_{t}\) and/or \(\mathcal{T}_{s}\
eq\mathcal{T}_{t}\). \(\mathcal{D}_{s}\
eq\mathcal{D}_{t}\) implies that either \(\mathcal{X}_{s}\
eq\mathcal{X}_{t}\) or \(P_{s}(X)\
eq P_{t}(X)\). \(\mathcal{T}_{s}\
eq\mathcal{T}_{t}\) implies that either \(\mathcal{Y}_{s}\
eq\mathcal{Y}_{t}\) or \(P(Y_{s}|X_{s})\
eq P(Y_{t}|X_{t})\)._  
**Definition 2** (Dstl). : _Given a source domain \(\mathcal{D}_{s}\) and learning task \(\mathcal{T}_{s}\), a target domain \(\mathcal{D}_{t}\) and learning task \(\mathcal{T}_{t}\), transfer learning aims to help improve the learning of the target predictive function \(f(. )\) in \(\mathcal{D}_{t}\) using the knowledge in \(\mathcal{D}_{s}\) and \(\mathcal{T}_{s}\), where \(\mathcal{D}_{s}\simeq\mathcal{D}_{t}\) and \(\mathcal{T}_{s}\simeq\mathcal{T}_{t}\). \(\mathcal{D}_{s}\simeq\mathcal{D}_{t}\) implies that \(\mathcal{X}_{s}\simeq\mathcal{X}_{t}\) and \(P_{s}(X)\simeq P_{t}(X)\). \(\mathcal{T}_{s}\simeq\mathcal{T}_{t}\) implies that \(\mathcal{Y}_{s}\simeq\mathcal{Y}_{t}\) and \(P(Y_{s}|X_{s})\simeq P(Y_{t}|X_{t})\)._  
In our context, the learning task is image classification (Benign or Malignant), and each pixel or weight is taken as a feature, hence \(\mathcal{X}\) is the space of all pixel vectors, \(x_{i}\) is the \(i\)th pixel vector corresponding to some images and \(X\) is a specific learning sample. Additionally, \(\mathcal{Y}\) is the set of all labels, which is Benign, Malignant for the classification task, and \(y_{i}\) is \"Benign\" or \"Malignant\". In our context, \(\mathcal{D}_{s}\) can be a set of weights vectors together with their associated Benign or Malignant class labels. Based on the above DSTL definition, a domain is a pair \(\mathcal{D}=\{X,P(X)\}\), hence, the condition \(\mathcal{D}_{s}\simeq\mathcal{D}_{t}\) implies that \(\mathcal{X}_{s}\simeq\mathcal{X}_{t}\) and \(P_{s}(X)\simeq P_{t  
instances from \(\mathcal{D}_{s}\) and \(\mathcal{D}_{t}\), making it domain invariant. In this research, various pr-trained models were fine-tuned on 98,967 of the augmented CBIS-DDSM dataset, and saved as the name of the original pre-trained network followed by the symbol (+) to distinguish them from the original pre-trained networks that were only trained on ImageNet dataset. Next, the updated pre-trained models (+) were fine-tuned for the second time on the augmented images of the target datasets of MIAS and BCDR. Figure 5 illustrates the process of DSTL. All the pre-trained networks that have been used in this research share three common layers namely input layer, FC layer, and classification layer.