I’m new to Pytorch-geometric, and geometric deep learning. I’m trying to visualize the datasets available in pytorch-geometric, but couldn’t find anything to do so.
How do I visualize these graph datasets. Is there provision to do so in pytorch-geometric? How else can we visualize this ?
from torch_geometric.datasets import KarateClub
dataset = KarateClub()
for i in dataset[0]:
print(i)
# this torch.geometric.datasets object comprises of edge(edge information for each node), x(nodes) and y(labels for each node)
edge,x,y = dataset[0]
numpyx = x[1].numpy()
numpyy = y[1].numpy()
numpyedge = edge[1].numpy()
import networkx as nx
g = nx.Graph(numpyx)
name,edgeinfo = edge
src = edgeinfo[0].numpy()
dst = edgeinfo[1].numpy()
edgelist = zip(src,dst)
for i,j in edgelist:
g.add_edge(i,j)
nx.draw_networkx(g)
Hello all! I am also new in PyG… I am trying to import the dataset using Colab but following your instructions outputs an error: module ‘community’ has no attribute ‘best_partition’. Do you know why this could be happening? Thanks for the help!!
from torch_geometric.datasets import KarateClub
dataset = KarateClub()
AttributeError: module ‘community’ has no attribute ‘best_partition’
For future issues, python-louvain already installs networkx package. Therefore, if the previous error appears uninstall both libraries and install back only python-louvain.