MCPcopy Create free account
hub / github.com/chengsen/PyTorch_TextGCN / normalize_adj

Function normalize_adj

utils.py:144–151  ·  view source on GitHub ↗

Symmetrically normalize adjacency matrix.

(adj)

Source from the content-addressed store, hash-verified

142
143
144def normalize_adj(adj):
145 """Symmetrically normalize adjacency matrix."""
146 adj = sp.coo_matrix(adj)
147 rowsum = np.array(adj.sum(1))
148 d_inv_sqrt = np.power(rowsum, -0.5).flatten()
149 d_inv_sqrt[np.isinf(d_inv_sqrt)] = 0.
150 d_mat_inv_sqrt = sp.diags(d_inv_sqrt)
151 return adj.dot(d_mat_inv_sqrt).transpose().dot(d_mat_inv_sqrt).tocoo()
152
153
154class EarlyStopping:

Callers 1

preprocess_adjFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected