Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the function of tensor "denom" ? #38

Closed
qwe1997 opened this issue Apr 18, 2022 · 3 comments
Closed

What is the function of tensor "denom" ? #38

qwe1997 opened this issue Apr 18, 2022 · 3 comments

Comments

@qwe1997
Copy link

qwe1997 commented Apr 18, 2022

In the Class of GraphConvLayer and MultiGraphConvLayer, there is a tensor called denom. I have tried to understand its meaning,however I failed.So please tell me this tensor's meaning.thanks!

` def forward(self, adj, gcn_inputs):
# gcn layer
denom = adj.sum(2).unsqueeze(2) + 1
outputs = gcn_inputs
cache_list = [outputs]
output_list = []

    for l in range(self.layers):  # 0, 1
        Ax = adj.bmm(outputs)
        AxW = self.weight_list[l](Ax)
        AxW = AxW + self.weight_list[l](outputs)  # self loop
        AxW = AxW / denom 
        gAxW = F.relu(AxW)
        cache_list.append(gAxW)
        outputs = torch.cat(cache_list, dim=2) 
        output_list.append(self.gcn_drop(gAxW))`
@Cartus
Copy link
Owner

Cartus commented Apr 21, 2022

As I remember, denom is the diagonal node degree matrix used in GCN, please refer to the original GCN paper:
https://arxiv.org/pdf/1609.02907.pdf

@qwe1997
Copy link
Author

qwe1997 commented Apr 22, 2022

Thank you very much! "denom" is the diagonal node degree matrix, "adj.sum(2)" means getting graph nodes degrees and unsqueeze(2) means generating two dimensional matrix for graph convolution calculation and +1 means adding self-loop nodes degrees!

@Cartus
Copy link
Owner

Cartus commented Apr 22, 2022

Exactly! I am closing this issue, if you have further questions, feel free to re-open it.

@Cartus Cartus closed this as completed Apr 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants