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

normalize函数中与论文中公式有出入 #25

Open
cxiang97 opened this issue Nov 16, 2021 · 0 comments
Open

normalize函数中与论文中公式有出入 #25

cxiang97 opened this issue Nov 16, 2021 · 0 comments

Comments

@cxiang97
Copy link

在utils.py中normalize(mx)中对邻接矩阵的正则化计算:

def normalize(mx):
"""Row-normalize sparse matrix"""
rowsum = np.array(mx.sum(1))
r_inv = np.power(rowsum, -1).flatten()
r_inv[np.isinf(r_inv)] = 0.
r_mat_inv = sp.diags(r_inv)
mx = r_mat_inv.dot(mx)
return mx

它的意思是将度矩阵求导D-1 *A,而您的论文中是D-1/2 * A * D-1/2 (请忽略符号上没加小帽子),即下面这个函数,它是GCN原文的对adj正则的代码

def normalize_adj(adj, self_loop=True):
"""Symmetrically normalize adjacency matrix."""
if self_loop:
adj = adj + sp.eye(adj.shape[0])
adj = sp.coo_matrix(adj)
rowsum = np.array(adj.sum(1))
d_inv_sqrt = np.power(rowsum, -0.5).flatten()
d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.
d_mat_inv_sqrt = sp.diags(d_inv_sqrt)
return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt).tocoo()

虽然我看到DAEGC的代码也是上面的公式?

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

1 participant