-
def forward(self,x,edge_index):
z = x
if last_layer == False:
s = self.pool(x,edge_index)
x_new = s.T @ z
a_new = s.T @ edge_index @ s
return x_new,a_new I wanted to implement the DiffPool method, but I found that in torch_feometric, edge_index is a vector of size [2,num_edge], and S is a vector of size [num_node,new_num_node]. They can't multiply. What should I do? |
Beta Was this translation helpful? Give feedback.
Answered by
rusty1s
Aug 8, 2022
Replies: 1 comment 3 replies
-
from torch_sparse import SparseTensor
adj = SparseTensor.from_edge_index(edge_index)
a_new = s.T @ (adj @ s) |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
mumu029
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
edge_index
needs to be transformed first into a dense adjacency matrix viautils.to_dense_adj
. Alternatively, you can convertedge_index
into aSparseTensor
and do