what does edge_weight in GCNconv in PyTorch mean and what can I use to obtain the edge weight?

711 views Asked by At

I am working on Graph neural network using PyTorch geometric for node classification task. I would like to ask for GCNconv layer, I noticed that it supports edge_weight attribute

my questions:

  1. what does the value of edge weight means in PyTorch geometric? (do larger values mean more similar or not)?

  2. what is the data type of the edge-weight tensor?

  3. any ideas how to compute the edge weight between two nodes given the node features are the color and position?

2

There are 2 answers

1
Kadir TUTAR On

You can look at https://pytorch-geometric.readthedocs.io/en/latest/cheatsheet/gnn_cheatsheet.html

SparseTensor: If checked (✓), supports message passing based on torch_sparse.SparseTensor, e.g., GCNConv(...).forward(x, adj_t). See here for the accompanying tutorial.

edge_weight: If checked (✓), supports message passing with one-dimensional edge weight information, e.g., GraphConv(...).forward(x, edge_index, edge_weight).

edge_attr: If checked (✓), supports message passing with multi-dimensional edge feature information, e.g., GINEConv(...).forward(x, edge_index, edge_attr).

bipartite: If checked (✓), supports message passing in bipartite graphs with potentially different feature dimensionalities for source and destination nodes, e.g., SAGEConv(in_channels=(16, 32), out_channels=64).

static: If checked (✓), supports message passing in static graphs, e.g., GCNConv(...).forward(x, edge_index) with x having shape [batch_size, num_nodes, in_channels].

lazy: If checked (✓), supports lazy initialization of message passing layers, e.g., SAGEConv(in_channels=-1, out_channels=64).

0
Renyi On
  1. what does the value of edge weight means in PyTorch geometric? (do larger values mean more similar or not)?
  • You can view edge weight as a type of one-dimension edge feature. And the meaning of edge weight depends on your graph setting. So edge weight does not always mean the similarity between two nodes.
  1. what is the data type of the edge-weight tensor?
  • Normally it is torch.float, and the size is [number_of_edges, 1].
  1. any ideas how to compute the edge weight between two nodes given the node features are the color and position?
  • Given the position information, a straightforward setting lets the distance between two nodes be the edge weight. To the color information, you can define an indicator to measure the relationship between connected nodes. As edge weight can only be one-dimensional data, you can use edge_attr in pytorch geometric if you have multiple edge features.