## 3 Materials and Methods
### Proposed Model of Multiple Instance Classification Based on GCNs  
In the framework of multiple instance classification, the WSIs with the malignant/benign labels can be viewed as positive/negative bags. The patches containing malignant/benign tissue information can be regarded as positive/negative instances. In our experiment, all the image patches passed through CNNs for further feature extraction and dimension reduction. Thus, the instances in the MIC framework are replaced by patch features, which is illustrated in Figure 3. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Dataset** & **WSI Number** & **Patch Resolution** & **Threshold** & **Patch Number** \\ \hline SRS & 185 & 224 \(\times\) 224 pixels & 35,000 (17.3\%) & 68,387 \\ Mars & 2032 & 450 \(\times\) 450 pixels & 15,000 (29.9\%) & 396,539 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Some indicators in data processing. Figure 2: The example of a gastric cancer histopathology image. (**a**) SRS image. (**b**) H&E stained image. In order to solve this multiple instance classification problem from the perspective of graphs, we propose a novel algorithm based on GCNs for gastric cancer pathology image classification. The whole flowchart is illustrated in Figure 4. The first step is to map bag space into graph space, converting the multiple instance classification problem into a graph classification problem. An alternative heuristic strategy is: given a set of bags \([X_{1},X_{2},\dots,X_{N}]\), each bag contains a different number of instances \(\left[x_{1}{}^{(i)},x_{2}{}^{(i)},\dots,x_{K}{}^{(i)}\right]\). We regard each bag in MIL as a graph, thus a bag of instances is converted into an undirected graph. The adjacency matrix can be derived with the following formula:  
\[A_{mn}{}^{(i)}=\left\{ \begin{array}{c}1\;if\;distance\Big{(}x_{m}{}^{(i)},x _{n}{}^{(i)}\Big{)}<\eta\\ 0\;otherwise\end{array} \right. \tag{8}\]  
where distance \(\Big{(}x_{m}{}^{(i)},x_{n}{}^{(i)}\Big{)}\) is the Euclidean distance between the m-th and n-th instance in i-th bag. The subscript represents the order of instances in the bag, and also implies that it corresponds to the spatial position relationships in the original image. \(\eta\) is the threshold to decide whether there is a connecting edge between two instances based on their distance. The task is converted to learn a graph classification model that maps from graph to the corresponding label with the node feature, edges and graph labels given. After converting bags of instances into graphs, a classification model based on GCNs is constructed, as detailed in Figure 4. The network architecture is composed of stacks of  
Figure 4: The flowchart of the proposed method. Figure 3: The flowchart of the multiple instance classification. units consisting of GNN modules and DIFFPOOL modules, one feature embedding GNN module and two fully connected layers. In the experiment, the GNN module was built on the GraphSAGE architecture [19]. Compared to a traditional GCN, GraphSAGE is a framework for inductive representation learning on large graphs. By sampling neighbor nodes randomly, it resolves the defect of poor flexibility and expansibility of traditional GCN and achieves the small batch distributed training of large-scale graph data. The node aggregation and embedding generation are illustrated in the following formula:  
\[h_{v}^{k}=\sigma\Big{(}W^{k}\text{-}mean\Big{(}h_{u}^{k-1},\;\forall u\; \epsilon\;\mathcal{N}(v)\cup\{v\}\Big{)}\Big{)} \tag{9}\]  
where \(h_{v}^{k}\) is the representation of node \(v\) at the layer \(k\) and \(\mathcal{N}(v)\) represents a set of neighbors of node \(v\). \(\sigma(\cdot)\) represents the nonlinear activation function; specifically, LeakyReLU [20] was adopted in the experiment. Additionally, the aggregation function adopts inductive aggregation.