Skip to main content

A Python framework for relational representation learning

Project description

Spektral logo

WARNING
Spektral is still a work in progress and may change substantially before the first proper release. The API is not mature enough to be considered stable, but we'll try to keep breaking changes to a minimum. Drop me an email if you want to help out with the development.

Welcome to Spektral

Spektral is a framework for relational representation learning, built in Python and based on the Keras API. The main purpose of this project is to provide a simple, fast, and scalable environment for fast experimentation.

Spektral contains a wide set of tools to build graph neural networks, and implements some of the most popular layers for graph deep learning so that you only need to worry about creating your models.

Spektral is an open source project available on Github.
Read the documentation on the official website.

Relational Representation Learning

An important trait of human intelligence is the ability to model the world in terms of entities and relations, exploiting the knowledge that entities are connected (called the relational inductive bias) in order to make informed decisions.
This relational representation of the world allows us to model a great deal of phenomena using graphs, from social networks to sentences, from the interactions of bodies in a gravitational field to the bonds between atoms in a molecule.

Given their flexibility for representing knowledge in a structured way, graphs have been historically ubiquitous in computer science, and early efforts in artificial intelligence relied heavily on relational representations (e.g., Monte Carlo methods, Bayesian networks, etc.).
Modern machine learning approaches, on the other hand, seemed to have diverted from such hand-engineered representations in favour of learning from raw data, with deep learning methods leading the way on the quasi-totality of learning tasks.
However, by placing artificial intelligence in the framework of relational inductive bias, as proposed by Battaglia et al., we see that even the most modern deep learning methods are designed to exploit the relational inductive biases of particular types of data. For instance, convolutional neural networks are based on exploiting the relation of locality in grid-structured data, and recurrent neural networks are designed to exploit the sequentiality of time series (i.e., chains of time steps).

Adding to this, in recent years graph neural networks (GNNs) have been proposed, in several formulations, as a general framework for exploiting arbitrary relational inductive biases on arbitrarily defined entities and relations, giving rise to the field of relational representation learning (RRL).
In other words, RRL consists of developing models that are able to deal with graphs natively, taking their topology and attributes into account when making a prediction, exactly like we do when we reason about the universe.

To read more about RRL and recent developments in the literature, an excellent starting point is this paper by DeepMind.

Why Keras?

The core GNN modules of Spektral are based on Keras, rather than libraries like TensorFlow or PyTorch.
Because it's built as a Keras extension, Spektral works with all the different backends offered by Keras, so that you can quickly start experimenting with RRL without having to deal with the distracting low-level details.
This also means that Spektral inherits all the core design principles of Keras, and that it can be seamlessly integrated in your Keras or TensorFlow projects.

While Keras has a slightly higher computational overhead with respect to the "pure" deep learning frameworks, the speed of implementation of Keras's models largely makes up for the disadvantage. At the same time, Keras offers the same granular control as the other frameworks via direct access to the backend (from keras import backend as K), and native functions from the backend frameworks can directly be used at any point in a Keras model.

Spektral's accessory modules are built in Numpy/Scipy, so everything should work at almost-C-like speed and without compatibility issues.

Installation

Spektral is developed with Python 3 in mind, although some modules may work as expected also in Python 2. However, you should consider switching to Python 3 if you haven't already.

The framework is tested for Ubuntu 16.04 and 18.04, but is should also work on other Linux distros and MacOS. Core functionalities should work on Windows, as well, although it is not fully supported for now.

To install the required dependencies on Ubuntu run:

$ sudo apt install graphviz libgraphviz-dev libcgraph6

Some features of Spektral also 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 simplest way to install Spektral is with 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 .'

Note that the setup.py script will not attempt to install a backend for Keras, in order to not mess up any previous installation. It will, however, install Keras and its dependencies via PyPi (which may include the CPU version of TensorFlow).
If you are already a Keras user, this should not impact you. If you're just getting started, then you may want to install the GPU version of Tensorflow before installing Spektral.

Also note that some features of Spektral may depend explicitly on TensorFlow, although this dependency will be kept to a minimum.

Contributing

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spektral-0.0.5.tar.gz (40.9 kB view details)

Uploaded Source

Built Distribution

spektral-0.0.5-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file spektral-0.0.5.tar.gz.

File metadata

  • Download URL: spektral-0.0.5.tar.gz
  • Upload date:
  • Size: 40.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for spektral-0.0.5.tar.gz
Algorithm Hash digest
SHA256 62d418c8bde573545205c69932ad9b82f1fff903287fa5c6217e3eb243142e85
MD5 88fef0110e6159ec3fddc27173d87982
BLAKE2b-256 4f0ef93d3ddb45ea1d6162a4e20ea9933a3cfa87aa470f6e18c5921c99dd55ba

See more details on using hashes here.

Provenance

File details

Details for the file spektral-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: spektral-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.2

File hashes

Hashes for spektral-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7a250011b9333f21928ef3760a90be16a6626cbce2201f835193792638014f50
MD5 176eafa128dd6b2ddea95ca03cdfeba5
BLAKE2b-256 f6d4c61ab37419cee24b0312f2bae843792274f3c3205003dcc2cdb9c9c04c6b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page