dmlc / dgl

Python package built to ease deep learning on graph, on top of existing DL frameworks.
http://dgl.ai
Apache License 2.0
13.49k stars 3.02k forks source link

Confusion about the edge indicator matrices 'pmpd' in tutorial 'Line Graph Neural Network' #310

Closed ZongweiZhou1 closed 5 years ago

ZongweiZhou1 commented 5 years ago

❓ Questions and Help

Hey, This is a beautiful job and helps me a lot.

However, some questions catch me when I come into the toturial Line Graph Neural Network . I find the edge indicator matrices 'pmpd' refered in origin paper are loaded from '.pkl' file and I cannot refer how the matrices are calculated.

In the origin paper, $Pm{i, i\rightarrow j} = Pm{j, i\rightarrow i} =1, Pd{i, i\rightarrow j}=1, Pd{j, i\rightarrow j}=-1$, but the .pkl file is not consistent with the definition. Then I read the code in linegraph.

Something are still weird, the pmpd_x just considering the start point of each edge which means only a $1$ in each column of matrix pmpd, and pmpd_y is the sum of the features of all connected nodes which means there are no $-1$ in the matrix pmpd

I am confused now, if you can give me a clear explanation on how to get the matrix pmpd I'll very appreciate.

GaiYu0 commented 5 years ago

Hey,

Thanks for posting this question! Actually we are no less confused than you are.

In the paper, both Pm and Pd are $|V| \times 2 |E|$ matrices. Given Eq. (2), {Pm, Pd} (pmpd) has to be a $|V| \times 2 |E|$ matrix as well. How to get a $|V| \times 2 |E|$ matrix from two $|V| \times 2 |E|$ matrices? We emailed the corresponding author but have not heard from him yet. In our implementation, we simply let {Pm, Pd} = Pm + Pd. As you see, the result is that $1$'s and $-1$'s in Pm and Pd cancel each other and only $1$'s that mark the start point of edges remain. More precisely, ${Pm, Pd}{i, i \rightarrow j} = 2$ due to the adding of $1$'s. Because $2$ is a constant that can be "absorbed" by the subsequent affine layer, we simply let ${Pm, Pd}{i, i \rightarrow j} = 1$.

jermainewang commented 5 years ago

Hi @ZongweiZhou1 , for general questions, please use our discussion forum. This issue will be closed and feel free to raise the question again in the forum.