A Visual Guide to Graph Neural Network

A Visual Guide to Graph Neural Network

Everything you need to know to start working with GNN

image.png

A Graph is a non-linear data structure consisting of nodes and edges. The nodes are sometimes also referred to as vertices and the edges are lines or arcs that connect any two nodes in the graph.

image.png

Graph Neural Network

The main idea here is we encode the nodes which are elements and the edges which are the relationships among those elements. How to decides what it does? Well, that depends on your problem. It could be a social network, molecular structures or connecting roads in case of Google maps. So the first part of solving problems using GNNs' is basically designing a graph representation of your problem. Secondly you for each node you need some information to start with. This information is encoded in the distributed vector presentation or embeddings and this is encoded for each node. It could be any type of information that you want to pass.

image.png

Now given above is a general representation of a graph neural network. The output is going to be the same graph but each node would have a different vector representation. The output vector representation would contain how different nodes belong within the context of the graph. This output is then passed to the specific task you are trying to solve. Remember, the initial vector representation is created by humans using the feature engineering (old fashioned ML).

Graph neural network incorporates a technique called Neural Message Passing. This helps us understand how each node sends and receive inputs from its neighbours. Let's take a sneak peek at inside the Neural Message Passing.

image.png

So from the above diagram, you can see that the value of final node F is dependent on the value at current node state as well as information coming from neighbours( that connect) related to their current node state. How does the whole network work?

There is a clock-like one in CPU at each cycle a clock tick and when it ticks every node gets inputs to from their neighbour, computes messages and update its state. The number of time we want to call this cycle is a hybrid parameter( a design decision). There is no notion of convergence in graph neural network. All nodes in the network are updated simultaneously ( in parallel)

Below is a visual representation of how the message from one node pass-through nth node with time t.

graph.gif

You can inspect from the above diagram how neural message passing occurs. Initially, each node knows about itself then with time about its neighbours and then its neighbours' neighbour.

So in starting we had some information which we feed to GNN and after GNN processing you get to know about the node how it is positioned inside the network and its relationships with other nodes and now you can do anything with the output vector as per your need in your application.

All Graph images are created by Author.:)