how can I perform node classification with PyG? #3755
-
Dear PyG users, I have inputs like this:
One graph has the number of '34' node features of each node I want to classify that a node is whether 0 or 1 with different sizes of a graph. How can I classify a node in a different size graph? Best regards :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Your inputs look great. You can wrap them inside a list and pass them to data_list = [...]
loader = DataLoader(data_list, batch_size=32, shuffle=True) You can then do node classification following the PyG node-level prediction examples, e.g., here and here: for data in loader:
data = data.to(device)
optimizer.zero_grad()
pred = model(data.x, data.edge_index)
loss = F.cross_entropy(pred, data.y)
loss.backward()
optimizer.step() |
Beta Was this translation helpful? Give feedback.
Your inputs look great. You can wrap them inside a list and pass them to
torch_geometric.loader.DataLoader
to create mini-batches from it:You can then do node classification following the PyG node-level prediction examples, e.g., here and here: