Giter Site home page Giter Site logo

lirongwu / ff-g2m Goto Github PK

View Code? Open in Web Editor NEW
18.0 2.0 1.0 71 KB

Code for AAAI 2023 (Oral) paper "Extracting Low-/High- Frequency Knowledge from Graph Neural Networks and Injecting it into MLPs: An Effective GNN-to-MLP Distillation Framework"

License: MIT License

Python 100.00%
graph-neural-networks knowledge-distillation graph-knowledge-distillation graph-signal-processing high-frequency-analytics

ff-g2m's Introduction

Full-Frequency GNN-to-MLP Distillation (FF-G2M)

This is a PyTorch implementation of the Full-Frequency GNN-to-MLP Knowledge Distillation (FF-G2M), and the code includes the following modules:

  • Dataset Loader (Cora, Citeseer, Pubmed, Amazon-Photo, Coauthor-CS, and Coauthor-Phy) and data splitting strategy
  • Various teacher GNN architectures (GCN, SAGE, GAT) and student MLPs used in this paper
  • Training paradigm for teacher GNNs and student MLPs
  • Visualization and evaluation metrics

Introduction

Recent years have witnessed the great success of Graph Neural Networks (GNNs) in handling graph-related tasks. However, MLPs remain the primary workhorse for practical industrial applications due to their desirable inference efficiency and scalability. To reduce their gaps, one can directly distill knowledge from a well-designed teacher GNN to a student MLP, which is termed as GNN-to-MLP distillation. However, the process of distillation usually entails a loss of information, and "which knowledge patterns of GNNs are more likely to be left and distilled into MLPs?" becomes an important question. In this paper, we first factorize the knowledge learned by GNNs into low- and high-frequency components in the spectral domain and then derive their correspondence in the spatial domain. Furthermore, we identified a potential information drowning problem for existing GNN-to-MLP distillation, i.e., the high-frequency knowledge of the pre-trained GNNs may be overwhelmed by the low-frequency knowledge during distillation; we have described in detail what it represents, how it arises, what impact it has, and how to deal with it. In this paper, we propose an efficient Full-Frequency GNN-to-MLP (FF-G2M) distillation framework, which extracts both low-frequency and high-frequency knowledge from GNNs and injects it into MLPs. Extensive experiments show that FF-G2M improves over the vanilla MLPs by 12.6% and outperforms its corresponding teacher GNNs by 2.6% averaged over six graph datasets and three common GNN architectures.

Dependenciesc

  • numpy==1.19.2
  • scipy==1.3.1
  • torch==1.6.0
  • dgl == 0.6.1

Overview

  • train_and_eval.py

    • train_teacher() -- Pre-train the teacher GNNs.
    • train_student() -- Train the student MLPs with the pre-trained teacher GNNs.
  • model.py

    • MLP() -- student MLPs
    • GCN() -- GCN Classifier, working as teacher GNNs
    • GAT() -- GAT Classifier, working as teacher GNNs
    • GraphSAGE() -- GraphSAGE Classifier, working as teacher GNNs
    • edge_distribution_low() -- Loss for Low-Frequency Distillation (LFD)
    • edge_distribution_high() -- Loss for High-Frequency distillation (HFD)
  • dataloader.py

    • load_data() -- Load Cora, Citeseer, Pubmed, Amazon-Photo, Coauthor-CS, and Coauthor-Phy datasets and their data splittings.
  • utils.py

    • set_seed() -- Set radom seeds for reproducible results.

Running the code

  1. Install the required dependency packages

  2. To get the results on a specific dataset, please run with proper hyperparameters:

python train.py --dataset data_name --ablation_mode mode

where the data_name is one of the six datasets (Cora, Citeseer, Pubmed, Amazon-Photo, Coauthor-CS, and Coauthor-Phy), and ablation_mode denotes different experimental settings (0: FF-G2M; 1: vanilla MLPs; 2: GLNN; 3: Low-Frequency Distillation (LFD); 4: High-Frequency distillation (HFD). Use the FF-G2M model with the default optimal hyperparameters on the Citeseer dataset as an example:

python main.py --dataset citeseer --ablation_mode 0

Citation

If you find this project useful for your research, please use the following BibTeX entry.

@inproceedings{wu2023extracting,
  title={Extracting low-/high-frequency knowledge from graph neural networks and injecting it into mlps: An effective gnn-to-mlp distillation framework},
  author={Wu, Lirong and Lin, Haitao and Huang, Yufei and Fan, Tianyu and Li, Stan Z},
  booktitle={Proceedings of the AAAI Conference on Artificial Intelligence},
  volume={37},
  number={9},
  pages={10351--10360},
  year={2023}
}

ff-g2m's People

Contributors

lirongwu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

yanjiangjerry

ff-g2m's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.