Skip to main content

ALReLU activation package for PyTorch with fixed and trainable alpha variants.

Project description

alrelu-torch

PyPI-installable PyTorch package for the ALReLU activation with 2 variants:

  1. ALReLU (default): fixed alpha=0.01
  2. TrainableALReLU: trainable alpha parameter

Formula:

ALReLU(x, alpha) = max(abs(alpha * x), x)

Installation

After publishing:

pip install alrelu-torch

From source:

pip install .

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

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

alrelu_torch-0.1.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

alrelu_torch-0.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file alrelu_torch-0.1.0.tar.gz.

File metadata

  • Download URL: alrelu_torch-0.1.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alrelu_torch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f69435bc3252149df43de90d54e46e0fc8137fb998654b7a09f75e85a053c4d6
MD5 cec26baf5acdc638ee5a5c81e2661d8c
BLAKE2b-256 c60c1b1d8ca0903af3786dfb315c973ecef8c300ea62656591b027919dd7c7f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for alrelu_torch-0.1.0.tar.gz:

Publisher: publish-torch.yml on MStamatis/ALReLU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file alrelu_torch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: alrelu_torch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for alrelu_torch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f573b4c5111105c28c5cb285abdc171c36d267c304f548d400d708099a9f5e4a
MD5 5321264f81c1ab4c81abbf8ba3f8a84b
BLAKE2b-256 cdb9cbc6b4a562a0c768dc72f1ff7fc5284d448992c0ddf3c50cf74b5aadf0b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for alrelu_torch-0.1.0-py3-none-any.whl:

Publisher: publish-torch.yml on MStamatis/ALReLU

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page