Rational Activations
Project description
Rational Activations - Learnable Rational Activation Functions
First introduce as PAU in Padé Activation Units: End-to-end Learning of Activation Functions in Deep Neural Network.
1. About Rational Activation Functions
Rational Activations are a novel learnable activation functions. Rationals encode activation functions as rational functions, trainable in an end-to-end fashion using backpropagation and can be seemingless integrated into any neural network in the same way as common activation functions (e.g. ReLU).
Rationals: Beyond known Activation Functions
Rational can approximate any known activation function arbitrarily well (cf. Padé Activation Units: End-to-end Learning of Flexible Activation Functions in Deep Networks): (*the dashed lines represent the rational approximation of every function)
Rational are made to be optimized by the gradient descent, and can discover good properties of activation functions after learning (cf Recurrent Rational Networks):
Rationals evaluation on different tasks
-
They were first applied (as Padé Activation Units) to Supervised Learning (image classification) in Padé Activation Units:....
:octocat: See rational_sl github repo
Rational matches or outperforms common activations in terms of predictive performance and training time. And, therefore relieves the network designer of having to commit to a potentially underperforming choice.
- Recurrent Rational Functions have then been introduced in Recurrent Rational Networks, and both Rational and Recurrent Rational Networks are evaluated on RL Tasks. :octocat: See rational_rl github repo
2. Dependencies
We support MxNet, Keras, and PyTorch. Instructions for MxNet can be found here. Instructions for Keras here. The following README instructions assume that you want to use rational activations in PyTorch.
PyTorch>=1.4.0
CUDA>=10.2
3. Installation
To install the rational_activations module, you can use pip, but:
:bangbang: You should be careful about the CUDA version running on your machine.
To get your CUDA version:
import torch
torch.version.cuda
For non TensorFlow and MXNet users, or if the command bellow don't work the package listed bellow don't work on your machine:
TensorFlow or MXNet (or PyTorch not CUDA optimized)
pip3 install -U pip wheel
pip3 install torch rational_activations
If you want a CUDA optimized version:
For your corresponding version of CUDA, please use one of the following command blocks:
CUDA 10.2 & PyTorch 1.7.1 (default one)
pip3 install -U pip wheel
pip3 install torch rational_activations_cu102
CUDA 11.0 & PyTorch 1.7.1 (default one)
Python3.6
pip3 install -U pip wheel
pip3 install torch==1.7.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install rational_activations_cu110
CUDA 11.0 & PyTorch 1.8.1 (latest one)
Python3.6
pip3 install -U pip wheel
pip3 install torch==1.8.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install https://github.com/ml-research/rational_activations/blob/master/wheelhouse/torch1.8.1/cuda-11.0/rational_activations_cu110-0.2.0-cp36-cp36m-manylinux2014_x86_64.whl?raw=true
Python3.7
pip3 install -U pip wheel
pip3 install torch==1.8.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install https://github.com/ml-research/rational_activations/blob/master/wheelhouse/torch1.8.1/cuda-11.0/rational_activations_cu110-0.2.0-cp37-cp37m-manylinux2014_x86_64.whl?raw=true
Python3.8
pip3 install -U pip wheel
pip3 install torch==1.8.1+cu110 -f https://download.pytorch.org/whl/torch_stable.html
pip3 install https://github.com/ml-research/rational_activations/blob/master/wheelhouse/torch1.8.1/cuda-11.0/rational_activations_cu110-0.2.0-cp38-cp38-manylinux2014_x86_64.whl?raw=true
Other CUDA/Pytorch
You can find other wheels at this address, download a raw version and install it via pip3 install rational_activations*.whl
.
For any other combinaison of python, please install from source:
pip3 install airspeed
git clone https://github.com/ml-research/rational_activations.git
cd rational_activations
python3 setup.py install --user
If you encounter any trouble installing rational, please contact this person.
4. Using Rational in Neural Networks
Rational can be integrated in the same way as any other common activation function.
import torch
from rational.torch import Rational
model = torch.nn.Sequential(
torch.nn.Linear(D_in, H),
Rational(), # e.g. instead of torch.nn.ReLU()
torch.nn.Linear(H, D_out),
)
Please also check the documentation :notebook_with_decorative_cover:
5. Cite Us in your paper
@inproceedings{molina2019pade,
title={Pad{\'e} Activation Units: End-to-end Learning of Flexible Activation Functions in Deep Networks},
author={Molina, Alejandro and Schramowski, Patrick and Kersting, Kristian},
booktitle={International Conference on Learning Representations},
year={2019}
}
@article{delfosse2021recurrent,
title={Recurrent Rational Networks},
author={Delfosse, Quentin and Schramowski, Patrick and Molina, Alejandro and Kersting, Kristian},
journal={arXiv preprint arXiv:2102.09407},
year={2021}
}
@misc{delfosse2020rationals,
author = {Delfosse, Quentin and Schramowski, Patrick and Molina, Alejandro and Beck, Nils and Hsu, Ting-Yu and Kashef, Yasien and Rüling-Cachay, Salva and Zimmermann, Julius},
title = {Rational Activation functions},
year = {2020},
publisher = {GitHub},
journal = {GitHub repository},
howpublished={\url{https://github.com/ml-research/rational_activations}}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
File details
Details for the file rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 031bebd1be7f4d9d2aac220f25af48fb61ac4f09aec3cdaca38fb264c2ea88e4 |
|
MD5 | 5540731f0bb32fc96e019ecc20c49155 |
|
BLAKE2b-256 | f3cea011fff8ee30ddcd1a656883cf9ba366aff925c0bc35af796e4d3f0e9e1c |
File details
Details for the file rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c159776186a7309f0adf164ae2704bb2432d74cd518e231d505dd4dbd53b1ec |
|
MD5 | 3508e3489f43ec28ea48bca48cc0c223 |
|
BLAKE2b-256 | ea639ab1704691099173b8c166dc4b5777447d0738e6e57598da545a0aa7a2bd |
File details
Details for the file rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bc02fe89b8c829a56dde8a871d58736e508f1d0b72e1c7e24eefbdfe431dae0 |
|
MD5 | a9ba8fecf18a4d3f88226aaa4345062d |
|
BLAKE2b-256 | 3a309277fe028ad54a49a1163e1b23859b2bdf8c5b53753badb281aacabaa7eb |
File details
Details for the file rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbe10d67a9e657b0c05d89bf499f9377d57e14fa5fa399c0da87ff2a5ea5f683 |
|
MD5 | 30ddff72ba30c4fbab847166ad157a66 |
|
BLAKE2b-256 | b64f8a16949c312d28927c6b25e33a8e1dc9e627106635dd425672554072d4fc |
File details
Details for the file rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ace6fc63486453fdc2470ea0b3665635dc653c871133a1292b4bd2555bfb0b52 |
|
MD5 | 68e86f51d442629a8377d2c6ef7251a7 |
|
BLAKE2b-256 | d8885286d5b1ed0dd49ca3df170ca855c44bee4524089eb27563603f25b8d297 |
File details
Details for the file rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.8, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 143ce6cac2bc679ed4ec13cd6af5cc7d947cabf214226cc08ad970d8d0aeae55 |
|
MD5 | 970bb77198b9851c4e5746aee46d3774 |
|
BLAKE2b-256 | 1ae9a61d38d19533cfbb9bfd4e9e1b2a3308db9a26e950d60cccb9e82902c0c4 |
File details
Details for the file rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.7m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 056f4a799f972a5724ecc14c3aa26a4e3460f0dda0f6386e27516ad1fd81ad5d |
|
MD5 | 4a83d15116dcb24866fc1783ce385316 |
|
BLAKE2b-256 | 5489b9247eb0f5ef106329d66ea97cee18b98254c32164a94365e6038b139d32 |
File details
Details for the file rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
.
File metadata
- Download URL: rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 4.3 MB
- Tags: CPython 3.6m, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.25.1 setuptools/50.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063632e6f5c83b152ec4d5d7e105281a50280f01fecb6091f55aae0c617c3501 |
|
MD5 | 46361f51d2ebfa681855182316981a7d |
|
BLAKE2b-256 | 73684b6fc7d7b3511e85043d240454d237c924d1e0cd4346e7bcbd5c21b38a34 |