Skip to content

PyTorch implementation of Heterogeneous Graph Neural Networks with attention aggregation for node classification on academic networks.

Notifications You must be signed in to change notification settings

abasit/heterogeneous-graphs-node-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Heterogeneous Graph Neural Networks for Node Classification

License: MIT

PyTorch implementation of Heterogeneous Graph Neural Networks with attention aggregation for node classification on academic networks.

Overview

This repository contains implementations of Heterogeneous Graph Neural Networks with two aggregation strategies:

  • Mean Aggregation: Simple averaging across different message types (paper-author and paper-subject connections)
  • Attention Aggregation: Learned semantic-level attention weights inspired by HAN (Wang et al., 2019)

Both models are tested on the ACM academic paper dataset, where the task is to classify papers into research areas based on their content and heterogeneous relationships.

Results

Performance on ACM dataset (3 classes, 3025 nodes):

Model Test Micro-F1 Test Macro-F1 Configuration Training Time
Mean 84.99% 84.41% 2 layers, 64 hidden < 2 min
Attention 86.54% 86.28% 2 layers, 64 hidden, 32 attn < 3 min

Learned Attention Weights:

  • Layer 1: Author connections (48.8%), Subject connections (51.2%)
  • Layer 2: Author connections (61.7%), Subject connections (38.3%)

Installation

# Clone the repo
git clone https://github.com/yourusername/hetero-gnn.git
cd hetero-gnn

# Create a virtualenv (recommended)
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install --upgrade pip
pip install -r requirements.txt

Usage

Below are example commands to train and evaluate the heterogeneous GNN models.

Dataset

The ACM academic paper dataset is automatically downloaded on first run. If the download fails, you can manually download acm.pkl from https://www.dropbox.com/scl/fi/cbe0pkadicrv128mi5odz/acm.pkl?rlkey=ppxff7rystkuafc7y9ae0qax1&dl=0 and place it in the data/ directory.

Dataset details:

  • 3,025 academic papers with 1,870-dimensional features
  • Two relationship types: paper-author and paper-subject connections
  • 3 research area classes for classification

1. Train with Mean Aggregation

python src/main.py --config configs/mean_aggregation.yaml

2. Train with Attention Aggregation

python src/main.py --config configs/attention_aggregation.yaml

Acknowledgments

This implementation draws inspiration from several key papers in heterogeneous graph learning:

Parts of this code were adapted from the Stanford CS224W "Machine Learning with Graphs" course materials:

Leskovec, Jure (Instructor). CS224W: Machine Learning with Graphs. Stanford University.
URL: https://web.stanford.edu/class/cs224w/

About

PyTorch implementation of Heterogeneous Graph Neural Networks with attention aggregation for node classification on academic networks.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages