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
Built Distributions
File details
Details for the file torch-snake-0.0.1.tar.gz
.
File metadata
- Download URL: torch-snake-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a5d96633d74b2c9dc44631f866aabc699eb83d58fcbc1ea7e07781658d38ca5 |
|
MD5 | 34d71ad60bc498a1055d0432bdf927b9 |
|
BLAKE2b-256 | 95013289551fded3b1da353cdff53f2d83f87c6f64422f32571315f5f10a97a5 |
File details
Details for the file torch_snake-0.0.1-py3.6.egg
.
File metadata
- Download URL: torch_snake-0.0.1-py3.6.egg
- Upload date:
- Size: 4.7 kB
- Tags: Egg
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 973d211d03899d77f2bcaee176c351f1016ae5a28bf367c79030b69d121032b8 |
|
MD5 | 33c69866dd0e5257ac53ec1b99ec8ec4 |
|
BLAKE2b-256 | a1bb48e311efe62bb3ec6e08ac65adbe5b3af007b494057682007d7aaadbf549 |
File details
Details for the file torch_snake-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: torch_snake-0.0.1-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32b9f1efef2a139ce16e27cb77dc549f23eb8b6086b45071b0646738ec349ade |
|
MD5 | 0d38419bfde3de6fb10c276bf83d6083 |
|
BLAKE2b-256 | 9750b091873d4f7eb1e564383cc6e0af102dd95606c164cbeb000db519527049 |