首页 > 解决方案 > How to create a Spektral graph with edge weights and edge features

问题描述

I want to create a Graph in Spektral which has both edged weights and edge labels. I have three matrices: a nxn adjacency matrix, an nx4 feature matrix for the nodes, and an nxnx2 matrix which represents the label for each edge. I do not know how to incorporate this third matrix into my Graph so that the edges will be labeled. I would also be happy to label the edges manually, but I don't know how to do that either. Thanks!

标签: pythontensorflowgraph

解决方案


spektral.data.Graph数据结构有一个属性调用来e存储边缘属性。因此,如果您将数据存储到 numpy 数组中,您可以执行以下操作:

g = Graph(x=x, a=a, e=e)

e你的边缘属性矩阵在哪里。

如果您使用它们,它们将被数据加载器自动拾取。

在此处查看文档。


推荐阅读