alrelu-torch
PyPI-installable PyTorch package for the ALReLU activation with 2 variants:
ALReLU(default): fixedalpha=0.01TrainableALReLU: trainablealphaparameter
Formula:
ALReLU(x, alpha) = max(abs(alpha * x), x)
Reference
ALReLU paper:
ALReLU: A different approach on Leaky ReLU activation function to improve Neural Networks Performance
https://arxiv.org/abs/2012.07564
Installation
pip install alrelu-torch
From source:
pip install .
Training Examples (MNIST)
Scripts:
- Keras + TensorFlow:
scripts/train_mnist_keras_tf.py - PyTorch:
scripts/train_mnist_torch.py
Direct links:
- https://github.com/MStamatis/ALReLU/blob/main/scripts/train_mnist_keras_tf.py
- https://github.com/MStamatis/ALReLU/blob/main/scripts/train_mnist_torch.py
Run commands (from repo root):
# Keras + TensorFlow
python scripts/train_mnist_keras_tf.py --epochs 5 --variant fixed --alpha 0.01
python scripts/train_mnist_keras_tf.py --epochs 5 --variant learnable --alpha 0.01
# PyTorch
python scripts/train_mnist_torch.py --epochs 5 --variant fixed --alpha 0.01
python scripts/train_mnist_torch.py --epochs 5 --variant learnable --alpha 0.01
Usage
1) Functional API
import torch
from alrelu_torch import alrelu
x = torch.tensor([-2.0, -1.0, 0.0, 1.0, 2.0])
y = alrelu(x) # alpha=0.01 by default
2) Fixed module
import torch.nn as nn
from alrelu_torch import ALReLU
model = nn.Sequential(
nn.Linear(32, 64),
ALReLU(alpha=0.01),
nn.Linear(64, 10),
)
3) Trainable alpha module
import torch.nn as nn
from alrelu_torch import TrainableALReLU
model = nn.Sequential(
nn.Linear(32, 64),
TrainableALReLU(alpha_init=0.01, non_negative=True),
nn.Linear(64, 10),
)
Development
Install dev tools:
pip install -e .[dev]
Run tests:
pytest
Build package:
python -m build
Metadata
Release files for alrelu-torch 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| alrelu_torch-0.1.2.tar.gz | 4.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| alrelu_torch-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.0 kB
Release files / alrelu_torch-0.1.2.tar.gz
| Download URL | alrelu_torch-0.1.2.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
401c3f04356144f81d3e309eb2bfd47c27bd1ca16e22c9aff30d75b348cd8987
|
|
BLAKE2b-256 checksum How to use checksums |
8aa04ce2d43490e9ae09b9cfb07fc756d5ae8b59a29262b1a093c0429e7a84f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency logRelease files / alrelu_torch-0.1.2-py3-none-any.whl
| Download URL | alrelu_torch-0.1.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
701213769077113047566b90fc5c49f965b547e538035c03045aa1b7c043244a
|
|
BLAKE2b-256 checksum How to use checksums |
7a384a9bde5b3d44d60192d5a8d0f8dcaafc2cc4b19c962ac39dc145c41cc0f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 22, 2026.
Transparency log