Open WangYibucea opened 3 years ago
from torch_sparse import SparseTensor
SparseTensor(row=edge_index[0], col=edge_index[1], value=edge_weight, sparse_sizes=(num_nodes, num_nodes))
Thank you for your reply, but I would like to convert SparseTensor to the normal format of tensor and use it in other networks. How should I do this please?
Do you mean converting to dense tensors/scipy matrices/networkx graphs?
adj = SparseTensor(row=edge_index[0], col=edge_index[1], value=edge_weight, sparse_sizes=(num_nodes, num_nodes))
dense_adj = adj.to_dense()
torch_sparse_coo_adj = adj.to_torch_sparse_coo_tensor()
scipy_adj = adj.to_scipy()
For converting to networkx, I suggest to make use of `torch_geometric.utils.to_networkx
G = to_networkx(Data(edge_index=edge_index, edge_weight=edge_weight), edge_attrs=['edge_weight'])
So far I've got
edge_index
,edge_weight
, How do I go about converting these two vectors into theadj
. It has the dimensions (number of nodes, number of nodes).