frame-averaging-pytorch


Nameframe-averaging-pytorch JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryFrame Averaging
upload_time2024-06-07 12:47:14
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseMIT License Copyright (c) 2024 Phil Wang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords artificial intelligence deep learning geometric learning
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <img src="./frame-averaging.png" width="350px"></img>

## Frame Averaging - Pytorch

Pytorch implementation of a simple way to enable <a href="https://arxiv.org/abs/2305.05577">(Stochastic)</a> <a href="https://arxiv.org/abs/2110.03336">Frame Averaging</a> for any network. This technique was recently adopted by Prescient Design in <a href="https://arxiv.org/abs/2308.05027">AbDiffuser</a>

## Install

```bash
$ pip install frame-averaging-pytorch
```

## Usage

```python
import torch
from frame_averaging_pytorch import FrameAverage

# contrived neural network

net = torch.nn.Linear(3, 3)

# wrap the network with FrameAverage

net = FrameAverage(
    net,
    dim = 3,           # defaults to 3 for spatial, but can be any value
    stochastic = True  # whether to use stochastic variant from FAENet (one frame sampled at random)
)

# pass your input to the network as usual

points = torch.randn(4, 1024, 3)
mask = torch.ones(4, 1024).bool()

out = net(points, frame_average_mask = mask)

out.shape # (4, 1024, 3)

# frame averaging is automatically taken care of, as though the network were unwrapped
```

or you can also carry it out manually

```python
import torch
from frame_averaging_pytorch import FrameAverage

# contrived neural network

net = torch.nn.Linear(3, 3)

# frame average module without passing in network

fa = FrameAverage()

# pass the 3d points and mask to FrameAverage forward

points = torch.randn(4, 1024, 3)
mask = torch.ones(4, 1024).bool()

framed_inputs, frame_average_fn = fa(points, frame_average_mask = mask)

# network forward

net_out = net(framed_inputs)

# frame average

frame_averaged = frame_average_fn(net_out)

frame_averaged.shape # (4, 1024, 3)
```

## Citations

```bibtex
@article{Puny2021FrameAF,
    title   = {Frame Averaging for Invariant and Equivariant Network Design},
    author  = {Omri Puny and Matan Atzmon and Heli Ben-Hamu and Edward James Smith and Ishan Misra and Aditya Grover and Yaron Lipman},
    journal = {ArXiv},
    year    = {2021},
    volume  = {abs/2110.03336},
    url     = {https://api.semanticscholar.org/CorpusID:238419638}
}
```

