bknyaz / graph_nn

Graph Classification with Graph Convolutional Networks in PyTorch (NeurIPS 2018 Workshop)

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

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

About laplacian batch

ydu0116 opened this issue · comments

Hi, many thanks for your code! May I ask the following question regarding laplacian batch?
In github.com/tkipf/gcn, laplacian is normalized by divided by the largest eigen value:

def chebyshev_polynomials(adj, k):
"""Calculate Chebyshev polynomials up to order k. Return a list of sparse matrices (tuple representation)."""
print("Calculating Chebyshev polynomials up to order {}...".format(k))

adj_normalized = normalize_adj(adj)
laplacian = sp.eye(adj.shape[0]) - adj_normalized
largest_eigval, _ = eigsh(laplacian, 1, which='LM')
scaled_laplacian = (2. / largest_eigval[0]) * laplacian - sp.eye(adj.shape[0])

while in the code below:
L = D_hat.view(batch, N, 1) * A_hat * D_hat.view(batch, 1, N)
L is not normalized. May I ask what is the reason for not divided by the eigen value?

Many thanks in advance!

Hi, thanks for a good question. largest_eigval should have an upper bound of 2 and typically doesn't vary too much from graph to graph. I think I tried to normalize by this number for some datasets, but it didn't change results much and for large graphs computing this constant can be very slow (but this can be computed and saved before training). You can see the appendix in our paper https://arxiv.org/pdf/1811.09595.pdf with some math details.

If in your dataset all graphs have very different structure (number of nodes, connectivity patterns, etc.), I can imagine normalizing by largest_eigval can be useful.

Hi, thanks for a good question. largest_eigval should have an upper bound of 2 and typically doesn't vary too much from graph to graph. I think I tried to normalize by this number for some datasets, but it didn't change results much and for large graphs computing this constant can be very slow (but this can be computed and saved before training). You can see the appendix in our paper https://arxiv.org/pdf/1811.09595.pdf with some math details.

If in your dataset all graphs have very different structure (number of nodes, connectivity patterns, etc.), I can imagine normalizing by largest_eigval can be useful.

Hi, many thanks for your reply!