MITB Banner

Now You Can Build Graph Neural Networks With Spektral Based On Keras

Share

Recently, a PhD researcher, Daniele Grattarola built a framework known as Spektral for mapping relational representation learning which is built in Python and is based on the Keras API. Spektral contains a comprehensive set of tools to build graph neural networks as well as implement some of the popular layers for graph Deep Learning.

How It Works

Spektral is built with semi-supervised deep learning methods for graph data, Graph Neural Network (GNN). According to this paper, the idea of GNN is simple: to encode structural information of the graph, each node v_i can be represented by a low-dimensional state vector s_i , 1 ≤ i ≤ N. The categorisation of  deep learning methods on the graph is shown below

The core GNN modules of Spektral are mainly based on Keras and it works with all the different backends offered by Keras in order to promptly start experimenting with the Relational Representation Learning (RRL) which consists of developing models that are able to deal with graphs natively without having to deal with the distracting low-level details. The accessory modules of Spectral are built in Numpy/Scipy and for which everything should work at the speed of almost-C-like and without compatibility issues.

Data Representation

Spektral uses a matrix-based representation of manipulating graphs and feeding them to neural networks. This is one of the most commonly used approaches in the theory of GNN and it is also perfect to perform effective computations on GPU.

In this framework, some layers and functions are implemented to work on a single graph and while the others are considered as a set of graphs. The framework also distinguishes between three main modes of operations mentioned below

  • Single, where a single graph is considered with its topology and attributes
  • Batch, where a collection of graphs are considered, each with its own topology and attributes
  • Mixed, where a graph with a fixed topology is considered but a collection of different attributes. This can be considered as a particular case of the batch mode (i.e. the case where all adjacency matrices are the same) but is treated separately for computational reasons.

Installation

Spektral is developed by keeping Python in mind so Python versions 2 and 3 are recommended. Python 3 is heavily recommended and for those who are using Python 2 version are suggested to switch into Python 3 for a smooth workflow.

There are some features  of Spectral which require the following optional dependencies

  • RDKit, a library for cheminformatics and molecule manipulation (available through Anaconda);
  • Dyfunconn, a library to build functional connectivity networks (available through PyPi);
  • CDG, a library implementing several change detection algorithms, as well as an engine for Riemannian geometry (available on Github);

The framework is tested for Ubuntu 16.04 and 18.04 and should also work on other Linux distros and MacOS.

To install the required dependencies on Ubuntu, run the following code

$ sudo apt install graphviz libgraphviz-dev libcgraph6

The simplest way to install Spektral is with PyPi; just run:

$ pip install spektral

To install the framework from source, run the following code in the terminal:

$ git clone https://github.com/danielegrattarola/spektral.git

$ cd spektral

$ python setup.py install  # Or ‘pip install .’

Bottom Line

However, this project comes with a little warning for the work which is still in progress and may change before the proper release. Also, if you are interested in contributing your ideas for further development, you can easily do it just by dropping an email.

PS: The story was written using a keyboard.
Share
Picture of Ambika Choudhury

Ambika Choudhury

A Technical Journalist who loves writing about Machine Learning and Artificial Intelligence. A lover of music, writing and learning something out of the box.
Related Posts

CORPORATE TRAINING PROGRAMS ON GENERATIVE AI

Generative AI Skilling for Enterprises

Our customized corporate training program on Generative AI provides a unique opportunity to empower, retain, and advance your talent.

Upcoming Large format Conference

May 30 and 31, 2024 | 📍 Bangalore, India

Download the easiest way to
stay informed

Subscribe to The Belamy: Our Weekly Newsletter

Biggest AI stories, delivered to your inbox every week.

AI Courses & Careers

Become a Certified Generative AI Engineer

AI Forum for India

Our Discord Community for AI Ecosystem, In collaboration with NVIDIA. 

Flagship Events

Rising 2024 | DE&I in Tech Summit

April 4 and 5, 2024 | 📍 Hilton Convention Center, Manyata Tech Park, Bangalore

MachineCon GCC Summit 2024

June 28 2024 | 📍Bangalore, India

MachineCon USA 2024

26 July 2024 | 583 Park Avenue, New York

Cypher India 2024

September 25-27, 2024 | 📍Bangalore, India

Cypher USA 2024

Nov 21-22 2024 | 📍Santa Clara Convention Center, California, USA

Data Engineering Summit 2024

May 30 and 31, 2024 | 📍 Bangalore, India