JAX/Flax implementation of rational neural nets
Project description
rationalnets
JAX/Flax implementation of rational neural nets.
Original
- paper: Nicolas Boullé, Yuji Nakatsukasa, and Alex Townsend, Rational neural networks, arXiv preprint arXiv:2004.01902 (2020).
- github: https://github.com/NBoulle/RationalNets
Installation
rationalnets
can be installed with pip with the following command:
python -m pip install rationalnets
Or you can install the latest version with the following command:
python -m pip install git+https://github.com/yonesuke/RationalNets.git
QuickStart
Rational activation function
import jax.numpy as jnp
from jax import random
from rationalnets import RationalMLP
xs = jnp.arange(-2.0, 2.0, 0.01)
act = Rational()
params = model.init(random.PRNGKey(0), xs)
ys = act.apply(params, xs) # values of rational activation function for -2.0 ~ 2.0
Rational MLP
import jax.numpy as jnp
from jax import random
from rationalnets import RationalMLP
model = RationalMLP([12, 8, 4])
batch = jnp.ones((32, 10))
variables = model.init(random.PRNGKey(0), batch)
output = model.apply(variables, batch)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rationalnets-0.1.0.tar.gz
(2.9 kB
view details)
Built Distribution
File details
Details for the file rationalnets-0.1.0.tar.gz
.
File metadata
- Download URL: rationalnets-0.1.0.tar.gz
- Upload date:
- Size: 2.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f3af6f0772b60825781c33aedd1eaee9cc76d05676b1943bbc2b54882adbafc |
|
MD5 | 936e12a8c7a99a7223e003155685d92c |
|
BLAKE2b-256 | 52edf37a509e4657005ea3eb2800c4b3755f3e6ecdb3e322a871612fcd2149fc |
File details
Details for the file rationalnets-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: rationalnets-0.1.0-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc6c2babd398698bc56bf45acc2a175da4cd09fff6da6e6739342f68cc222fdd |
|
MD5 | 93ffc56465074b6ddebdc0da8901fef4 |
|
BLAKE2b-256 | 81a2f76785a9bd86427e5e93bf35e21520b44b20eec8405c052fef7d9ca25921 |