{"id":13869702,"url":"https://github.com/BorgwardtLab/TOGL","last_synced_at":"2025-07-15T18:31:45.586Z","repository":{"id":37709912,"uuid":"328666678","full_name":"BorgwardtLab/TOGL","owner":"BorgwardtLab","description":"Topological Graph Neural Networks (ICLR 2022)","archived":false,"fork":false,"pushed_at":"2022-06-10T06:02:01.000Z","size":1683,"stargazers_count":124,"open_issues_count":1,"forks_count":24,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-07-11T11:54:35.530Z","etag":null,"topics":["graph-classification","graph-learning","iclr2022","machine-learning","node-classification","persistent-homology","pytorch","pytorch-geometric"],"latest_commit_sha":null,"homepage":"https://openreview.net/pdf?id=oxxUMeFwEHd","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BorgwardtLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-11T13:06:05.000Z","updated_at":"2025-07-06T14:49:23.000Z","dependencies_parsed_at":"2022-07-08T01:31:06.611Z","dependency_job_id":null,"html_url":"https://github.com/BorgwardtLab/TOGL","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BorgwardtLab/TOGL","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FTOGL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FTOGL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FTOGL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FTOGL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BorgwardtLab","download_url":"https://codeload.github.com/BorgwardtLab/TOGL/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BorgwardtLab%2FTOGL/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265451443,"owners_count":23767768,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graph-classification","graph-learning","iclr2022","machine-learning","node-classification","persistent-homology","pytorch","pytorch-geometric"],"created_at":"2024-08-05T20:01:12.658Z","updated_at":"2025-07-15T18:31:45.557Z","avatar_url":"https://github.com/BorgwardtLab.png","language":"Python","readme":"# Topological Graph Neural Networks\n\nThis repository contains the code for our ICLR 2022 paper \u0026ldquo;Topological\nGraph Neural Networks.\u0026ldquo; This repository requires either Python 3.7 or 3.8 to\nbe installed.\n\n**Please note**: This repository is a work in progress!\n\n## Citation\n\nIf you use this code, please consider citing our paper:\n\n```bibtex\n@InProceedings{Horn22a,\n  author        = {Horn, Max and {De Brouwer}, Edward and Moor, Michael and Moreau, Yves and Rieck, Bastian and Borgwardt, Karsten},\n  title         = {Topological Graph Neural Networks},\n  year          = {2022},\n  booktitle     = {International Conference on Learning Representations~(ICLR)},\n  url           = {https://openreview.net/pdf?id=oxxUMeFwEHd},\n}\n```\n\n## Quickstart\n\n```bash\n# Install poetry\ncurl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -\n# Create venv and install dependencies of project\npoetry install\n# In case any errors occur, please rerun `poetry install`\npoetry run install_deps_cpu  # or of course install_deps_cuXXX for GPU support\n# Train TopoGNN on DD for 10 epochs\npoetry run python topognn/train_model.py --model TopoGNN --dataset DD --max_epochs 10\n```\n\n## Installation\n\nThis repository uses `poetry` in order to manage dependencies and provide\na virtual environment for the project.  In order to install `poetry` please\nrefer to the instructions [here](https://python-poetry.org/docs/#installation).\nAfter poetry is installed it can be used to create a virtual environment and\ninstall the dependencies of the repository:\n\n```bash\n$ poetry install\n# If any errors occur please rerun the command `poetry install`\n```\n\nDue to some incompatibilities between `poetry` and `torch_geometric` (which was\nused for the implementation of GNNs in this repository), additional\ndependencies need to be installed in a separate step dependent on the necessity\nof CUDA based GPU acceleration.  This can be done using the command below\n\n```bash\n$ poetry run install_deps_{cpu, cu101, cu102, cu110}\n```\n\nwhere `{cpu, cu101, cu102, cu110}` should be replaced with either `cpu` or the\nstring matching the installed cuda toolkit version.\n\n## Training models\n\nThe repository implements two models `TopoGNN` and `GNN`.  Additional\nparameters can be passed to the script depending on the model and dataset\nselected. For example, the `GNN` model and the `MNIST` dataset have the\nfollowing configuration options:\n\n```bash\n$ poetry run topognn/train_model.py --model GNN --dataset MNIST --help\nusage: train_model.py [-h] [--model {TopoGNN,GCN}]\n                      [--dataset {IMDB-BINARY,REDDIT-BINARY,REDDIT-5K,PROTEINS,PROTEINS_full,ENZYMES,DD,MUTAG,MNIST,CIFAR10,PATTERN,CLUSTER,Necklaces,Cycles,NoCycles}]\n                      [--training_seed TRAINING_SEED]\n                      [--max_epochs MAX_EPOCHS] [--paired PAIRED]\n                      [--merged MERGED] [--logger {wandb,tensorboard}]\n                      [--gpu GPU] [--hidden_dim HIDDEN_DIM]\n                      [--lr LR]\n                      [--dropout_p DROPOUT_P] [--GIN GIN]\n                      [--train_eps TRAIN_EPS] [--batch_norm BATCH_NORM]\n                      [--residual RESIDUAL] [--batch_size BATCH_SIZE]\n                      [--use_node_attributes USE_NODE_ATTRIBUTES]\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --model {TopoGNN,GCN}\n  --dataset {IMDB-BINARY,REDDIT-BINARY,REDDIT-5K,PROTEINS,PROTEINS_full,ENZYMES,DD,MUTAG,MNIST,CIFAR10,PATTERN,CLUSTER,Necklaces,Cycles,NoCycles}\n  --training_seed TRAINING_SEED\n  --max_epochs MAX_EPOCHS\n  --paired PAIRED\n  --merged MERGED\n  --logger {wandb,tensorboard}\n  --gpu GPU\n  --hidden_dim HIDDEN_DIM\n  --lr LR\n  --dropout_p DROPOUT_P\n  --GIN GIN\n  --train_eps TRAIN_EPS\n  --batch_norm BATCH_NORM\n  --residual RESIDUAL\n  --batch_size BATCH_SIZE\n  --use_node_attributes USE_NODE_ATTRIBUTES\n```\n\n### Logging\n\nBy default runs are logged using Tensorboard, yet logging via WandB is also\npossible. For this some adaptations to the code might be necessary in order to\nlog to the correct entity/project.  The logs of Tensorboard are by default\nstored under the path `logs/{MODEL}_{DATASET}`.\n\n### TopoGNN variants and ablations\n\nIn our work we show multiple variants and ablations of the TOGL layer. In\nparticular we present the `simple` variant, which does not actually perform any\ntopological computation, but merely includes all other components of the layer.\nThis setting can be triggered using the additional parameter `--fake True`.\nFurther, we differentiate between TOGL with coordinatization functions with the\nparameter `--deepset False` and TOGL using a deep sets `--deepset True`.  Below\nyou can see some configurations which reflect the scenarios covered in our\nwork.\n\n```bash\n# TopoGNN with coord functions\npoetry run topognn/train_model.py --model TopoGNN --dataset DD --batch_size 20 --lr 0.0007\n\n# GCN on DD\npoetry run topognn/train_model.py --model GCN --dataset DD --batch_size 20 --lr 0.0007\n```\n\nAdditional calls are also possible; check out available models in `models.py`.\n\n### Synthetic datasets\n\nThe synthetic datasets used to train our models are provided in the folder\n`data/SYNTHETIC`. If these are not compatible with your architecture (which\ncould happen as they are saved in a binary file format), you can regenerate the\nsynthetic datasets using calls to the script `data/SYNTHETIC/datagen.py`:\n\n```bash\ncd data/SYNTHETIC\npoetry run python datagen.py --dataset Cycle --min_cycle 3\npoetry run python datagen.py --dataset Necklaces\n```\n\n## Results used for plots\n\nThe results and data used to plot our figures can be found in the folder\n`plots_data` and code to generate plots can be found in the `notebooks` folder.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBorgwardtLab%2FTOGL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBorgwardtLab%2FTOGL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBorgwardtLab%2FTOGL/lists"}