Skip to main content

ArXiv Badge PWC

Logo

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): rational_approx (*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): rational_properties

Rationals evaluation on different tasks

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. rl_scores :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:

‼️ 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 📔

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

Metadata

Release files for rational-activations 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for rational-activations 0.2.1
File Actions
rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64 Details for rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Total release size: 34.4 MB

Release files / rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
031bebd1be7f4d9d2aac220f25af48fb61ac4f09aec3cdaca38fb264c2ea88e4
BLAKE2b-256 checksum
How to use checksums
f3cea011fff8ee30ddcd1a656883cf9ba366aff925c0bc35af796e4d3f0e9e1c
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
6c159776186a7309f0adf164ae2704bb2432d74cd518e231d505dd4dbd53b1ec
BLAKE2b-256 checksum
How to use checksums
ea639ab1704691099173b8c166dc4b5777447d0738e6e57598da545a0aa7a2bd
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2bc02fe89b8c829a56dde8a871d58736e508f1d0b72e1c7e24eefbdfe431dae0
BLAKE2b-256 checksum
How to use checksums
3a309277fe028ad54a49a1163e1b23859b2bdf8c5b53753badb281aacabaa7eb
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
cbe10d67a9e657b0c05d89bf499f9377d57e14fa5fa399c0da87ff2a5ea5f683
BLAKE2b-256 checksum
How to use checksums
b64f8a16949c312d28927c6b25e33a8e1dc9e627106635dd425672554072d4fc
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
ace6fc63486453fdc2470ea0b3665635dc653c871133a1292b4bd2555bfb0b52
BLAKE2b-256 checksum
How to use checksums
d8885286d5b1ed0dd49ca3df170ca855c44bee4524089eb27563603f25b8d297
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
143ce6cac2bc679ed4ec13cd6af5cc7d947cabf214226cc08ad970d8d0aeae55
BLAKE2b-256 checksum
How to use checksums
1ae9a61d38d19533cfbb9bfd4e9e1b2a3308db9a26e950d60cccb9e82902c0c4
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
056f4a799f972a5724ecc14c3aa26a4e3460f0dda0f6386e27516ad1fd81ad5d
BLAKE2b-256 checksum
How to use checksums
5489b9247eb0f5ef106329d66ea97cee18b98254c32164a94365e6038b139d32
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL rational_activations-0.2.1-1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 4.3 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
063632e6f5c83b152ec4d5d7e105281a50280f01fecb6091f55aae0c617c3501
BLAKE2b-256 checksum
How to use checksums
73684b6fc7d7b3511e85043d240454d237c924d1e0cd4346e7bcbd5c21b38a34
Upload date
Uploaded using Trusted Publishing?
What is 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

Security for rational-activations 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page