bdy9527 / SDCN

Structural Deep Clustering Network
Apache License 2.0
259 stars 72 forks source link

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

Open cxiang97 opened 2 years ago

cxiang97 commented 2 years ago

在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的代码也是上面的公式?