Skip to main content

Sample PyTorch implementation of the snake activation function

Project description

Snake

Inspired by "Neural Networks Fail to Learn Periodic Functions and How to Fix It".

This is a PyTorch implementation of the snake activation function from the paper - or at least I think it is, no affiliation with the authors, use at your own risk, etc., etc.

A few variations of the function are discussed in the paper, this package implements:

Installation

From the main repo folder, run python setup.py install

Usage

Fairly easy really from snake.activations import Snake. The Snake constructor (code here) has an optional learnable parameter alpha which defaults to 1. The authors of the paper find values between 5 and 50 work quite well for "known-periodic" data, while for better results with non-periodic data, you should choose a small value like 0.2. The constructor also takes an alpha_learnable parameter which defaults to True, so that you can disable "learnability" if your experiments so require.

Sample code

There's a notebook, still quite rough - example.ipynb.

Acknowledgements

This code probably wouldn't have gotten written if it hadn't been for Alexandra Deis and her excellent article .

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

torch-snake-0.0.1.tar.gz (2.8 kB view hashes)

Uploaded Source

Built Distributions

torch_snake-0.0.1-py3.6.egg (4.7 kB view hashes)

Uploaded Source

torch_snake-0.0.1-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

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