"...git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "983dec3bf787c064ed57f2621c9b7375d443f746"
Unverified Commit 61a4e039 authored by Andrei Ivanov's avatar Andrei Ivanov Committed by GitHub
Browse files

Removing the warning in the DGL Label Propagation example. (#5993)


Co-authored-by: default avatarHongzhi (Steve), Chen <chenhongzhi.nkcs@gmail.com>
parent fddc0c48
......@@ -310,11 +310,7 @@ class CitationGraphDataset(DGLBuiltinDataset):
def _preprocess_features(features):
"""Row-normalize feature matrix and convert to tuple representation"""
rowsum = np.asarray(features.sum(1))
r_inv = np.power(rowsum, -1).flatten()
r_inv[np.isinf(r_inv)] = 0.0
r_mat_inv = sp.diags(r_inv)
features = r_mat_inv.dot(features)
features = _normalize(features)
return np.asarray(features.todense())
......@@ -929,11 +925,12 @@ class CoraBinary(DGLBuiltinDataset):
def _normalize(mx):
"""Row-normalize sparse matrix"""
rowsum = np.asarray(mx.sum(1))
mask = np.equal(rowsum, 0.0).flatten()
rowsum[mask] = np.nan
r_inv = np.power(rowsum, -1).flatten()
r_inv[np.isinf(r_inv)] = 0.0
r_inv[mask] = 0.0
r_mat_inv = sp.diags(r_inv)
mx = r_mat_inv.dot(mx)
return mx
return r_mat_inv.dot(mx)
def _encode_onehot(labels):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment