Open In App

What are Graph Neural Networks?

Last Updated : 02 Jul, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Graph Neural Network is a modern machine learning technique that is sued to perform various operations on graphical data. There are traditional neural networks already available for analyzing, and performing operations but they are limited to textual data only. When we need to tackle the graphical data, we use the Graph Neural Network. Graphical neural networks let you examine these connections in novel ways because graphs are strong data structures that store relationships between items. A GNN can be utilized, for instance, to identify which users are most likely to endorse something on social networking sites. This article will explore the basics of Graph Neural Networks, along with the architecture of GNN, and how they work. We will also discuss the applications of GNNs and their limitations. 

Graph-Neural-Networks

What is a Graph?

The graph is the most basic and essential part of the Graph Neural Network. In the field of computer science, Graph is a data structure that is made of two components that are vertices and edges (known as nodes). A graph is represented by A, an adjacency matrix. If a graph has n nodes, then it will have a dimension of (n × n). 

The formula for defining a graph is,

G= (V, E)

where, 

  • V = set of nodes
  • E = edged between the nodes

What-is-Graph

What is Graph Neural Network?

Graph Neural Networks were developed by Scarselli et al. in 2008. The GNN was developed to fulfill the purpose of modeling dynamic systems using graphical data. As soon as the GNN developed it attracted the eyes of researchers and it became a major area of research and applications. There is a wide range of GNN applications such as social media applications, marketing, etc. Graph Neural Networks are a methodology that is used to solve complex graph-related problems. As we know, a graph represents objects and their relationship using mathematical formulas. There are two parameters of a graph. The first is an object (node) and the second is a relationship (edges).  Let’s take an example of a social network that can be represented as a graph, where the users are the nodes, and their connections are the edges. The prime focus for developing the GNN was that it will be able to establish and learn the hidden patterns and relationships for the graphical data. Traditional neural networks are not capable of handling graph-structured data because these models suppose that the input data is of a fixed-size vector. 

What-is-Graph-Neural-Network

Types of Graph Neural Network

The GNN is classified into 3 types that are as follows:

1. Recurrent GNN

It is a type of GNN in which the connection between the various nodes generates a cyclic allowance of output from the other nodes. This affects the node of the same cycle from the output and it behaves dynamically in nature. It is based on a Banach  Fixed-Point Theorem.

2. Spatial GNN

Spatial GNN is similar to CNN. It also performs on the basis of collecting the properties of its neighboring nodes and transferring them to the central node. 

3. Spectral GNN

This GNN is based on the matric theory of mathematics. Like other GNNs uses the nodes and topology to extract the result but spectral GNN uses the eigenvalues and eigenvector concepts to get the result from the provided graphical data.

Functions of Graphical Neural Network

The various functions performed by the GNN are as follows:

1. Node classification

Noder classification is defined as the process of training a model to predict labels of nodes that are based on the features and specifications of the neighbor nodes and functions. It falls under the category of semi-supervised ML problems.

2. Link prediction

Link Prediction is defined as the process of defining the relationship between the two nodes in the graph. Also, this function helps to check whether the two nodes or entities are connected or not.

3. Graph classification

As the name suggests, it is used to classify the graph on the basis of nodes present on the different graphs. It is similar to that of node classification and link prediction. This function sorts the graphs into a similar category.

Challenges of using GNN in Machine Learning

Although GNNs are useful in solving machine learning problems, there are some challenges and limitations of GNN in ML which are as follows:

  • A GNN uses the features of neighbor nodes to predict the central node, and it continues until the node becomes stable. 
  • GNN uses a huge amount of data to learn.
  • It adjusts the parameter to minimize the loss function of the model.

Graph Convolutional Network

Graph Convolutional Networks is defined as a type of neural network that is used to solve various graph-related problems namely graph-structured data problems. The three components of the GCNs are graph convolution, linear layer, and a non-linear activation function. You can perform operations in the above-mentioned order. They together make one network layer namely network layer. We can build a graphical neural network using PyTorch.

Python3




import torch
from torch import nn
  
class graph_CN(nn.Module):
    def __init__(self, *sizes):
        super().__init__()
        self.layers = nn.ModuleList([
            nn.Linear(a, b) for a, b in zip(sizes[:-1], sizes[1:])
        ])
  
    def forward(self, vert, edg):
  
        # ----- Build the adjacency matrix -----
        adj_M = torch.eye(len(vert))
  
        # edg contain connected vert: [vertex_0, vertex_1] 
        adj_M [edg[:, 0], edg[:, 1]] = 1
        adj_M [edg[:, 1], edg[:, 0]] = 1
  
        # ----- Here forward data passes are done-----
        for layer in self.layers:
            vert= torch.sigmoid(layer(adj_M @ vert))
  
        return vert