```bibtex
@article{Duval2023FAENetFA,
    title   = {FAENet: Frame Averaging Equivariant GNN for Materials Modeling},
    author  = {Alexandre Duval and Victor Schmidt and Alex Hernandez Garcia and Santiago Miret and Fragkiskos D. Malliaros and Yoshua Bengio and David Rolnick},
    journal = {ArXiv},
    year    = {2023},
    volume  = {abs/2305.05577},
    url     = {https://api.semanticscholar.org/CorpusID:258564608}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "frame-averaging-pytorch",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "artificial intelligence, deep learning, geometric learning",
    "author": null,
    "author_email": "Phil Wang <lucidrains@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/65/1d/367beb477104b7b18fee165c86795927d61542f06f1f327e5be2c7313112/frame_averaging_pytorch-0.1.1.tar.gz",
    "platform": null,
    "description": "<img src=\"./frame-averaging.png\" width=\"350px\"></img>\n\n## Frame Averaging - Pytorch\n\nPytorch implementation of a simple way to enable <a href=\"https://arxiv.org/abs/2305.05577\">(Stochastic)</a> <a href=\"https://arxiv.org/abs/2110.03336\">Frame Averaging</a> for any network. This technique was recently adopted by Prescient Design in <a href=\"https://arxiv.org/abs/2308.05027\">AbDiffuser</a>\n\n## Install\n\n```bash\n$ pip install frame-averaging-pytorch\n```\n\n## Usage\n\n```python\nimport torch\nfrom frame_averaging_pytorch import FrameAverage\n\n# contrived neural network\n\nnet = torch.nn.Linear(3, 3)\n\n# wrap the network with FrameAverage\n\nnet = FrameAverage(\n    net,\n    dim = 3,           # defaults to 3 for spatial, but can be any value\n    stochastic = True  # whether to use stochastic variant from FAENet (one frame sampled at random)\n)\n\n# pass your input to the network as usual\n\npoints = torch.randn(4, 1024, 3)\nmask = torch.ones(4, 1024).bool()\n\nout = net(points, frame_average_mask = mask)\n\nout.shape # (4, 1024, 3)\n\n# frame averaging is automatically taken care of, as though the network were unwrapped\n```\n\nor you can also carry it out manually\n\n```python\nimport torch\nfrom frame_averaging_pytorch import FrameAverage\n\n# contrived neural network\n\nnet = torch.nn.Linear(3, 3)\n\n# frame average module without passing in network\n\nfa = FrameAverage()\n\n# pass the 3d points and mask to FrameAverage forward\n\npoints = torch.randn(4, 1024, 3)\nmask = torch.ones(4, 1024).bool()\n\nframed_inputs, frame_average_fn = fa(points, frame_average_mask = mask)\n\n# network forward\n\nnet_out = net(framed_inputs)\n\n# frame average\n\nframe_averaged = frame_average_fn(net_out)\n\nframe_averaged.shape # (4, 1024, 3)\n```\n\n## Citations\n\n```bibtex\n@article{Puny2021FrameAF,\n    title   = {Frame Averaging for Invariant and Equivariant Network Design},\n    author  = {Omri Puny and Matan Atzmon and Heli Ben-Hamu and Edward James Smith and Ishan Misra and Aditya Grover and Yaron Lipman},\n    journal = {ArXiv},\n    year    = {2021},\n    volume  = {abs/2110.03336},\n    url     = {https://api.semanticscholar.org/CorpusID:238419638}\n}\n```\n\n```bibtex\n@article{Duval2023FAENetFA,\n    title   = {FAENet: Frame Averaging Equivariant GNN for Materials Modeling},\n    author  = {Alexandre Duval and Victor Schmidt and Alex Hernandez Garcia and Santiago Miret and Fragkiskos D. Malliaros and Yoshua Bengio and David Rolnick},\n    journal = {ArXiv},\n    year    = {2023},\n    volume  = {abs/2305.05577},\n    url     = {https://api.semanticscholar.org/CorpusID:258564608}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 Phil Wang  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Frame Averaging",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://pypi.org/project/frame-averaging-pytorch/",
        "Repository": "https://github.com/lucidrains/frame-averaging-pytorch"
    },
    "split_keywords": [
        "artificial intelligence",
        " deep learning",
        " geometric learning"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fee06d0b97238ab6101662e110d4c1a08541429c6a2be382cd7c07ae244780c1",
                "md5": "79ddaba6921dbfc658807ef72d625cf7",
                "sha256": "a056e36242435d786043a36cc2c4bbcf6576c408debd9075b1839c60f3c89ea8"
            },
            "downloads": -1,
            "filename": "frame_averaging_pytorch-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "79ddaba6921dbfc658807ef72d625cf7",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 6023,
            "upload_time": "2024-06-07T12:47:12",
            "upload_time_iso_8601": "2024-06-07T12:47:12.405868Z",
            "url": "https://files.pythonhosted.org/packages/fe/e0/6d0b97238ab6101662e110d4c1a08541429c6a2be382cd7c07ae244780c1/frame_averaging_pytorch-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "651d367beb477104b7b18fee165c86795927d61542f06f1f327e5be2c7313112",
                "md5": "9b2536d35057dbf07f65a471a725ab0d",
                "sha256": "4bcbd622aa62282d5cb7f77021ca9c3c984fcea58e03377ce5b815282bf896d7"
            },
            "downloads": -1,
            "filename": "frame_averaging_pytorch-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9b2536d35057dbf07f65a471a725ab0d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 221082,
            "upload_time": "2024-06-07T12:47:14",
            "upload_time_iso_8601": "2024-06-07T12:47:14.540795Z",
            "url": "https://files.pythonhosted.org/packages/65/1d/367beb477104b7b18fee165c86795927d61542f06f1f327e5be2c7313112/frame_averaging_pytorch-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-07 12:47:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "lucidrains",
    "github_project": "frame-averaging-pytorch",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "frame-averaging-pytorch"
}
        
Elapsed time: 0.24238s