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

Function sparse_to_tuple

gcn/utils.py:93–109  ·  view source on GitHub ↗

Convert sparse matrix to tuple representation.

(sparse_mx)

Source from the content-addressed store, hash-verified

91
92
93def sparse_to_tuple(sparse_mx):
94 """Convert sparse matrix to tuple representation."""
95 def to_tuple(mx):
96 if not sp.isspmatrix_coo(mx):
97 mx = mx.tocoo()
98 coords = np.vstack((mx.row, mx.col)).transpose()
99 values = mx.data
100 shape = mx.shape
101 return coords, values, shape
102
103 if isinstance(sparse_mx, list):
104 for i in range(len(sparse_mx)):
105 sparse_mx[i] = to_tuple(sparse_mx[i])
106 else:
107 sparse_mx = to_tuple(sparse_mx)
108
109 return sparse_mx
110
111
112def preprocess_features(features):

Callers 3

preprocess_featuresFunction · 0.85
preprocess_adjFunction · 0.85
chebyshev_polynomialsFunction · 0.85

Calls 1

to_tupleFunction · 0.85

Tested by

no test coverage detected