This project contains the PyTorch implementation for a Graph Attention Network (GAT) framework for classifying colorectal cancer patches from the PathMNIST dataset. We explored both an End-to-End (raw pixel) and a Hybrid Autoencoder approach to node embeddings.
To set up the environment, run:
pip install torch torchvision
pip install torch-geometric
pip install medmnist
pip install pandas numpy matplotlib scikit-learnThe code was run on Windows 11 v24H2, using an Nvidia RTX 5070 GPU (12 GB of VRAM) with an AMD Ryzen 7 9800x3D processor, and 31.1 GB of standard RAM (6000 MT/s).
├── train_ae.ipynb # defines and trains the Autoencoder used for the Hybrid approach.
├── train_model_gat_ae.ipynb # uses the model from train_ae.ipynb to train the Hybrid GAT.
├── train_model_mlp.ipynb # trains a simple MLP for baseline comparison.
├── train_model_simple.ipynb # trains the End-to-End GAT.
├── visualize_graphs.ipynb # visualizes the attention scores
├── download_data.ipynb # contains the downloading data and graph creations.
├── GATModels.py # contains the GAT model definitions.
├── AutoEncoder.py # contains the Autoencoder definition.
├── util/ # contains various utility files used in graph creation and dataset representation.
└── README.md # project documentation
- Run
download_data.ipynbto download the dataset and to create the graphs. - Run
train_model_mlp.ipynbto train the baselines. - Run
train_ae.ipynbto train the Autoencoder to embed the node features. - Run
train_model_gat_ae.ipynbto train the Hybrid GAT. - Run
train_model_simple.ipynbto train the End-to-End GAT (best model performance). - Run
visualize_graphs.ipynbto visualize the attention scores on a fixed spatial grid.
| Model | Accuracy | AUC |
|---|---|---|
| GAT (End-to-End) | 0.775 | 0.962 |
| GAT (Hybrid) | 0.689 | 0.942 |
| MLP Baseline | 0.638 | 0.925 |