Convert sparse matrix to tuple representation.
(sparse_mx)
| 123 | return adj, features, y_train, y_val, y_test, train_mask, val_mask, test_mask |
| 124 | |
| 125 | def sparse_to_tuple(sparse_mx): |
| 126 | """Convert sparse matrix to tuple representation.""" |
| 127 | def to_tuple(mx): |
| 128 | if not sp.isspmatrix_coo(mx): |
| 129 | mx = mx.tocoo() |
| 130 | coords = np.vstack((mx.row, mx.col)).transpose() |
| 131 | values = mx.data |
| 132 | shape = mx.shape |
| 133 | return coords, values, shape |
| 134 | |
| 135 | if isinstance(sparse_mx, list): |
| 136 | for i in range(len(sparse_mx)): |
| 137 | sparse_mx[i] = to_tuple(sparse_mx[i]) |
| 138 | else: |
| 139 | sparse_mx = to_tuple(sparse_mx) |
| 140 | |
| 141 | return sparse_mx |
| 142 | |
| 143 | def standardize_data(f, train_mask): |
| 144 | """Standardize feature matrix and convert to tuple representation""" |
no test coverage detected