Row-normalize feature matrix and convert to tuple representation
(features)
| 110 | |
| 111 | |
| 112 | def 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 | |
| 122 | def normalize_adj(adj): |
no test coverage detected