Skip to main content

Frame Averaging

Project description

Frame Averaging - Pytorch

Pytorch implementation of a simple way to enable (Stochastic) Frame Averaging for any network. This technique was recently adopted by Prescient Design in AbDiffuser

Install

$ pip install frame-averaging-pytorch

Usage

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

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

@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}
}
@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}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

frame_averaging_pytorch-0.1.1.tar.gz (221.1 kB view details)

Uploaded Source

Built Distribution

frame_averaging_pytorch-0.1.1-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file frame_averaging_pytorch-0.1.1.tar.gz.

File metadata

File hashes

Hashes for frame_averaging_pytorch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4bcbd622aa62282d5cb7f77021ca9c3c984fcea58e03377ce5b815282bf896d7
MD5 9b2536d35057dbf07f65a471a725ab0d
BLAKE2b-256 651d367beb477104b7b18fee165c86795927d61542f06f1f327e5be2c7313112

See more details on using hashes here.

File details

Details for the file frame_averaging_pytorch-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for frame_averaging_pytorch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a056e36242435d786043a36cc2c4bbcf6576c408debd9075b1839c60f3c89ea8
MD5 79ddaba6921dbfc658807ef72d625cf7
BLAKE2b-256 fee06d0b97238ab6101662e110d4c1a08541429c6a2be382cd7c07ae244780c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page