A Python framework for relational representation learning
Project description
WARNING |
---|
The documentation for 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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file spektral-0.0.4.tar.gz
.
File metadata
- Download URL: spektral-0.0.4.tar.gz
- Upload date:
- Size: 39.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb38378a952955aaf9e824591202d3ea3f86b136db2c3987232498e6d9081565 |
|
MD5 | 18b8fa01bf6945bd3e07b64ce1793fe5 |
|
BLAKE2b-256 | 856242b97a4f7dd7dd2f8191721de3c7dec8a4224d5ecb0ca20e6695d688d6e7 |
Provenance
File details
Details for the file spektral-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: spektral-0.0.4-py3-none-any.whl
- Upload date:
- Size: 47.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57865b61c02605e07e29c4d60ae36b48e088403f12e9df11113158696035c722 |
|
MD5 | f69b8f6f4208110ec100170b31256d7d |
|
BLAKE2b-256 | d5492ad9c1e207ec510bec74d9872b2f354979965d78b6b029dd462465da2421 |