In the above code, first, we have imported the PyTorch module. Then we created a class namely “GNN”. There are layers of GCN that are defined as linear transformations. Here, the model is taking vertices and edges as the input value. Then we get the final output which is node features after passing through different layers of the GCN. 

DeepWalk 

Deepwalk is defined as a graph neural network that is used to perform various operations on the specific structure of the target graph. Deepwalk uses a very advanced technique namely random path-traversing, that helps it to observe clearly the local structures provided in the given network. DeepWalk does this by using various random paths and after that, it trains the data using the Skip-gram model. The Skip-gram model is a machine-learning model that is capable to specify a particular node that is related to the provided input words. After recognizing the closest node related to the input, this model generates some predicted words for that specific node. This concept is used by DeepWalk.

GraphSage

A representation learning method for dynamic graphs is GraphSAGE. Without retraining, it predicts the embedding of a new node using inductive learning. It uses aggregator functions to create new node embeddings based on the node’s properties and surroundings. Instead of adding them together and losing track of them, we utilize a universal aggregation function. Prior to using mean aggregation, we totaled up the messages from the neighbors and then normalized them according to the number of neighbors. Now, we can also employ deep neural networks like LSTMs or a pooling-type technique.

Applications of GNNs

  • Graphical Neural Network is widely used in social media applications, NLP, and advertisement recommendation systems. 
  • It is also used for data analysis of social media applications where there is very large datasets. It helps the developer to find relationships between the data nodes generated by a specific user. 
  • For the use of Graph classification and Node classification.
  • It is also used to make predictions in the healthcare department.
  • GNN is used to establish the relationship between the user and products which increases the efficiency of a model.

GNN in Traffic

GNN is also used in the field of traffic by analyzing the speed of vehicles, the number of vehicles on the road, etc. We can predict the traffic strength using the GNN to solve complex traffic problems.

GNN in Computer Vision 

Graphical Neural Network is widely used in the field of computer vision. The application of GNN in computer vision is increasing day by day rapidly. The various use case of GNN in solving computer vision is image classification, object recognition, and in the field of semantic segmentation. The advantage of using the GNN in computer vision is that it is able to establish a spatial relationship between the provided objects. GNN is able to create models which can perform the execution of complex operations between the objects of the image that allows them to create more efficient ad accurate predictions regarding any object and attributes

GNN in NLP

Talking about the GNN in the field of Natural Language Processing, in recent times, the GNN is widely chosen to be applied in the NLP. This is because the GNN is highly capable of differentiating, finding, and establishing the relationship between words and phrases, which is a prime aim of NLP. The GNN treats each word as a node in the graph and establishes a relationship between these nodes to make a semantic relationship between them. That’s how the GNN works in the field of Natural Language Processing. Making the relationship between those nodes allows the network to capture patterns and relationships between words. GNN is also used to analyze the content and then make more accurate predictions. GNN is also used to make machine learning tasks such as image classification, object recognition, and entity recognition.

Conclusion

Graph Neural Network is a type of neural network that is designed to work with graph-structured data, such as social networks, biological networks, and recommendation systems by establishing a relationship between the various data nodes. A graph is defined as the abstract representation of a network that represents some relation between data, usually two different entities.  A graph is defined as G= (V, E). Here, V is used to represent the node sets (vertices) and E is used to define the edge between them. Graph Convolutional Networks are a type of neural network that is used to solve various graph-related problems namely graph-structured data problems. The various use case of GNN in Computer vision and Natural Language Processing are image classification, object recognition, and in the field of semantic segmentation.

FAQs on Graph Neural Networks

Now let us have a look over some frequently asked questions regarding the topic of Graphic Neural Networks.

Q1. What is Graph Neural Network in Machine Learning?

Answer:

Graph Neural Network in machine learning is used to perform operations on data represented by graphs. To establish relationships, analyze the data, and many more operations are performed. It helps in machine learning as well as deep learning.

Q2. How can you graph a neural network?

Answer:

Graph Neural Networks are similar to basic Neural Networks but they have some advanced options in terms of network. In it, there is a class concept that helps to do node-level, edge-level, and graph-level predictions with very less effort. 

Q3. What are the types of Neural Graph Networks?

Answer:

There are three types of Graphical Neural Networks. The first one is Recurrent Graph Neural Networks, the second is Spatial Convolutional Networks, and the last one is Spectral Convolutional Networks.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads