Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

作者您好,向您请教一下discrete_graph_learning.py中实现Equation(2)的细节 #56

Open
ghost opened this issue Nov 9, 2023 · 0 comments

Comments

@ghost
Copy link

ghost commented Nov 9, 2023

作者您好,作为GNN的初学者对discrete_graph_learning.py代码中Equation(2)实现的这部分还存在一些疑惑:
self.rel_rec = torch.FloatTensor(np.array(encode_one_hot(np.where(np.ones((self.num_nodes, self.num_nodes)))[0]), dtype=np.float32))
self.rel_send = torch.FloatTensor(np.array(encode_one_hot(np.where(np.ones((self.num_nodes, self.num_nodes)))[1]), dtype=np.float32))
这里我理解的作用是将每个node看作reciever和sender的角色,然后将节点之间的关系表示为one-hot向量矩阵,但我好奇这个为什么能这么表示呢?譬如self.num_nodes为3的时候这两个属性分别为tensor([[1., 0., 0.], [1., 0., 0.], [1., 0., 0.], [0., 1., 0.], [0., 1., 0.], [0., 1., 0.], [0., 0., 1.], [0., 0., 1.], [0., 0., 1.]])tensor([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.], [1., 0., 0.], [0., 1., 0.], [0., 0., 1.], [1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]),这两个属性的值怎么就能表示节点之间的关系了呢?
以及在下方有将这两个属性与node feature相乘,分别得到receiver和sender的特征表示:
receivers = torch.matmul(self.rel_rec.to(node_feat.device), node_feat)
senders = torch.matmul(self.rel_send.to(node_feat.device), node_feat)
为什么这两个矩阵相乘就能作为receiver和sender的特征表示呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants