MCPcopy Index your code
hub / github.com/PetarV-/GAT / sparse_to_tuple

Function sparse_to_tuple

utils/process.py:125–141  ·  view source on GitHub ↗

Convert sparse matrix to tuple representation.

(sparse_mx)

Source from the content-addressed store, hash-verified

123 return adj, features, y_train, y_val, y_test, train_mask, val_mask, test_mask
124
125def 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
143def standardize_data(f, train_mask):
144 """Standardize feature matrix and convert to tuple representation"""

Callers 2

preprocess_featuresFunction · 0.85
preprocess_adjFunction · 0.85

Calls 1

to_tupleFunction · 0.85

Tested by

no test coverage detected