# Generalizability of Deep Learning System for the Pathologic Diagnosis of Various Cancers
## 2 Materials and Methods
### Normal/Tumor Classifiers for the TCGA Tissue Datasets  
We divided each TCGA dataset into training and test datasets with a 9:1 ratio. The division was patient-wise and thus no slide from patients in the training dataset was included in the test dataset. For the frozen tissue WSIs of the TCGA datasets, there are normal or tumor WSIs which consisted of almost exclusively normal or tumor tissues, respectively. The normal or tumor WSIs are distinguished by the IDs of the WSIs (Figure 1a). Therefore, the patches from the frozen WSIs were simply labeled depending on their IDs. On the contrary, the FFPE tissue WSIs contain both normal and tumor tissues. To discriminate between them, I.H.S. and S.H.L. annotated normal and tumor regions in a FFPE WSI with the Aperio ImageScope software (Leica Biosystems) using a freehand drawing tool (Figure 1a). As depicted in Figure 1a, the normal/tumor tissue patch datasets were collected based on the IDs of WSIs or normal/tumor annotation for the frozen and FFPE WSIs, respectively, to train the normal/tumor classifiers for the frozen and FFPE tissues each. As we included six different cancer types (TCGA-BLCA, TCGA-LUAD/LUSC, TCGA-COAD/READ, TCGA-STAD, TCGA-CHOL, and TCGA-LIHC), total 12 classifiers were trained. Unlike the tissue/non-tissue classifier, the Inception-v3 model was used without any parameter changes to train the normal/tumor classifiers for the 360 \(\times\) 360-pixel patches at 20\(\times\) magnification. We adopted the inception-v3 model because it was superior for the normal/tumor discrimination task than other CNN architectures in our previous study [13]. Deep neural networks were implemented using the TensorFlow deep learning library ([[http://tensorflow.org](http://tensorflow.org)]([http://tensorflow.org](http://tensorflow.org))). We used a mini-batch size of 128, and the cross-entropy loss function was adopted as a loss function. For training, we used RMSProp optimizer, with initial learning rate of 0.1, weight decay of 0.9, momentum of 0.9, and epsilon of 1.0. To minimize overfitting, data augmentation techniques, including random horizontal/vertical flipping, random perturbation of the contrast and brightness, and random rotations by 90\({}^{\circ}\) were applied to the tissue patches during the training. Ten percent of the training data were used as a validation dataset for the early stopping of the training. Thus, the training session was terminated when the loss for the validation data started to increase. At least five models were trained for each dataset and the results from the most appropriate models were presented in the results section. Total six computer systems (one computer with dual NVIDIA Titan V GPUs, two computers with dual NVIDIA Titan RTX GPUs and three computers with dual NVIDIA RTX 2080 ti GPUs) were used to train the models. Figure 1: The workflow of the fully automated normal/tumor classifiers for whole slide images (WSIs). (**a**) Collection of the normal and tumor tissue image patches. For the frozen tissue WSIs, normal and tumor patches were collected depending on the IDs of the WSIs. For the formalin-fixed paraffin-embedded (FFPE) tissue WSIs, two pathologists annotated the normal and tumor regions. Normal and tumor patches were collected depending on the annotations. (**b**) Classification process for a representative WSI. At first, only proper tissue patches were selected by the tissue/non-tissue classifier. Then, the tumor probabilities of the proper tissues were obtained by the normal/tumor classifier. Finally, a heatmap was drawn to demarcate the normal/tumor distribution. For the test WSIs, non-overlapping 360 \(\times\) 360-pixel patches at 20\(\times\) magnification were collected and the tissue/non-tissue and normal/tumor classifiers were sequentially applied (Figure 1b). Only patches which were classified as tissue by tissue/non-tissue classifier were passed to the normal/tumor classifiers.