GithubHelp home page GithubHelp logo

filippomb / spectral-clustering-with-graph-neural-networks-for-graph-pooling Goto Github PK

View Code? Open in Web Editor NEW
258.0 11.0 48.0 3 MB

Experimental results obtained with the MinCutPool layer as presented in the 2020 ICML paper "Spectral Clustering with Graph Neural Networks for Graph Pooling"

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

License: MIT License

Python 100.00%
graph-neural-networks graph-pooling spectral-clustering unsupervised-learning

spectral-clustering-with-graph-neural-networks-for-graph-pooling's Introduction

Spectral Clustering with Graph Neural Networks for Graph Pooling

This code reproduces the experimental results obtained with the MinCutPool layer as presented in the ICML 2020 paper

Spectral Clustering with Graph Neural Networks for Graph Pooling
F. M. Bianchi*, D. Grattarola*, C. Alippi

The official Tensorflow implementation of the MinCutPool layer is in Spektral.

The PyTorch implementation of MinCutPool is in Pytorch Geometric.

Setup

The code is based on Python 3.5, TensorFlow 1.15, and Spektral 0.1.2. All required libraries are listed in requirements.txt and can be installed with

pip install -r requirements.txt

Image segmentation

Run Segmentation.py to perform hyper-segmentation, generate a Region Adjacency Graph from the resulting segments, and then cluster the nodes of the RAG graph with the MinCutPool layer.

Clustering

Run Clustering.py to cluster the nodes of a citation network. The datasets cora, citeseer, and pubmed can be selected. Results are provided in terms of homogeneity score, completeness score, and normalized mutual information (v-score).

Pytorch

Clustering_pytorch.py contains a basic implementation in Pytorch based on Pytorch Geometric.

Autoencoder

Run Autoencoder.py to train an autoencoder with bottleneck and compute the reconstructed graph. It is possible to switch between the ring and grid graphs, but also any other point clouds from the PyGSP library are supported. Results are provided in terms of the Mean Squared Error.

Graph Classification

Run Graph_Classification.py to train a graph classifier. Additional classification datasets are available here (drop them in data/classification/) and here (drop them in data/). Results are provided in terms of classification accuracy averaged over 10 runs.

Pytorch

A basic Pytorch implementation of the graph classification task can be found in this example from Pytorch Geometric.

Citation

Please, cite the original paper if you are using MinCutPool in your research

@inproceedings{bianchi2020mincutpool,
    title={Spectral Clustering with Graph Neural Networks for Graph Pooling},
    author={Bianchi, Filippo Maria and Grattarola, Daniele and Alippi, Cesare},
    booktitle={Proceedings of the 37th international conference on Machine learning},
    pages={2729-2738},
    year={2020},
    organization={ACM}
}

License

The code is released under the MIT License. See the attached LICENSE file.

spectral-clustering-with-graph-neural-networks-for-graph-pooling's People

Contributors

danielegrattarola avatar dependabot[bot] avatar filippomb 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  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

spectral-clustering-with-graph-neural-networks-for-graph-pooling's Issues

BUG when run Graph_Classification.py

I do not modify the code in Graph_Classification.py. When I run Graph_Classification.py, bug is as follow:

Traceback (most recent call last):
  File "D:\Program Files\JetBrains\PyCharm 2019.3.3\plugins\python\helpers\pydev\pydevd.py", line 1448, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\Program Files\JetBrains\PyCharm 2019.3.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/YZY1037/Desktop/Spectral-Clustering-with-Graph-Neural-Networks-for-Graph-Pooling-master/Graph_Classification.py", line 105, in <module>
    A, X, y = get_graph_kernel_dataset(P['dataset_ID'], feat_norm='ohe')
  File "C:\Users\YZY1037\Desktop\Spectral-Clustering-with-Graph-Neural-Networks-for-Graph-Pooling-master\utils\dataset_loader.py", line 90, in get_graph_kernel_dataset
    nx_graphs, y = read_graphs_txt(dataset_ID)
  File "C:\Users\YZY1037\Desktop\Spectral-Clustering-with-Graph-Neural-Networks-for-Graph-Pooling-master\utils\dataset_loader.py", line 67, in read_graphs_txt
    g.node[n]['label'] = node_labels[i]
AttributeError: 'Graph' object has no attribute 'node'

I want to know why and how to solve it. Thanks.

About clustering

Thanks for your great job, how could i use clustering,py on my data?

Results about graph signal reconstruction

Dear authors,

Thank you so much for making this work public!

I've been trying to reproduce the graph signal reconstruction results from your paper using the same ring and grid dataset you generated. For the graph u-net, using the built-in model in pyg (torch_geometric.nn.GraphUNet), I was getting results that look better than what you reported in the paper. The code and the result I obtained can be found here (https://drive.google.com/drive/folders/1WXe18TUM0J9dPQOHP8PVkWFcrF41sisV?usp=sharing)

If you do not have time to check the code, would you mind sharing the code you used to reconstruct graph signals for topKPooling? I can cross-check if I messed up with something.

Thank you so much for your attention.

Best regards,
Fuli

missing definition of \widetilde{D} in Equation (6)

Hi, @FilippoMB @danielegrattarola , I have several questions w.r.t Equation (6).

  1. what's the definition of image? if it is normalized in the same way as the adjacency matrix, it is thus an Identity matrix, isn't it?
  2. in Equation (3), you use the adjacency matrix, but in Equation (6), you use the normalized adjacency matrix, why?

Thank you very much in advance.

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.