Edge-GNN
Edge-GNN (Edge Graph Neural Network) is a neural network architecture that focuses on edges in a graph structure and aims to utilise edge features and weights to process edge-level and graph-wide tasks.
Edge-GNNs differ from regular GNNs in that they focus primarily on edges rather than nodes (vertices). As information about the connections between nodes (edges) is important for many graph analysis tasks (e.g. relation prediction and link prediction), Edge-GNNs have the following properties
- Learning edge representations: assigning an embedding (feature vector) to each edge, updating it and utilising the attributes associated with the edge (e.g. weight, type, direction).
- Node-edge interaction: builds a bi-directional learning process that propagates node information to the edges and returns edge information back to the nodes.
- Applicable to edge-centric tasks: suitable for tasks where edges are of primary interest, such as link prediction, edge classification and relational reasoning.
- Applicable to dynamic graphs: can be extended to handle the appearance and disappearance of edges and changes in their attributes.
The mathematical background of Edge-GNNs is that, whereas in normal GNNs, information is aggregated from neighbouring nodes when updating a node’s features, Edge-GNNs include the following processes
- Edge feature initialisation: assign a feature vector \( \mathbf{h}_{i,j} \) to each edge \( e_{i,j} \). For example, use the edge weights and types as initial values.
- Edge update: update the edge features using the node features \( \mathbf{h}_i, \mathbf{h}_j \) and edge features \( \mathbf{h}_{i,j} \).
Example of an update expression:.
\[
\mathbf{h}_{i,j}^{(t+1)} = \mathrm{MLP}([\mathbf{h}_i^{(t)}; \mathbf{h}_j^{(t)}; \mathbf{h}_{i,j}^{(t)}]),
\]
Where \( [\cdot; \cdot] \) represents a vector join.
- Reflection on node features: edge features are aggregated and node features are updated.
\[
\mathbf{h}_i^{(t+1)} = \mathrm{Aggregate}(\{ \mathbf{h}_{i,j}^{(t+1)} | j \in \mathcal{N}(i) \}),
\]
Where \(\mathcal{N}(i)\) denotes the set of neighbour nodes of node \(i\).
Implementation example
The following is an example implementation of an Edge-GNN (Edge Graph Neural Network). The code uses PyTorch Geometric to create a simple model that updates edge features and ultimately predicts node features.
Edge-GNN implementation example: first, import the necessary libraries; PyTorch Geometric is a library that supports deep learning based on graph structures, making it easy to build GNNs.
pip install torch torch-geometric
The next step is to implement the Edge-GNN model.
import torch
import torch.nn.functional as F
from torch_geometric.nn import MessagePassing
from torch_geometric.utils import add_self_loops
from torch_geometric.data import Data
class EdgeGNN(MessagePassing):
def __init__(self, node_in_channels, edge_in_channels, out_channels):
super().__init__(aggr='add') # ‘add’ Aggregation method.
self.node_mlp = torch.nn.Linear(node_in_channels, out_channels)
self.edge_mlp = torch.nn.Linear(edge_in_channels + 2 * out_channels, out_channels)
def forward(self, x, edge_index, edge_attr):
edge_index, edge_attr = add_self_loops(edge_index, edge_attr=edge_attr, fill_value=0)
x = self.node_mlp(x)
return self.propagate(edge_index, x=x, edge_attr=edge_attr)
def message(self, x_i, x_j, edge_attr):
# Integration of edge features and neighbouring node features.
return F.relu(self.edge_mlp(torch.cat([x_i, x_j, edge_attr], dim=1)))
# Create node features, edge features and edge indices
node_features = torch.randn((10, 16)) # 10 nodes, 16 dimensional features
edge_features = torch.randn((20, 8)) # 20 edges, 8 dimensional features
edge_indices = torch.tensor([[0, 1], [1, 2], [2, 3], [3, 4], [4, 5], [5, 6], [6, 7], [7, 8], [8, 9],
[0, 2], [1, 3], [2, 4], [3, 5], [4, 6], [5, 7], [6, 8], [7, 9],
[0, 3], [1, 4], [2, 5], [3, 6]]).t() # Define connections between nodes
# Create data objects.
data = Data(x=node_features, edge_index=edge_indices, edge_attr=edge_features)
# Define the Edge-GNN model.
model = EdgeGNN(node_in_channels=16, edge_in_channels=8, out_channels=32)
# Running the model.
output = model(data.x, data.edge_index, data.edge_attr)
print(output)
Description.
- The EdgeGNN class:
- Inherits from the MessagePassing class and aggregates edge features and node features.
- node_mlp and edge_mlp are MLPs (multi-layer perceptrons) for transforming node features and edge features respectively.
- The message method combines neighbouring node features and edge features and updates edge features.
- Data preparation:
- node_features: node features (10 nodes, each with 16 dimensional features).
- edge_features: edge features (20 edges, each with 8 dimensional features).
- edge_indices: indices defining the connection relations of the edges (10 nodes and 20 edges in this example).
- propagate:
- With the propagate method, each node aggregates information using neighbouring nodes and edge features.
- Finally, a node feature (output) is obtained.
Output example: running this code yields the output after updating the node features. The dimension of the node feature is set to 32 and the updated feature is displayed.
tensor([[-0.3127, -0.4059, 0.2311, 0.3193, 0.4611, 0.1869, -0.1323, 0.5429, 0.1933, -0.5683, 0.2113, 0.5110, 0.4362, -0.2854, -0.1163, 0.1420, -0.2427, 0.4707, 0.3515, -0.0876, -0.0835, 0.0195, 0.0495, 0.2829, 0.3779, -0.1769, 0.0364, 0.1217, -0.1381, 0.0966, -0.4157, 0.1954, 0.3080, -0.2988],
[ 0.0693, 0.3212, -0.3046, 0.2517, 0.4044, -0.0460, -0.3282, -0.1061, -0.0783, -0.4631, -0.2930, 0.1105, -0.3678, 0.3190, 0.0183, 0.1830, -0.1207, -0.4530, 0.2532, -0.3724, 0.3833, -0.2162, -0.3211, -0.1303, 0.1730, -0.2091, 0.0741, 0.2107, 0.0541, 0.3855, -0.0999, 0.1079, 0.2380]])
The output is the feature vector of the updated node. The features of each node are updated based on the features of neighbouring nodes and edges.
Application examples
Specific applications of Edge-GNN (Edge Graph Neural Network) are mainly related to tasks that use edge information to learn the structure of a graph and the relationships between nodes. They are described below.
1. link prediction in knowledge graphs
- Problem: In knowledge graphs (e.g. DBpedia, Freebase, etc.), nodes represent entities (people, places, events, etc.) and edges represent relationships between those entities. Link prediction is the task of predicting unknown edges (relations).
- Role of Edge-GNNs: Edge-GNNs capture relationships between nodes as edge features and dynamically update edges to help predict relationships. For example, it predicts new links in the knowledge graph by learning edges such as ‘person and country’.
- APPLICATION: The co-operation between companies and product interrelationships are represented in the knowledge graph and these relationships are predicted using Edge-GNNs. This enables the prediction of future co-operation and the recommendation of relevant products.
2. user relationship prediction in social networks
- Problem: In social media platforms, it is important to predict relationships between users (e.g. friends, follows, comments, etc.). This prediction can improve recommendation systems and ad targeting.
- Role of Edge-GNN: Edge-GNN predicts future relationships by dynamically updating the features of edges (relationships between users) and fusing them with the features of nodes (users). For example, it can learn users’ behaviour patterns and interests and recommend highly relevant users.
- Application example: a social network platform uses Edge-GNN to predict new friend and follower relationships between users. This enables them to recommend new potential friends to users and optimise the targeting of advertisements.
3. flow forecasting in traffic networks
- PROBLEM: Predicting traffic volumes and congestion between roads is of great importance in transport systems. This can reduce traffic congestion and optimise navigation based on congestion forecasts.
- Role of Edge-GNNs: Edge-GNNs capture edge information between roads (e.g. road type, traffic volume, speed, etc.) as features and use this edge information to predict traffic flows.
- APPLICATION: Edge-GNN is used in urban traffic networks to predict traffic volumes on specific road sections. Based on traffic volume forecasts, a system can be created to suggest route changes to reduce traffic congestion.
4. chemical reaction prediction
- PROBLEM: Predicting reactions of chemical molecules plays an important role in the discovery of new drugs and the design of materials. As chemical reactions occur through edges (bonds) between molecules, learning edge information can be useful.
- Role of Edge-GNNs: Edge-GNNs combine features of edges (chemical bonds) and nodes (atoms) within chemical molecules to predict chemical reactions. This enables the prediction of highly reactive bonds and unknown chemical reactions.
- APPLICATION: In the discovery of new drugs, Edge-GNN is used to predict reactions between chemical molecules. This will enable reactions between existing drugs and new compounds to be simulated and promising drug candidates to be identified.
5. failure prediction in manufacturing
- Problem: In manufacturing, it is important to predict machine and equipment failures and optimise the timing of maintenance. Predictions can be made based on the relationships between equipment and the operating history.
- Role of Edge-GNN: Edge-GNN captures edges between equipment (e.g. interactions between machines operating on the same line) and equipment conditions (temperature, pressure, etc.) as edge features and uses this information to predict failures.
- Application example: in a production line, Edge-GNN is used to predict machine and equipment failures. For example, by capturing signs that a particular piece of equipment is about to fail, preventive maintenance can be carried out and production efficiency can be improved.
reference book
Reference books related to Edge-GNN (Edge Graph Neural Network) are described.
1. ‘Graph Representation Learning’ by William L. Hamilton
– Overview: This book provides a broad overview of graph neural networks, from basic concepts to applications. It is particularly useful for learning the theoretical background on graph representation learning and for understanding graph neural networks, which form the basis of Edge-GNNs.
2. ‘Deep Learning on Graphs’ by Yao Ma, Jure Leskovec
– Overview: This book provides a comprehensive overview of deep learning techniques on graph data, touching on techniques related to Edge-GNNs, the development of graph neural networks and their applications.
3. ‘Graph Neural Networks: A Review of Methods and Applications’ by Zhou, J., et al.
– Overview: Covers a wide range of graph neural networks, from theoretical foundations to application examples, and is particularly useful for understanding models that utilise edge information; provides theoretical underpinnings for specific approaches using Edge-GNNs; provides a review of the development of graph neural networks and their applications;
5. ‘Graph-Based Deep Learning’ by Jure Leskovec, R. K. Gupta.
– Overview: a book dedicated to graph-based deep learning, providing a practical guide on how to utilise node and edge information in graphs; application examples, including Edge-GNNs, are also mentioned; the book provides a practical overview of the techniques used in graph-based deep learning and how they can be used to improve the performance of graphs
6. ‘Practical Graph Mining with R’ by Nagiza F. Samatova.
– Overview: the book focuses on a practical approach to machine learning with graph data, with specific reference to how to utilise graph edge information.
7. ‘Graph Neural Networks in Action’ by Guodong Long, Chao Zhang, & Jiawei Han
– Overview: This book is designed to teach practical approaches to graph neural networks, including specific implementations for edge-informed architectures such as Edge-GNNs.
8. ‘Graph Neural Networks: Foundations, Frontiers, and Applications’.
– Author(s): Lingfei Wu, Peng Cui, et al.
– Overview: Covers a wide range of GNNs, from foundations to applications, and mentions edge-centric models.
9. ‘Graph Neural Networks for Natural Language Processing’.
– Author(s): Zhiyuan Liu, et al.
– Overview: Details the role of edges and their use in NLP.
コメント