The Python implementation of the μG language for programming graph neural networks
Project description
libmg
libmg is a Python library for compiling μG expressions into TensorFlow model. It allows the parsing, unparsing, normalization, compilation of μG expressions. It also provides functionalities to visualize graphs and model outputs.
Pre-requisites
- A Linux operating system (preferably Ubuntu 16.04 or later as per the TensorFlow recommendation).
- Python 3.11 environment.
The library can run both on the CPU or the GPU. To enable the GPU, the specific dependencies needed are those of TensorFlow 2.12, that is:
- GCC 9.3.1
- Bazel 5.3.0
- NVIDIA GPU drivers version 450.80.02 or higher
- CUDA 11.8
- cuDNN 8.6
- (Optional) TensorRT 7
Installation
libmg can be installed via pip or from source.
Pip installation
libmg can be installed from the Python Package Index PyPI, by simply running the following command in your shell or virtual environment:
$ pip install libmg
Source installation
You can install libmg from source using git. You can start by downloading the repo archive or by cloning the repo:
git clone https://github.com/quasylab/mG.git
Then proceed by opening a shell into the mG directory you have just downloaded. To build the library you will need to use [Poetry](https://python-poetry.
org/). Run the following command:
poetry install
and Poetry will install libmg in your Python environment. To install the development dependencies as well, install with:
poetry install --with tests --with docs
This will add the testing dependencies (pytest, mypy, and flake8) as well as the documentation dependencies (mkdocs and plugins).
Usage
- Create a
Datasetobject with theGraphinstances to process. - Define dictionaries of
Psi,Phi,Sigmaobjects as needed by your application. - Define a
CompilerConfigthat is adequate for the graphs in yourDataset - Create a
MGCompilerusing the dictionaries and theCompilerConfig - Create an adequate
Loaderfor yourDataset: use theSingleGraphLoaderif your dataset contains a single graph and use theMultipleGraphLoaderotherwise. - Build a model from your μG formulas using the compiler's
compile(expr)method. - Train your model as you would in Tensorflow
- Use
output = model.predict(loader.load(), steps=loader.steps_per_epoch)or a loop like
to run your model on the dataset.for x in loader.load(): output = model(x) - Visualize the outputs on the browser using
print_layer(model, inputs, layer_idx=-1)
Documentation
You can find the official documentation here.
Research articles
Matteo Belenchia, Flavio Corradini, Michela Quadrini, and Michele Loreti. 2023. Implementing a CTL Model Checker with μG, a Language for Programming Graph Neural Networks. In Formal Techniques for Distributed Objects, Components, and Systems: 43rd IFIP WG 6.1 International Conference, FORTE 2023, Held as Part of the 18th International Federated Conference on Distributed Computing Techniques, DisCoTec 2023, Lisbon, Portugal, June 19–23, 2023, Proceedings. Springer-Verlag, Berlin, Heidelberg, 37–54. https://doi.org/10.1007/978-3-031-35355-0_4. Preprint: https://www.researchgate.net/publication/371467699_Implementing_a_CTL_Model_Checker_with_mu_mathcal_G_a_Language_for_Programming_Graph_Neural_Networks
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file libmg-2.1.6.tar.gz.
File metadata
- Download URL: libmg-2.1.6.tar.gz
- Upload date:
- Size: 877.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62ddbd8511bdfd0dab223dcdda72cc0a4a42b846dfef6ad7cf5bd96a80925c19
|
|
| MD5 |
14b446567fa262091062ccff4e7ca773
|
|
| BLAKE2b-256 |
76e0356c079e50249a7d4610b019c9d20dd802971bad21e753d92aba3ca46352
|
Provenance
The following attestation bundles were made for libmg-2.1.6.tar.gz:
Publisher:
publish.yml on quasylab/mG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libmg-2.1.6.tar.gz -
Subject digest:
62ddbd8511bdfd0dab223dcdda72cc0a4a42b846dfef6ad7cf5bd96a80925c19 - Sigstore transparency entry: 251715585
- Sigstore integration time:
-
Permalink:
quasylab/mG@5367bd98c7c7ca245aedc52831063034457550d7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quasylab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5367bd98c7c7ca245aedc52831063034457550d7 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file libmg-2.1.6-py3-none-any.whl.
File metadata
- Download URL: libmg-2.1.6-py3-none-any.whl
- Upload date:
- Size: 893.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7a339209d742a8b4ba4f1f8af486f52e1e3c0941e2c4a3578ecb56b60a7fb077
|
|
| MD5 |
0414abc198c9d62d51dabb2d655ff497
|
|
| BLAKE2b-256 |
e00e37398907c426b6aa0010e9810916553d5be4e21318d4eee3cd5ddbd9773e
|
Provenance
The following attestation bundles were made for libmg-2.1.6-py3-none-any.whl:
Publisher:
publish.yml on quasylab/mG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
libmg-2.1.6-py3-none-any.whl -
Subject digest:
7a339209d742a8b4ba4f1f8af486f52e1e3c0941e2c4a3578ecb56b60a7fb077 - Sigstore transparency entry: 251715590
- Sigstore integration time:
-
Permalink:
quasylab/mG@5367bd98c7c7ca245aedc52831063034457550d7 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/quasylab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5367bd98c7c7ca245aedc52831063034457550d7 -
Trigger Event:
workflow_dispatch
-
Statement type: