Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
# Conflicts:
#	spektral/datasets/qm9.py
#	spektral/utils/data.py
  • Loading branch information
danielegrattarola committed Nov 30, 2020
2 parents afc2618 + c9167f2 commit c4c87a0
Show file tree
Hide file tree
Showing 122 changed files with 5,695 additions and 4,054 deletions.
22 changes: 11 additions & 11 deletions .github/workflows/examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y graphviz libgraphviz-dev libcgraph6
- name: Python Dependencies
- name: Python dependencies
run: |
python -m pip install --upgrade pip
pip install matplotlib lxml tqdm ogb
- name: Install spektral
- name: Install Spektral
run: |
pip install .
- name: Just one epoch
Expand All @@ -36,20 +36,20 @@ jobs:
- name: Run all examples
run: |
cd examples/node_prediction/
for c_py in citation_*.py; do
echo "##### $c_py #####"
python $c_py
for f in *.py; do
echo "##### $f #####"
python $f
done
cd ..
cd graph_prediction/
for c_py in qm9_*.py; do
echo "##### $c_py #####"
python $c_py
for f in *.py; do
echo "##### $f #####"
python $f
done
cd ..
cd other/
for c_py in *.py; do
echo "##### $c_py #####"
python $c_py
for f in *.py; do
echo "##### $f #####"
python $f
done
cd ..
28 changes: 9 additions & 19 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ If you found a bug in the latest version of Spektral, you can [open an issue](ht

Before opening the issue, make sure to follow these steps:

1. Update to the current master branch and see if the problem is already solved. Sometimes a change does not get released immediately on PyPi, so it might be a good idea to install from source.
1. Update to the current `develop` branch and see if the problem is already solved. Sometimes a change does not get released immediately on PyPi, so it might be a good idea to install from source.
2. Check old issues to see if the problem was already solved.
3. Make sure that your configuration checks all requirements, including:
3. Make sure that your configuration matches all requirements, including:
- Operating system
- Python version
- Version of Spektral
- Version of Tensorflow and Keras (note that since version 0.3 Spektral only supports `tf.keras`)
- Version of CUDA and cuDNN
- Tensorflow version (note that since version 0.3 Spektral only supports `tf.keras` and TensorFlow 2.1 and above)
4. Provide a minimal script to reproduce the issue. The script should be runnable as-is, with no modification or external data.
5. Include any stack trace/errors that you get.

Expand All @@ -27,7 +25,7 @@ Bug fixes should be added to the `master` branch.

## Feature requests

If you want to request a feature, [open an issue](https://github.com/danielegrattarola/spektral/issues) on GitHub and clearly mark it as a feature request.
If you want to request a feature, [open an issue](https://github.com/danielegrattarola/spektral/issues) on GitHub and mark it as a feature request.

1. Give a detailed description of the feature, including why it is important and why it fits in the scope of the project.
Spektral is primarily a library for creating graph neural networks, so new features should gravitate around this subject.
Expand All @@ -47,7 +45,7 @@ There are no hard rules for contributing to Spektral, but you should try to foll
**General guidelines:**

- Format your code according to PEP8;
- Make sure that the code you contribute is clearly identifiable in a PR (e.g., watch out for your IDE automatically reformatting the whole project);
- Make sure that the code you contribute is clearly identifiable in a PR (e.g., watch out for your IDE automatically reformatting files);
- New features should support:
- Python >= 3.5
- TensorFlow >= 2.1.0
Expand All @@ -64,23 +62,15 @@ There are no hard rules for contributing to Spektral, but you should try to foll
- Message-passing/convolutional layers go in their own file in `layers/convolutional/`;
- Pooling layers go in their own file in `layers/pooling/`;
- Global pooling layers go in `layers/pooling/globalpool.py`;
- Layers should extend `tensorflow.keras.layers.Layer` and implement the following methods:
- `build()`
- `call()`
- `compute_output_shape()`
- `get_config()`
- Convolutional layers should also implement a `preprocess(A)` staticmethod to manipulate/normalize the adjacency matrix before giving it as input to the GNN (e.g., the `preoprocess()` method of GCN adds self-loops and then re-scales each row by the degree);
- Make sure that you understand [data modes](https://spektral.graphneural.network/data/) and that you know the modes supported by your layer. Layers should support at least single or batch mode;
- Many layers in Spektral inherit their base functionality from `GraphConv`, check if this is the case for yours as well;
- There is also a `MessagePassing` layer that offers a quick API to implement convolutional layers in single/disjoint mode;
- Layers should extend `MessagePassing`, `Conv` or `Pool`.
- Make sure that you understand [data modes](https://graphneural.network/data-modes/) and that you know the modes supported by your layer. Layers should support at least one of disjoint or batch mode;
**Guidelines for testing:**
- Tests are found in `tests/`;
- It's especially important to add tests for any new layer. See `tests/test_layers/` and the files contained there;
- See the comments in each test `.py` for more information;
- See the docstrings in each file for more information;
**Guidelines for the documentation:**
- See the documentation in the other layers for how to format docstrings (it's important that the format is the same so that the docs can be built automatically);
- Docs are automatically generated using `docs/autogen.py`. Make sure to include any new Layer as an entry in the `PAGES` dictionary. It is not necessary to add utils and other minor functions to `autogen.py` (although you should still write the docstrings).
- Docs are automatically generated using `docs/autogen.py`. Make sure to include any new layer as an entry in the `PAGES` dictionary. It is not necessary to add utils and other minor functions to `autogen.py` (although you should still write the docstrings).
50 changes: 29 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<img src="https://danielegrattarola.github.io/spektral/img/logo_dark.svg" width="50%"/>
<img src="https://danielegrattarola.github.io/spektral/img/logo_dark.svg" style="max-width: 400px; width: 100%;"/>

# Welcome to Spektral
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 nodes of a network, predicting molecular properties, generating new graphs with GANs, clustering nodes, predicting links, and any other task where data is described by graphs.
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:

- [Graph Convolutional Networks (GCN)](https://arxiv.org/abs/1609.02907)
- [Chebyshev networks (ChebNets)](https://arxiv.org/abs/1606.09375)
- [Chebyshev convolutions](https://arxiv.org/abs/1606.09375)
- [GraphSAGE](https://arxiv.org/abs/1706.02216)
- [ARMA convolutions](https://arxiv.org/abs/1901.01343)
- [Edge-Conditioned Convolutions (ECC)](https://arxiv.org/abs/1704.02901)
Expand All @@ -22,29 +22,30 @@ and many others (see [convolutional layers](https://graphneural.network/layers/c

You can also find [pooling layers](https://graphneural.network/layers/pooling/), including:

- [MinCut pooling](https://arxiv.org/abs/1907.00481)
- [DiffPool](https://arxiv.org/abs/1806.08804)
- [MinCUT pooling](https://arxiv.org/abs/1907.00481)
- [Top-K pooling](http://proceedings.mlr.press/v97/gao19a/gao19a.pdf)
- [Self-Attention Graph (SAG) pooling](https://arxiv.org/abs/1904.08082)
- Global sum, average, and max pooling
- Global pooling
- [Global gated attention pooling](https://arxiv.org/abs/1511.05493)
- [SortPool](https://www.cse.wustl.edu/~muhan/papers/AAAI_2018_DGCNN.pdf)

Spektral also includes lots of utilities for your graph deep learning projects.
Spektral also includes lots of utilities for representing, manipulating, and transforming graphs in your graph deep learning projects.

See how to [get started with Spektral](https://graphneural.network/getting-started/) and have a look at the [examples](https://danielegrattarola.github.io/spektral/examples/) for some templates.

The source code of the project is available on [Github](https://github.com/danielegrattarola/spektral).
Read the documentation [here](https://graphneural.network).
You can also cite the paper introducing Spektral: [Graph Neural Networks in TensorFlow and Keras with Spektral](https://arxiv.org/abs/2006.12138) (ICML 2020 - GRL+ Workshop).

If you want to cite Spektral in your work, refer to our paper:

> [Graph Neural Networks in TensorFlow and Keras with Spektral](https://arxiv.org/abs/2006.12138)<br>
> Daniele Grattarola and Cesare Alippi
## Installation
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.

Some optional features of Spektral depend on [RDKit](http://www.rdkit.org/docs/index.html),
a library for cheminformatics and molecule manipulation (available through Anaconda).

The simplest way to install Spektral is from PyPi:

```bash
Expand All @@ -65,21 +66,28 @@ To install Spektral on [Google Colab](https://colab.research.google.com/):
! pip install spektral
```

## TensorFlow 1 and Keras
Starting from version 0.3, Spektral only supports TensorFlow 2 and `tf.keras`.
The old version of Spektral, which is based on TensorFlow 1 and the stand-alone Keras library, is still available on the `tf1` branch on GitHub and can be installed from source:
## New in Spektral 1.0

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 `datasets` API.

This is a summary of the new features and changes:

- The new `Graph` and `Dataset` containers standardize how Spektral handles data.
**This does not impact your models**, but makes it easier to use your data in Spektral.
- The new `Loader` class 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.
- The new `transforms` module implements a wide variety of common operations on graphs, that you can now `apply()` to your datasets.
- The new `GeneralConv` and `GeneralGNN` classes 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.
- New datasets: QM7 and ModelNet10/40, and a new wrapper for OGB datasets.
- Major clean-up of the library's structure and dependencies.
- New examples and tutorials.

```bash
git clone https://github.com/danielegrattarola/spektral.git
cd spektral
git checkout tf1
python setup.py install # Or 'pip install .'
```

In the future, the TF1-compatible version of Spektral (<0.2) will receive bug fixes, but all new features will only support TensorFlow 2.

## Contributing
Spektral is an open source project available [on Github](https://github.com/danielegrattarola/spektral), and contributions of all types are welcome.
Spektral is an open-source project available [on Github](https://github.com/danielegrattarola/spektral), 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.

The contribution guidelines are available [here](https://github.com/danielegrattarola/spektral/blob/master/CONTRIBUTING.md) and a list of feature requests is available [here](https://github.com/danielegrattarola/spektral/projects/1).
Loading

0 comments on commit c4c87a0

Please sign in to comment.