Skip to main content

Random Fourier Features for PyTorch

Project description

Random Fourier Features Pytorch

Python package Coverage Status Documentation Status

PyPI Downloads

Random Fourier Features Pytorch is an implementation of "Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains" by Tancik et al. designed to fit seamlessly into any PyTorch project.

Installation

Use the package manager pip to install the package.

pip install random-fourier-features-pytorch

Usage

See the documentation for more details, but here are a few simple usage examples:

Gaussian Encoding

import torch
import rff

X = torch.randn((256, 256, 2))
encoding = rff.layers.GaussianEncoding(sigma=10.0, input_size=2, encoded_size=256)
Xp = encoding(X)

Basic Encoding

import torch
import rff

X = torch.randn((256, 256, 2))
encoding = rff.layers.BasicEncoding()
Xp = encoding(X)

Positional Encoding

import torch
import rff

X = torch.randn((256, 256, 2))
encoding = rff.layers.PositionalEncoding(sigma=1.0, m=10)
Xp = encoding(X)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Citation

If you end up using this repository, please cite it as:

@article{long2021rffpytorch,
  title={Random Fourier Features Pytorch},
  author={Joshua M. Long},
  journal={GitHub. Note: https://github.com/jmclong/random-fourier-features-pytorch},
  year={2021}
}

also cite the original work

@misc{tancik2020fourier,
      title={Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains}, 
      author={Matthew Tancik and Pratul P. Srinivasan and Ben Mildenhall and Sara Fridovich-Keil and Nithin Raghavan and Utkarsh Singhal and Ravi Ramamoorthi and Jonathan T. Barron and Ren Ng},
      year={2020},
      eprint={2006.10739},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

License

This is released under the MIT license found in the LICENSE file.

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

random-fourier-features-pytorch-1.0.1.tar.gz (5.9 kB view hashes)

Uploaded Source

Built Distribution

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