Closed pyyush closed 4 years ago
line 40 in utils.py features = coo_matrix((feature_values, (node_index, feature_index)), shape=(node_count, feature_count)).toarray()
The feature matrix (x) isn't sparse, instead, it's a dense matrix (ndarray
) due the .toarray()
method.
And the adjacency matrix (A) is represented as edge_index
and edge_weight
.
In that case, how to make a sparse adjacency matrix (A) given edge_index and edge_weight. My goal is to implement the GCNConv layer on my own by just using PyTorch.
You would like to call torch.sparse.FloatTensor(edge_index , edge_weight, shape)
, where shape
denotes the dense shape of adjacancy matrix A.
For more details, you may refer to pygcn.
line 40 in utils.py features = coo_matrix((feature_values, (node_index, feature_index)), shape=(node_count, feature_count)).toarray()