Code Monkey home page Code Monkey logo

ci-gcl's Introduction

CI-GCL

Community-Invariant Graph Contrastive Learning" (CI-GCL)

Overall Framework

This is the code for "Community-Invariant Graph Contrastive Learning" (CI-GCL). CI-GCL adopt learnable data augmentation with Community-Invariant constraint on both topology and features. And all these parts are jointly optimized to make sure the augmentation schemes can benefit from contrastive loss, CI constraints and downstream classifiers.

Requirement

Code is tested in Python 3.10.13. The requirements are listed below:

pip install torch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 --index-url https://download.pytorch.org/whl/cu118
pip install torch_geometric
pip install pyg_lib torch_scatter torch_sparse torch_cluster torch_spline_conv -f https://data.pyg.org/whl/torch-2.1.0+cu118.html
pip install dgl
pip install networkx
pip install tqdm tabulate
pip install scipy
pip install scikit-learn

Tip

Since we modify the framework of PyGCL, please do not include the PyGCL package in your enviroment.

Run the code

For different graph-level tasks, we provides:

Launch graph classification in unsupervised setting

python graph_classification.py --dataset_name ${dataset_name} --gpu ${gpu}

${dataset_name} is the dataset name (please refer to TU dataset), ${gpu} is the lanched GPU ID

Launch graph classification in transfer learning setting

python graph_transfer_pretrain_and_finetune.py --dataset_name ${dataset_name} --ft_dataset ${ft_dataset}

where ${dataset_name} is the pretrain dataset, and ${ft_dataset} is the finetune dataset

Tip

For transfer learning, please refer to pretrain-gnns for environment setup and dataset download.

Tip

When you can't manage to install the old torch-geometric versions, or you can't load the old datasets from "pretrain-gnns", you could install a new torch-geometric version and make modification based on pytorch_geometric (And the issue in pretrain-gnns could help either).

Launch the robustness of the pretrained encoder

We randomly drop and add [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] edges in topology robustness test. And randomly add gaussian noise to [0.05, 0.1, 0.15, 0.2, 0.25, 0.3] positions in feature robustness test.

python robustness_check.py --dataset_name ${dataset_name}
python robustness_check_feature.py --dataset_name ${dataset_name}

ci-gcl's People

Contributors

shiyintan avatar

Stargazers

Ubastic avatar Jung avatar  avatar Wang-MMM-Lab avatar Ziwen Zhao avatar Dongyuan Li avatar Jeongwhan Choi avatar

Watchers

 avatar

Forkers

zhuolinli-shu

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.