<p><a href="https://arxiv.org/abs/1901.00596" rel="nofollow noreferrer">A Comprehensive Survey on Graph Neural Networks</a> (2019) presents a list of ConvGNN's. All of the following accept weighted graphs, and three accept those with edge weights as well:</p>

<p><a href="https://i.sstatic.net/d7foa.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/d7foa.png" alt="enter image description here"></a></p>

<p>And below is a series of open source implementations of many of the above:</p>

<p><a href="https://i.sstatic.net/QSxzd.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/QSxzd.png" alt="enter image description here"></a></p>

CC BY-SA 4.0
2020-04-25T20:00:30.033Z
2020-04-26T10:42:30.907Z
2020-04-26T10:42:30.907Z
brazofuerte
<p>You can use <strong><a href="https://github.com/rusty1s/pytorch_geometric" rel="nofollow noreferrer">Pytorch_Geometric</a></strong> library for your projects. Its <strong>supports weighted GCNs</strong>. It is a rapidly evolving open-source library with easy to use syntax. It is mentioned in the landing page of <a href="https://pytorch.org/" rel="nofollow noreferrer">Pytorch</a>. It is the most starred Pytorch github repo for geometric deep learning. Creating a GCN model which can process graphs with weights is as simple as:</p>



<pre><code>import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv

class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = GCNConv(dataset.num_node_features, 16)
        self.conv2 = GCNConv(16, dataset.num_classes)

    def forward(self, data):

        # data has the following 3 attributes
        x, edge_index, edge_weight = data.x, data.edge_index, data.edge_weight

        x = self.conv1(x, edge_index, edge_weight)
        x = F.relu(x)
        x = F.dropout(x, training=self.training)
        x = self.conv2(x, edge_index, edge_weight)

        return F.log_softmax(x, dim=1)
</code></pre>

<p>See <a href="https://pytorch-geometric.readthedocs.io/en/latest/notes/introduction.html" rel="nofollow noreferrer">this</a> for getting started.
Check out its <a href="https://pytorch-geometric.readthedocs.io/en/latest/modules/nn.html#module-torch_geometric.nn.conv.message_passing" rel="nofollow noreferrer">documentation</a> on different variants of GCNs for further details. One of the best thing is that like Pytorch, its documentation are self-sufficient.</p>

CC BY-SA 4.0
2021-12-16T21:21:25.223Z
Is there any reason why Pytorch Geometric wouldn't deal with negative weights in GCNConv()? When I use positive weights it works just fine. When I use negative ones it sometimes returns nans and causes problems. Any ideas why?
Michael
CC BY-SA 4.0
2020-05-20T20:54:00.833Z
2020-05-21T09:33:56.123Z
2020-05-21T09:33:56.123Z
user1825567
<p>You can use Graph Attention Networks for weighted graphs. This model can handle negative weights. Check out its <a href="https://pytorch-geometric.readthedocs.io/en/latest/modules/nn.html#module-torch_geometric.nn.conv.message_passing" rel="nofollow noreferrer">documentation.</a></p>

CC BY-SA 4.0
2022-10-21T02:38:34.037Z
While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/22800)
Rob
CC BY-SA 4.0
2022-10-20T13:27:54.590Z
2022-10-20T13:27:54.590Z
Waqar Ali
<p>Currently, I'm using a Python library, <a href="https://github.com/stellargraph/stellargraph" rel="nofollow noreferrer">StellarGraph</a>, to implement GCN. And I now have a situation where I have graphs with weighted edges. Unfortunately, StellarGraph doesn't support those graphs</p>

<p>I'm looking for an open-source implementation for graph convolution networks for <strong>weighted graphs</strong>. I've searched a lot, but mostly they assumed unweighted graphs. Is there an open-source implementation for GCNs for weighted graphs?</p>

CC BY-SA 4.0
2019-11-28T12:56:37.187Z
You can take a look at "Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting" (you can find it on Github). In there you can find an implementation of the diffusion convolution which is applied to a weighted graph, the traffic adjacency matrix.
razvanc92
<python><resource-request><geometric-deep-learning><graphs><graph-neural-networks>
Is there an open-source implementation for graph convolution networks for weighted graphs?
port trum
# Is there an open-source implementation for graph convolution networks for weighted graphs?

(Asked by: username_0 on 2019-11-27)

Currently, I'm using a Python library, [StellarGraph](https://github.com/stellargraph/stellargraph), to implement GCN. And I now have a situation where I have graphs with weighted edges. Unfortunately, StellarGraph doesn't support those graphs

I'm looking for an open-source implementation for graph convolution networks for **weighted graphs**. I've searched a lot, but mostly they assumed unweighted graphs. Is there an open-source implementation for GCNs for weighted graphs?

**Tags:** python, resource-request, geometric-deep-learning, graphs, graph-neural-networks

> **Comments:**
> **username_1**: You can take a look at "Diffusion Convolutional Recurrent Neural Network: Data-Driven Traffic Forecasting" (you can find it on Github). In there you can find an implementation of the diffusion convolution which is applied to a weighted graph, the traffic adjacency matrix.  

---

## 3 answers

### Answer by username_2 on 2020-04-25. Score: 2 | Accepted answer

[A Comprehensive Survey on Graph Neural Networks](https://arxiv.org/abs/1901.00596) (2019) presents a list of ConvGNN's. All of the following accept weighted graphs, and three accept those with edge weights as well:

[![enter image description here](https://i.sstatic.net/d7foa.png)](https://i.sstatic.net/d7foa.png)

And below is a series of open source implementations of many of the above:

[![enter image description here](https://i.sstatic.net/QSxzd.png)](https://i.sstatic.net/QSxzd.png)


---

### Answer by username_3 on 2020-05-20. Score: 4

You can use Pytorch_Geometric library for your projects. Its supports weighted GCNs. It is a rapidly evolving open-source library with easy to use syntax. It is mentioned in the landing page of Pytorch. It is the most starred Pytorch github repo for geometric deep learning. Creating a GCN model which can process graphs with weights is as simple as:
import torch
import torch.nn.functional as F
from torch_geometric.nn import GCNConv

class Net(torch.nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = GCNConv(dataset.num_node_features, 16)
        self.conv2 = GCNConv(16, dataset.num_classes)

    def forward(self, data):

        # data has the following 3 attributes
        x, edge_index, edge_weight = data.x, data.edge_index, data.edge_weight

        x = self.conv1(x, edge_index, edge_weight)
        x = F.relu(x)
        x = F.dropout(x, training=self.training)
        x = self.conv2(x, edge_index, edge_weight)

        return F.log_softmax(x, dim=1)

See this for getting started.
Check out its documentation on different variants of GCNs for further details. One of the best thing is that like Pytorch, its documentation are self-sufficient.

> **Comments:**
> **username_4**: Is there any reason why Pytorch Geometric wouldn't deal with negative weights in GCNConv()? When I use positive weights it works just fine. When I use negative ones it sometimes returns nans and causes problems. Any ideas why?  

---

### Answer by username_5 on 2022-10-20. Score: 0

You can use Graph Attention Networks for weighted graphs. This model can handle negative weights. Check out its [documentation.](https://pytorch-geometric.readthedocs.io/en/latest/modules/nn.html#module-torch_geometric.nn.conv.message_passing)

> **Comments:**
> **username_6**: While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference.  Link-only answers can become invalid if the linked page changes. - [From Review](/review/late-answers/22800)  

---

