-
Hi, I am trying to implement the concept of VGAE (variational graph autoencoder ) on a custom dataset. so, for that i have to create an adjacency matrix. The way i created my adjacency matrix is as follows. I have 9 nodes per graph, and dynamic edge_indices. since I have 9 nodes. I have created a 9*9 matrix and checked for the active edges present. dataset = []
adj = torch.zeros(9,9)
edges = edge_index[:,:int(active_edges)] # this gives the number of active edges present in that certain graph.
for i in edges.t():
adj[i[0]i[1]] = 1 # replacing the zeros with ones whereever an active edge is present.
dataset.append(Data(x =x, edge_index = edge_index[:,:int(active_edges)], adj _= adj)) # appending this inro a dataloader.
train_loader = DataLoader(train_dataset, batch_size = 32)
for data in train_loader:
x, edge_index, adj = data.x, data.edge_index, data.adj
print(x.shape) = [288,30] # because (batch_size*num_nodes, num_features)
print(edge_index.shape) = [2, 441] # because (coo format) and 441 can vary for different because it is dynamic.
print(adj.shape) = [288,9] # because again (batch_size*num_nodes, 9) so, now the problem is during training. when i predict my adjacency matrix, using VGAE my latent feature output shape is (288, 20) Now i cannot backpropogate these two calculate my loss. I dont understand if I am missing something here. Please help. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 38 replies
-
Sorry I couldn't follow your example, what do you mean
Could you provide a working code block with your issue? |
Beta Was this translation helpful? Give feedback.
-
If you want to reconstruct edges batch-wise, you will need to first convert your node feature matrix of shape recon = x @ x.transpose(1, 2) |
Beta Was this translation helpful? Give feedback.
-
states.zip Please feel free to go through the code and use the data provided, if it helps you to understand the problem batter. Thanks |
Beta Was this translation helpful? Give feedback.
If you want to reconstruct edges batch-wise, you will need to first convert your node feature matrix of shape
(288, 20)
to(batch_size, num_nodes, 20) = (32, 9, 20)
. Then, you can re-construct edges for each adjacency matrix: