Fix data path:
p = os.path.join(os.getcwd(), '../survivalnet/data/Brain_Integ.mat')
You can use the gene data if your machine's memory allows.
X = D['Integ_X']
or
X = D['Gene_X']
fold_size = int(10 * len(X) / 100)
this means 10% of the data goes to validation and 10% to testing.
set graph construction parameters. Here 4 nearest neighbors are connected to each node based on Euclidean distance:
dist, idx = graph.distance_scipy_spatial(X_train.T, k=4, metric='euclidean')
graph coarsening level should be set to however many times you divide the data by 2 through pooling. So, one 2x2 pooling layer requires a coarsening level of 1, one 2x2 and two 4x4 pooling layers require coarsening level of 5.
graphs, perm = coarsening.coarsen(A, levels=CL, self_connections=False)
The code in this repository implements an efficient generalization of the popular Convolutional Neural Networks (CNNs) to arbitrary graphs, presented in our paper:
Michaël Defferrard, Xavier Bresson, Pierre Vandergheynst, Convolutional Neural Networks on Graphs with Fast Localized Spectral Filtering, Neural Information Processing Systems (NIPS), 2016.
The code is released under the terms of the MIT license. Please cite the above paper if you use it.
Additional material:
- NIPS2016 spotlight video
- Deep Learning on Graphs (lecture for EPFL's master course A Network Tour of Data Science)
There is also implementations of the filters used in:
- Joan Bruna, Wojciech Zaremba, Arthur Szlam, Yann LeCun, Spectral Networks and Locally Connected Networks on Graphs, International Conference on Learning Representations (ICLR), 2014.
- Mikael Henaff, Joan Bruna and Yann LeCun, Deep Convolutional Networks on Graph-Structured Data, arXiv, 2015.
-
Clone this repository.
git clone https://github.com/mdeff/cnn_graph cd cnn_graph
-
Install the dependencies. Please edit
requirements.txt
to choose the TensorFlow version (CPU / GPU, Linux / Mac) you want to install, or install it beforehand. The code was developed with TF 0.8 but people have used it with newer versions.pip install -r requirements.txt # or make install
-
Play with the Jupyter notebooks.
jupyter notebook
Run all the notebooks to reproduce the experiments on MNIST and 20NEWS presented in the paper.
cd nips2016
make
To use our graph ConvNet on your data, you need:
- a data matrix where each row is a sample and each column is a feature,
- a target vector,
- optionally, an adjacency matrix which encodes the structure as a graph.
See the usage notebook for a simple example with fabricated data. Please get in touch if you are unsure about applying the model to a different setting.