Skip to main content

Tensorflow 2.0 implementation of Fourier Features mapping networks.

Project description

Tensorflow Fourier Feature Mapping Networks

Tensorflow 2.0 implementation of Fourier Feature Mapping networks from the paper Fourier Features Let Networks Learn High Frequency Functions in Low Dimensional Domains.


  • Pip install
$ pip install --upgrade tf_fourier_features
  • Pip install (test support)
$ pip install --upgrade tf_fourier_features[tests]


from tf_fourier_features import FourierFeatureProjection
from tf_fourier_features import FourierFeatureMLP

# You should use FourierFeatureProjection right after the input layer.
ip = tf.keras.layers.Input(shape=[2])
x = FourierFeatureProjection(gaussian_projection = 256, gaussian_scale = 1.0)(ip)
x = tf.keras.layers.Dense(256, activation='relu')(x)
x = tf.keras.layers.Dense(3, activation='sigmoid')(x)

model = tf.keras.Model(inputs=ip, outputs=x)

# Or directly use the model class to build a multi layer Fourier Feature Mapping Network
model = FourierFeatureMLP(units=256, final_units=3, final_activation='sigmoid', num_layers=4,
                          gaussian_projection=256, gaussian_scale=10.0)

Results on Image Inpainting task

A partial implementation of the image inpainting task is available as the and scripts inside the scripts directory.

Weight files are made available in the repository under the Release tab of the project. Extract the weights and place the checkpoints folder at the scripts directory.

These weights generates the following output after 2000 epochs of training with batch size 8192 while using only 10% of the available pixels in the image during training phase.

If we train for using only 20% of the available pixels in the image during training phase -

If we train for using only 30% of the available pixels in the image during training phase - .


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


  • Tensorflow 2.0+
  • Matplotlib to visualize eval result

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

tf_fourier_features-0.0.1.tar.gz (6.6 kB view hashes)

Uploaded source

Built Distribution

tf_fourier_features-0.0.1-py2.py3-none-any.whl (6.1 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page