MCPcopy
hub / github.com/tkipf/gcn / preprocess_features

Function preprocess_features

gcn/utils.py:112–119  ·  view source on GitHub ↗

Row-normalize feature matrix and convert to tuple representation

(features)

Source from the content-addressed store, hash-verified

110
111
112def preprocess_features(features):
113 """Row-normalize feature matrix and convert to tuple representation"""
114 rowsum = np.array(features.sum(1))
115 r_inv = np.power(rowsum, -1).flatten()
116 r_inv[np.isinf(r_inv)] = 0.
117 r_mat_inv = sp.diags(r_inv)
118 features = r_mat_inv.dot(features)
119 return sparse_to_tuple(features)
120
121
122def normalize_adj(adj):

Callers 1

train.pyFile · 0.85

Calls 1

sparse_to_tupleFunction · 0.85

Tested by

no test coverage detected