简体   繁体   English

有没有办法让 GraphSAGE 考虑加权边

[英]Is there a way to allow GraphSAGE take into account weighted edges

Currently, I am using a great python library, StellarGraph, to implement GraphSAGE (graph neural network) and for most uses, the library works very well.目前,我正在使用一个很棒的 Python 库 StellarGraph 来实现 GraphSAGE(图神经网络),并且对于大多数用途,该库运行良好。

I now have a situation where I have graphs with weighted edges - the weights reflect the relative importance of some relationships compared to others.我现在有一种情况,我有带加权边的图 - 权重反映了某些关系与其他关系相比的相对重要性。 In other words, some links between nodes have lower weights (low importance) and others have higher weights (high importance).换句话说,节点之间的某些链接具有较低的权重(低重要性),而另一些具有较高的权重(高重要性)。

It would be very useful for clustering and perhaps even node classification in situations where weights are taken into account during graph network training.在图网络训练期间考虑权重的情况下,这对于聚类甚至节点分类非常有用。

Is there a way to have GraphSAGE / python StellarGraph take weighted edges into account?有没有办法让 GraphSAGE / python StellarGraph 考虑加权边?

This is now supported in StellarGraph in version 1.2.0 , via the weighted=True parameter to the data generators.现在通过数据生成器的weighted=True参数在 StellarGraph版本 1.2.0 中支持这一点。

For example, for GraphSAGE's GraphSAGENodeGenerator :例如,对于GraphSAGE 的GraphSAGENodeGenerator

G_generator = GraphSAGENodeGenerator(G, 50, [10,10], weighted=True)

For the details of what this means (quoting the pull request #1667 that fixed the relevant issue #462 ):有关这意味着什么的详细信息(引用修复相关问题 #462拉取请求 #1667 ):

This expands GraphSAGE (undirected and directed) to support weighted sampling, where edges with higher weights are taken proportionally more often.这扩展了 GraphSAGE(无向和有向)以支持加权采样,其中权重较高的边被更频繁地按比例获取。

For example, suppose there's there's 4 edges from node A:例如,假设有来自节点 A 的 4 条边:

A -0- B, A -1- C, A -2- D, A -3- D

An unweighed walk starting at A will choose each of the edges with equal propability and so end up on B, C or D in proportion 1:1:2 (edge counts).从 A 开始的未称重的步行将选择具有相等概率的每条边,因此以 1:1:2 的比例(边数)在 B、C 或 D 上结束。 A weighted walk will choose the edges proportional to the weights, so end up on the vertices in proportion 0:1:5 (sum of edge weight).加权行走将选择与权重成比例的边,因此最终以 0:1:5 的比例(边权重之和)在顶点上。 (Worth specifically highlighting: a weighted walk will never chose the AB edge because it has weight 0.) (值得特别强调:加权行走永远不会选择 AB 边,因为它的权重为 0。)

The full set of algorithms that support edge weights is marked via the "Edge weights" column in the table of demos in the documentation .支持边缘权重的全套算法通过文档中演示表中的“边缘权重”列进行标记。

Did you find a workaround or solution to this? 您是否找到了解决方法或解决方案? I had the same question as well. 我也有同样的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM