MCPcopy
hub / github.com/tkipf/pygcn / normalize

Function normalize

pygcn/utils.py:56–63  ·  view source on GitHub ↗

Row-normalize sparse matrix

(mx)

Source from the content-addressed store, hash-verified

54
55
56def normalize(mx):
57 """Row-normalize sparse matrix"""
58 rowsum = np.array(mx.sum(1))
59 r_inv = np.power(rowsum, -1).flatten()
60 r_inv[np.isinf(r_inv)] = 0.
61 r_mat_inv = sp.diags(r_inv)
62 mx = r_mat_inv.dot(mx)
63 return mx
64
65
66def accuracy(output, labels):

Callers 1

load_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected