{"id":15632779,"url":"https://github.com/rusty1s/pytorch_spline_conv","last_synced_at":"2025-05-14T21:08:38.881Z","repository":{"id":41176438,"uuid":"115535501","full_name":"rusty1s/pytorch_spline_conv","owner":"rusty1s","description":"Implementation of the Spline-Based Convolution Operator of SplineCNN in PyTorch","archived":false,"fork":false,"pushed_at":"2025-04-10T19:30:38.000Z","size":373,"stargazers_count":178,"open_issues_count":1,"forks_count":36,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-10T20:42:19.632Z","etag":null,"topics":["geometric-deep-learning","graph-neural-networks","pytorch","spline-cnn"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/1711.08920","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rusty1s.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-27T15:47:09.000Z","updated_at":"2025-04-10T19:30:41.000Z","dependencies_parsed_at":"2023-02-13T01:40:10.999Z","dependency_job_id":"76d38338-de86-4267-bb4b-6594b2b2806b","html_url":"https://github.com/rusty1s/pytorch_spline_conv","commit_stats":{"total_commits":455,"total_committers":8,"mean_commits":56.875,"dds":0.05714285714285716,"last_synced_commit":"7102d6982b0535cb189a5bf8fc6018487541d11e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_spline_conv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_spline_conv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_spline_conv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rusty1s%2Fpytorch_spline_conv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rusty1s","download_url":"https://codeload.github.com/rusty1s/pytorch_spline_conv/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248754368,"owners_count":21156417,"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":["geometric-deep-learning","graph-neural-networks","pytorch","spline-cnn"],"created_at":"2024-10-03T10:45:17.805Z","updated_at":"2025-04-13T17:38:59.696Z","avatar_url":"https://github.com/rusty1s.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"[pypi-image]: https://badge.fury.io/py/torch-spline-conv.svg\n[pypi-url]: https://pypi.python.org/pypi/torch-spline-conv\n[testing-image]: https://github.com/rusty1s/pytorch_spline_conv/actions/workflows/testing.yml/badge.svg\n[testing-url]: https://github.com/rusty1s/pytorch_spline_conv/actions/workflows/testing.yml\n[linting-image]: https://github.com/rusty1s/pytorch_spline_conv/actions/workflows/linting.yml/badge.svg\n[linting-url]: https://github.com/rusty1s/pytorch_spline_conv/actions/workflows/linting.yml\n[coverage-image]: https://codecov.io/gh/rusty1s/pytorch_spline_conv/branch/master/graph/badge.svg\n[coverage-url]: https://codecov.io/github/rusty1s/pytorch_spline_conv?branch=master\n\n# Spline-Based Convolution Operator of SplineCNN\n\n[![PyPI Version][pypi-image]][pypi-url]\n[![Testing Status][testing-image]][testing-url]\n[![Linting Status][linting-image]][linting-url]\n[![Code Coverage][coverage-image]][coverage-url]\n\n--------------------------------------------------------------------------------\n\nThis is a PyTorch implementation of the spline-based convolution operator of SplineCNN, as described in our paper:\n\nMatthias Fey, Jan Eric Lenssen, Frank Weichert, Heinrich Müller: [SplineCNN: Fast Geometric Deep Learning with Continuous B-Spline Kernels](https://arxiv.org/abs/1711.08920) (CVPR 2018)\n\nThe operator works on all floating point data types and is implemented both for CPU and GPU.\n\n## Installation\n\n### Binaries\n\nWe provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](https://data.pyg.org/whl).\n\n#### PyTorch 2.6\n\nTo install the binaries for PyTorch 2.6.0, simply run\n\n```\npip install torch-spline-conv -f https://data.pyg.org/whl/torch-2.6.0+${CUDA}.html\n```\n\nwhere `${CUDA}` should be replaced by either `cpu`, `cu118`, `cu124`, or `cu126` depending on your PyTorch installation.\n\n|             | `cpu` | `cu118` | `cu124` | `cu126` |\n|-------------|-------|---------|---------|---------|\n| **Linux**   | ✅    | ✅      | ✅      | ✅      |\n| **Windows** | ✅    | ✅      | ✅      | ✅      |\n| **macOS**   | ✅    |         |         |         |\n\n#### PyTorch 2.5\n\nTo install the binaries for PyTorch 2.5.0/2.5.1, simply run\n\n```\npip install torch-spline-conv -f https://data.pyg.org/whl/torch-2.5.0+${CUDA}.html\n```\n\nwhere `${CUDA}` should be replaced by either `cpu`, `cu118`, `cu121`, or `cu124` depending on your PyTorch installation.\n\n|             | `cpu` | `cu118` | `cu121` | `cu124` |\n|-------------|-------|---------|---------|---------|\n| **Linux**   | ✅    | ✅      | ✅      | ✅      |\n| **Windows** | ✅    | ✅      | ✅      | ✅      |\n| **macOS**   | ✅    |         |         |         |\n\n**Note:** Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0, PyTorch 1.7.0/1.7.1, PyTorch 1.8.0/1.8.1, PyTorch 1.9.0, PyTorch 1.10.0/1.10.1/1.10.2, PyTorch 1.11.0, PyTorch 1.12.0/1.12.1, PyTorch 1.13.0/1.13.1, PyTorch 2.0.0/2.0.1, PyTorch 2.1.0/2.1.1/2.1.2, PyTorch 2.2.0/2.2.1/2.2.2, PyTorch 2.3.0/2.3.1, and PyTorch 2.4.0/2.4.1 (following the same procedure).\nFor older versions, you need to explicitly specify the latest supported version number or install via `pip install --no-index` in order to prevent a manual installation from source.\nYou can look up the latest supported version number [here](https://data.pyg.org/whl).\n\n### From source\n\nEnsure that at least PyTorch 1.4.0 is installed and verify that `cuda/bin` and `cuda/include` are in your `$PATH` and `$CPATH` respectively, *e.g.*:\n\n```\n$ python -c \"import torch; print(torch.__version__)\"\n\u003e\u003e\u003e 1.4.0\n\n$ echo $PATH\n\u003e\u003e\u003e /usr/local/cuda/bin:...\n\n$ echo $CPATH\n\u003e\u003e\u003e /usr/local/cuda/include:...\n```\n\nThen run:\n\n```\npip install torch-spline-conv\n```\n\nWhen running in a docker container without NVIDIA driver, PyTorch needs to evaluate the compute capabilities and may fail.\nIn this case, ensure that the compute capabilities are set via `TORCH_CUDA_ARCH_LIST`, *e.g.*:\n\n```\nexport TORCH_CUDA_ARCH_LIST = \"6.0 6.1 7.2+PTX 7.5+PTX\"\n```\n\n## Usage\n\n```python\nfrom torch_spline_conv import spline_conv\n\nout = spline_conv(x,\n                  edge_index,\n                  pseudo,\n                  weight,\n                  kernel_size,\n                  is_open_spline,\n                  degree=1,\n                  norm=True,\n                  root_weight=None,\n                  bias=None)\n```\n\nApplies the spline-based convolution operator\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"50%\" src=\"https://user-images.githubusercontent.com/6945922/38684093-36d9c52e-3e6f-11e8-9021-db054223c6b9.png\" /\u003e\n\u003c/p\u003e\nover several node features of an input graph.\nThe kernel function is defined over the weighted B-spline tensor product basis, as shown below for different B-spline degrees.\n\n\u003cp align=\"center\"\u003e\n  \u003cimg width=\"45%\" src=\"https://user-images.githubusercontent.com/6945922/38685443-3a2a0c68-3e72-11e8-8e13-9ce9ad8fe43e.png\" /\u003e\n  \u003cimg width=\"45%\" src=\"https://user-images.githubusercontent.com/6945922/38685459-42b2bcae-3e72-11e8-88cc-4b61e41dbd93.png\" /\u003e\n\u003c/p\u003e\n\n### Parameters\n\n* **x** *(Tensor)* - Input node features of shape `(number_of_nodes x in_channels)`.\n* **edge_index** *(LongTensor)* - Graph edges, given by source and target indices, of shape `(2 x number_of_edges)`.\n* **pseudo** *(Tensor)* - Edge attributes, ie. pseudo coordinates, of shape `(number_of_edges x number_of_edge_attributes)` in the fixed interval [0, 1].\n* **weight** *(Tensor)* - Trainable weight parameters of shape `(kernel_size x in_channels x out_channels)`.\n* **kernel_size** *(LongTensor)* - Number of trainable weight parameters in each edge dimension.\n* **is_open_spline** *(ByteTensor)* - Whether to use open or closed B-spline bases for each dimension.\n* **degree** *(int, optional)* - B-spline basis degree. (default: `1`)\n* **norm** *(bool, optional)*: Whether to normalize output by node degree. (default: `True`)\n* **root_weight** *(Tensor, optional)* - Additional shared trainable parameters for each feature of the root node of shape `(in_channels x out_channels)`. (default: `None`)\n* **bias** *(Tensor, optional)* - Optional bias of shape `(out_channels)`. (default: `None`)\n\n### Returns\n\n* **out** *(Tensor)* - Out node features of shape `(number_of_nodes x out_channels)`.\n\n### Example\n\n```python\nimport torch\nfrom torch_spline_conv import spline_conv\n\nx = torch.rand((4, 2), dtype=torch.float)  # 4 nodes with 2 features each\nedge_index = torch.tensor([[0, 1, 1, 2, 2, 3], [1, 0, 2, 1, 3, 2]])  # 6 edges\npseudo = torch.rand((6, 2), dtype=torch.float)  # two-dimensional edge attributes\nweight = torch.rand((25, 2, 4), dtype=torch.float)  # 25 parameters for in_channels x out_channels\nkernel_size = torch.tensor([5, 5])  # 5 parameters in each edge dimension\nis_open_spline = torch.tensor([1, 1], dtype=torch.uint8)  # only use open B-splines\ndegree = 1  # B-spline degree of 1\nnorm = True  # Normalize output by node degree.\nroot_weight = torch.rand((2, 4), dtype=torch.float)  # separately weight root nodes\nbias = None  # do not apply an additional bias\n\nout = spline_conv(x, edge_index, pseudo, weight, kernel_size,\n                  is_open_spline, degree, norm, root_weight, bias)\n\nprint(out.size())\ntorch.Size([4, 4])  # 4 nodes with 4 features each\n```\n\n## Cite\n\nPlease cite our paper if you use this code in your own work:\n\n```\n@inproceedings{Fey/etal/2018,\n  title={{SplineCNN}: Fast Geometric Deep Learning with Continuous {B}-Spline Kernels},\n  author={Fey, Matthias and Lenssen, Jan Eric and Weichert, Frank and M{\\\"u}ller, Heinrich},\n  booktitle={IEEE Conference on Computer Vision and Pattern Recognition (CVPR)},\n  year={2018},\n}\n```\n\n## Running tests\n\n```\npytest\n```\n\n## C++ API\n\n`torch-spline-conv` also offers a C++ API that contains C++ equivalent of python models.\n\n```\nmkdir build\ncd build\n# Add -DWITH_CUDA=on support for the CUDA if needed\ncmake ..\nmake\nmake install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusty1s%2Fpytorch_spline_conv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frusty1s%2Fpytorch_spline_conv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frusty1s%2Fpytorch_spline_conv/lists"}