You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am quite new to this Pytorch Geometric and I am facing a lot of trouble.
1)First thing Can some one please expalin about the enzyme dataset mentioned in the documentation.
2)My second doubt is some one please explain how to understand the GNNcheatsheet mentioned. How can we say that like the particular function will supports the message passing based on the corresponding attributes?
The link for cheatsheet is: https://pytorch-geometric.readthedocs.io/en/latest/cheatsheet/gnn_cheatsheet.html.
Please clarify these two doubts.
For the first question I've the following code:
`def convert_to_networkx(graph, n_sample=None):
g = to_networkx(graph, node_attrs=["x"])
y = graph.y.numpy()
if n_sample is not None:
if n_sample >= len(g.nodes):
# If n_sample is larger or equal to the number of nodes, use all nodes
sampled_nodes = list(g.nodes)
else:
# Sample n_sample nodes from the graph
sampled_nodes = random.sample(list(g.nodes), n_sample)
g = g.subgraph(sampled_nodes)
y = y[sampled_nodes]
return g, y
from torch_geometric.datasets import TUDataset
import random
```
# Load the Enzymes dataset
dataset = TUDataset(root='/path/to/your/dataset', name='ENZYMES')
# Check the total number of graphs in the dataset
num_graphs_in_dataset = len(dataset)
# Define the number of graphs you want to visualize (e.g., 5 random graphs)
num_graphs_to_visualize = 5
# Ensure you don't sample more graphs than are available in the dataset
if num_graphs_to_visualize > num_graphs_in_dataset:
num_graphs_to_visualize = num_graphs_in_dataset
# Create a list of unique indices to select random graphs
random_graph_indices = random.sample(range(num_graphs_in_dataset), num_graphs_to_visualize)
# Iterate through the selected graphs
for i in random_graph_indices:
g, y = convert_to_networkx(dataset[i], n_sample=1000) # You can adjust n_sample as needed
plot_graph(g, y)`
But I'm getting the following error:
`Untitled-2.ipynb Cell 4 line 2
22 for i in random_graph_indices:
23 print("i=",i )
---> 24 g, y = convert_to_networkx(dataset[i], n_sample=1000) # You can adjust n_sample as needed
25 plot_graph(g, y)
Untitled-2.ipynb Cell 4 line 4
37 sampled_nodes = random.sample(list(g.nodes), n_sample)
39 g = g.subgraph(sampled_nodes)
---> 40 y = y[sampled_nodes]
42 return g, y
IndexError: index 1 is out of bounds for axis 0 with size 1`
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am quite new to this Pytorch Geometric and I am facing a lot of trouble.
1)First thing Can some one please expalin about the enzyme dataset mentioned in the documentation.
2)My second doubt is some one please explain how to understand the GNNcheatsheet mentioned. How can we say that like the particular function will supports the message passing based on the corresponding attributes?
The link for cheatsheet is:
https://pytorch-geometric.readthedocs.io/en/latest/cheatsheet/gnn_cheatsheet.html.
Please clarify these two doubts.
For the first question I've the following code:
`def convert_to_networkx(graph, n_sample=None):
def plot_graph(g, y):
`
My Main() is:
Beta Was this translation helpful? Give feedback.
All reactions