Skip to content

gsxform

Wavelet scattering transforms on graphs via PyTorch

tests codecov docs PyPI uv ruff license DOI


gsxform is a package for constructing graph scattering transforms, leveraging PyTorch to allow for GPU based computation. Using PyTorch, gsxform offers the ability to more easily build models that use both scattering transform and neural network components.

gsxform is first and foremost a research project and is being continuously refined. Behavior can potentially be unstable and consistency is not guaranteed.

Installation

gsxform requires Python 3.10 or later.

uv add "gsxform @ git+https://github.com/armaank/gsxform"

Or, to use a specific branch not yet merged to main

uv add "gsxform @ git+https://github.com/armaank/gsxform@branch-name"

Stable Version

To install the latest stable release from PyPI:

uv add gsxform
# or
pip install gsxform

Optional: torch_geometric support

The core package needs only PyTorch, but has adapters to work with existing models and daasets from torch_geometric (PyG)

from gsxform import Diffusion

phi = Diffusion(n_scales=4, n_layers=3)(x, W_adj)

If your graphs are already in PyTorch Geometric format (Data objects, edge_index, DataLoader batches), install the pyg extra:

uv add "gsxform[pyg]"
# or
pip install "gsxform[pyg]"

To use gsxform with PyG, you can either use:

  • GraphScattering, which wraps any transform as a module with the usual (x, edge_index, batch, edge_weight) signature. Use it as a feature extractor or as a layer inside a PyG model. It returns [n_graphs, F·C], or [n_nodes, F·C] for node output.
  • ScatteringFeatures as a dataset transform. It computes each graph's scattering features once, when the dataset loads, and stores them on the Data object. Use it when the features feed a separate classifier.

See the examples page for how to use PyG and gsxform in tandem.

Development version

gsxform uses uv to manage environments and dependencies. To work on gsxform itself, clone the repository and run make install:

git clone https://github.com/armaank/gsxform.git
cd gsxform
make install

This creates the virtual environment, installs gsxform with development and documentation dependencies, and sets up the pre-commit hooks. The development guide covers the make targets, code style, branching, and the release process.

Examples

See the examples page for how to set up and run the example notebooks.

License

The original code of this repository is released under the BSD 3.0-Clause Licence. Modifications, adaptations and derivative work is encouraged!

Citation

If you use gsxform, please cite using the Zenodo DOI