Graphs and where to find them
You’re probably already familiar with some types of graph data, such as social networks. However, graphs are an extremely powerful and general representation of data, we will show two types of data that you might not think could be modeled as graphs: images and text. Although counterintuitive, one can learn more about the symmetries and structure of images and text by viewing them as graphs,, and build an intuition that will help understand other less grid-like graph data, which we will discuss later.
Images as graphs
We typically think of images as rectangular grids with image channels, representing them as arrays (e.g., 244x244x3 floats). Another way to think of images is as graphs with regular structure, where each pixel represents a node and is connected via an edge to adjacent pixels. Each non-border pixel has exactly 8 neighbors, and the information stored at each node is a 3-dimensional vector representing the RGB value of the pixel.
Text as graphs
We can digitize text by associating indices to each character, word, or token, and representing text as a sequence of these indices. This creates a simple directed graph, where each character or index is a node and is connected via an edge to the node that follows it.
Graph-valued data in the wild
Graphs are a useful tool to describe data you might already be familiar with. Let’s move on to data which is more heterogeneously structured. In these examples, the number of neighbors to each node is variable (as opposed to the fixed neighborhood size of images and text). This data is hard to phrase in any other way besides a graph.
Graph Neural Networks
Graph Neural Networks (GNNs) are a type of neural network that operates on graph-structured data. They are designed to learn representations of nodes and edges in a graph, and can be used for a variety of tasks such as node classification, graph classification, and link prediction.
Graph Convolutions
One of the key components of GNNs is the graph convolutional layer. This layer is designed to aggregate information from neighboring nodes in a graph, and can be used to learn representations of nodes and edges that are sensitive to the graph structure.
Graph Attention Networks
Another important component of GNNs is the graph attention mechanism. This mechanism allows the model to focus on different nodes and edges in the graph, and can be used to learn representations of nodes and edges that are sensitive to the graph structure.
Generative Modelling
Besides learning predictive models on graphs, we might also care about learning a generative model for graphs. With a generative model we can generate new graphs by sampling from a learned distribution or by completing a graph given a starting point. A relevant application is in the design of new drugs, where novel molecular graphs with specific properties are desired as candidates to treat a disease.
Final Thoughts
Graphs are a powerful and rich structured data type that have strengths and challenges that are very different from those of images and text. In this article, we have outlined some of the milestones that researchers have come up with in building neural network based models that process graphs. We have walked through some of the important design choices that must be made when using these architectures, and hopefully the GNN playground can give an intuition on what the empirical results of these design choices are. The success of GNNs in recent years creates a great opportunity for a wide range of new problems, and we are excited to see what the field will bring.
Frequently Asked Questions
Q: What is a graph neural network?
A: A graph neural network is a type of neural network that operates on graph-structured data.
Q: What are some common applications of graph neural networks?
A: Some common applications of graph neural networks include node classification, graph classification, and link prediction.
Q: What is the difference between a graph convolutional layer and a graph attention mechanism?
A: A graph convolutional layer is designed to aggregate information from neighboring nodes in a graph, while a graph attention mechanism allows the model to focus on different nodes and edges in the graph.
Q: What is generative modelling on graphs?
A: Generative modelling on graphs is the process of learning a generative model for graphs, which can be used to generate new graphs by sampling from a learned distribution or by completing a graph given a starting point.
Q: What are some challenges in building graph neural networks?
A: Some challenges in building graph neural networks include handling variable-sized input graphs, dealing with non-Euclidean geometry, and designing effective graph convolutional layers and attention mechanisms.