# An Attention-Based Convolutional Neural Network for Acute Lymphoblastic Leukemia Classification
## 3 Materials and Methods
### Data Augmentation  
Data augmentation techniques can be used to overcome the problem of the limited size of a dataset, specifically in deep learning problems. Several techniques for image augmentation such as flipping, cropping, and rotation are used to obtain different copies of the original image. It gives the algorithm more generalization capabilities when we train our system not only with original images but with augmented images too. It has been stated that training a system with augmented images reduces the error rate and provides better generalization [41; 42; 43; 44; 45; 46]. The CNM-C 2019 is an imbalanced dataset that may degrade the performance of deep learning models. Data imbalanced problems usually cause overfitting and lead the model towards poor generalization. In order to avoid the problem of overfitting and to increase the number of images in the dataset, we used different data augmentation techniques such as rotation, horizontal and vertical flip, brightness correction, and contrast adjustments on the training dataset. The augmentation on images is applied on the run for every single image. Every time the model gets an image, it loops through the image and generates four augmented images in case of healthy cell images and generates two images in case of ALL cancer cell images, as shown in Figure 2.  
\begin{table}
\begin{tabular}{c c c} \hline \hline  & \multicolumn{2}{c}{**Cancer Cell Images**} \\ \hline
**Fold** & **No. of Subjects** & **No. of Images** \\ \hline
1 & 8 & 1119 \\
2 & 7 & 1100 \\
3 & 4 & 1200 \\
4 & 7 & 1218 \\
5 & 8 & 1203 \\
6 & 7 & 1209 \\ \hline Total & 41 & 7049 \\ \hline \multicolumn{3}{c}{**Normal Cell Images**} \\ \hline
**Fold** & **No. of Subjects** & **No. of Images** \\ \hline
1 & 3 & 562 \\
2 & 4 & 473 \\
3 & 4 & 538 \\
4 & 3 & 541 \\
5 & 3 & 524 \\
6 & 3 & 538 \\ \hline Total & 20 & 3176 \\ \hline \multicolumn{3}{c}{**Testing Data**} \\ \hline
**Class** & **Subjects** & **No. of Images** \\ \hline Healthy & 6 & 213 \\ Cancer & 6 & 223 \\ \hline Total & 12 & 436 \\ \hline \hline \end{tabular}
\end{table}
Table 1: The test and training data for each class is 7-fold. Folds 1–6 represents the training data. All cell images belonging to the same subject are placed in the same fold and not a single fold includes cell image from the same subject.  
Random rotation is applied to rotate the images clockwise, according to the value between (\(-45\) to \(45\)) degrees. Horizontal and vertical flipping was also applied on images to horizontally and vertically flip the entire rows and columns of an image to produce a mirror image. Table 2 represents our dataset distribution before and after augmentation for each fold, while Figure 3 represents the images before and after augmentation. There is a smaller number of healthy cell images than ALL cancer cell images in the C-NMC dataset. Therefore, to balance the dataset class-wise, we randomly applied the mentioned augmentation techniques on every image. These augmentation techniques always vary between flipping, rotation, contrast, and brightness correction. The healthy images are augmented at a double rate than ALL cancer cells to produce an equal number of images of both classes. Whenever the model gets an image, it generates two augmented images in the case of cancer cell images and four augmented images in the case of normal cell images.  
Figure 3: The result of applying data augmentation (**b–d**). (**a**) Original image (**b**) brightness correction and contrast adjustments, (**c**) rotation, and (**d**) vertical and horizontal flipping.  
Figure 2: The illustration of the image augmentation process.