Code Monkey home page Code Monkey logo

jinheonbaek / gmt Goto Github PK

View Code? Open in Web Editor NEW
94.0 2.0 20.0 34.94 MB

Official Code Repository for the paper "Accurate Learning of Graph Representations with Graph Multiset Pooling" (ICLR 2021)

Home Page: https://arxiv.org/abs/2102.11533

MATLAB 6.22% Python 87.54% Shell 6.24%
graph-representation graph-representation-learning graph-pooling graph-multiset-pooling graph-multiset-transformer graph-classification graph-reconstruction graph-transformer graph-neural-networks pytorch graph

gmt's Introduction

Accurate Learning of Graph Representations with Graph Multiset Pooling

Official Code Repository for the paper "Accurate Learning of Graph Representations with Graph Multiset Pooling" (ICLR 2021) : https://arxiv.org/abs/2102.11533.

In this repository, we implement both Graph Multiset Pooling (GMPool) and Graph Multiset Transformer (GMT), proposed in our paper.

Abstract

Graph neural networks have been widely used on modeling graph data, achieving impressive results on node classification and link prediction tasks. Yet, obtaining an accurate representation for a graph further requires a pooling function that maps a set of node representations into a compact form. A simple sum or average over all node representations considers all node features equally without consideration of their task relevance, and any structural dependencies among them. Recently proposed hierarchical graph pooling methods, on the other hand, may yield the same representation for two different graphs that are distinguished by the Weisfeiler-Lehman test, as they suboptimally preserve information from the node features. To tackle these limitations of existing graph pooling methods, we first formulate the graph pooling problem as a multiset encoding problem with auxiliary information about the graph structure, and propose a Graph Multiset Transformer (GMT) which is a multi-head attention based global pooling layer that captures the interaction between nodes according to their structural dependencies. We show that GMT satisfies both injectiveness and permutation invariance, such that it is at most as powerful as the Weisfeiler-Lehman graph isomorphism test. Moreover, our methods can be easily extended to the previous node clustering approaches for hierarchical graph pooling. Our experimental results show that GMT significantly outperforms state-of-the-art graph pooling methods on graph classification benchmarks with high memory and time efficiency, and obtains even larger performance gain on graph reconstruction and generation tasks.

Contribution of this work

  • We treat a graph pooling problem as a multiset encoding problem, under which we consider relationships among nodes in a set with several attention units, to make a compact representation of an entire graph only with one global function, without additional message-passing operations.
  • We show that existing GNN with our parametric pooling operation can be as powerful as the WL test, and also be easily extended to the node clustering approaches with learnable clusters.
  • We extensively validate GMT for graph classification, reconstruction, and generation tasks on synthetic and real-world graphs, on which it largely outperforms most graph pooling baselines.

Dependencies

  • Python 3.7
  • PyTorch 1.4
  • PyTorch Geometric 1.4.3

Run

To run the proposed model in the paper, run following commands:

  • Graph Classification on TU datasets, including D&D, PROTEINS, MUTAG, IMDB-BINARY, IMDB-MULTI, and COLLAB (See the script file for the detailed experimental setup on each dataset).
  • First, and second arguments denote the gpu_id and experiment_number.
sh ./scripts/classification_TU.sh 0 000
  • Graph Classification on OGB datasets, including HIV, Tox21, ToxCast, and BBBP (See the script file for the detailed experimental setup on each dataset).
  • First, and second arguments denote the gpu_id and experiment_number.
sh ./scripts/classification_OGB.sh 0 000
  • Graph Reconstruction on the ZINC dataset (See the script file for the detailed experimental setup on each dataset).
  • First, and second arguments denote the gpu_id and experiment_number.
sh ./scripts/reconstruction_ZINC.sh 0 000
  • Graph Reconstruction on the synthetic datasets, including grid and ring graphs (See the script file for the detailed experimental setup on each dataset).
  • First, and second arguments denote the gpu_id and experiment_number.
sh ./scripts/reconstruction_synthetic.sh 0 000

Citation

If you found the provided code with our paper useful in your work, we kindly request that you cite our work.

@inproceedings{
    baek2021accurate,
    title={Accurate Learning of Graph Representations with Graph Multiset Pooling},
    author={Jinheon Baek and Minki Kang and Sung Ju Hwang},
    booktitle={International Conference on Learning Representations},
    year={2021},
    url={https://openreview.net/forum?id=JHcqXGaqiGn}
}

gmt's People

Contributors

jinheonbaek avatar nardien avatar

Stargazers

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

Watchers

 avatar  avatar

gmt's Issues

Is the reported performance based on 100 times of training?

Hi! This is a fantastic work! However, can I ask if the reported performance is based on 100 times of training? In Section C.2 GRAPH CLASSIFICATION, you mentioned:

We then report the average performances on the validation and test sets, by performing overall experiments 10 times with different seeds.

Does this means your reported performance is based on 10folds*10seeds, which means 100 trained models in total? Or 10folds with different seeds?

Could you please provide the code for efficiency experiment?

Hi, this is a fantastic work. I'm wondering if you can provide the code for Efficiency section in you paper, e.g., experiments on the Erdos-Renyi graphs (I've check your repo and HaarPool's, and didn't find code about efficiency part). Furthermore, could you please provide the raw data of Figire 3 and Figire 4? We want to follow your work and settings.

Best wishes!

Problem about GMPool_I

Thanks for the codes and this is a interesting work.

I have a question about the implementation about GMPool_I.

In GMPool_I, the seed matrix S \in R^{1 \times k}, where the k is the number of nodes after GMPool_G.
But, In module GMPool_I, whatever S is, the attentional matrix A is a all-1 Matrix \in R^{1 \times k} because of the col-wise softmax

tensor([[[1., 1., 1.,  ..., 1., 1., 1.]],

        [[1., 1., 1.,  ..., 1., 1., 1.]],

        [[1., 1., 1.,  ..., 1., 1., 1.]],

        ...,

        [[1., 1., 1.,  ..., 1., 1., 1.]],

        [[1., 1., 1.,  ..., 1., 1., 1.]],

        [[1., 1., 1.,  ..., 1., 1., 1.]]], device='cuda:1',
       grad_fn=<SoftmaxBackward0>)

It seems that the output of GMPool_I is equivalent to sum(WH+b) with FFN and shortcut . It looks like more reasonable to use a row-wise softmax for GMPool_I. Is there some wrong with my understanding ?

Looking forward your reply.

ask about validation dataset

Hi, I'm very interested in this method.

There is a question about code in trainers. Is the dataset for validation the same as the test dataset?

    train_idxes = torch.as_tensor(np.loadtxt('./datasets/%s/10fold_idx/train_idx-%d.txt' % (self.args.data, fold_number),
                                            dtype=np.int32), dtype=torch.long)
    val_idxes = torch.as_tensor(np.loadtxt('./datasets/%s/10fold_idx/test_idx-%d.txt' % (self.args.data, val_fold_number),
                                            dtype=np.int32), dtype=torch.long)     
    test_idxes = torch.as_tensor(np.loadtxt('./datasets/%s/10fold_idx/test_idx-%d.txt' % (self.args.data, fold_number),
                                            dtype=np.int32), dtype=torch.long)

i look forward to your reply.

install the torch_sparse

when i run the code. The torch version used is 1.4.0 the conda version is 10.1 but when I use torch_sparse version 0.5.1 the conda version is 10.0 and the torch_sparse version 0.4.4 not has SparseTensor, I want to know the right version of torch_sparse. I look forward to your early reply.
image
image

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.