Graph Neural Networks with Keras and Tensorflow 2.
Spektral is a Python library for graph deep learning, based on the Keras API and TensorFlow 2. The main goal of this project is to provide a simple but flexible framework for creating graph neural networks (GNNs).
You can use Spektral for classifying the users of a social network, predicting molecular properties, generating new graphs with GANs, clustering nodes, predicting links, and any other task where data is described by graphs.
Spektral implements some of the most popular layers for graph deep learning, including:
and many others (see convolutional layers).
You can also find pooling layers, including:
Spektral also includes lots of utilities for representing, manipulating, and transforming graphs in your graph deep learning projects.
If you want to cite Spektral in your work, refer to our paper:
Graph Neural Networks in TensorFlow and Keras with Spektral
Daniele Grattarola and Cesare Alippi
Spektral is compatible with Python 3.5+, and is tested on Ubuntu 16.04+ and MacOS. Other Linux distros should work as well, but Windows is not supported for now.
The simplest way to install Spektral is from PyPi:
pip install spektral
To install Spektral from source, run this in a terminal:
git clone https://github.com/danielegrattarola/spektral.git cd spektral python setup.py install # Or 'pip install .'
To install Spektral on Google Colab:
! pip install spektral
The 1.0 release of Spektral is an important milestone for the library and brings many new features and improvements.
If you have already used Spektral in your projects, the only major change that you need to be aware of is the new
This is a summary of the new features and changes:
Datasetcontainers standardize how Spektral handles data. This does not impact your models, but makes it easier to use your data in Spektral.
Loaderclass hides away all the complexity of creating graph batches. Whether you want to write a custom training loop or use Keras' famous model-dot-fit approach, you only need to worry about the training logic and not the data.
transformsmodule implements a wide variety of common operations on graphs, that you can now
apply()to your datasets.
GeneralGNNclasses let you build models that are, well... general. Using state-of-the-art results from recent literature means that you don't need to worry about which layers or architecture to choose. The defaults will work well everywhere.
Spektral is an open-source project available on Github, and contributions of all types are welcome. Feel free to open a pull request if you have something interesting that you want to add to the framework.