Skip to main content

TorchLab

TorchLab is a research-oriented PyTorch library collecting activation functions, loss functions, and optimization algorithms that are useful for experimentation with neural networks.

The project is intended to make a broad set of published methods available behind a consistent PyTorch-style API.

Package layout

src/
└── torchlab/
    ├── __init__.py
    ├── activations/
    │   ├── __init__.py
    │   ├── classic.py
    │   └── adaptive.py
    ├── losses/
    │   ├── __init__.py
    │   └── losses.py
    └── optimizers/
        ├── __init__.py
        └── optimizers.py

Installation for development

Create and activate a virtual environment, then install TorchLab in editable mode:

python -m pip install --upgrade pip
python -m pip install -e ".[dev]"

Run the test suite:

pytest -q

Basic usage

import torch

from torchlab.activations.classic import GELU
from torchlab.activations.adaptive import Swish
from torchlab.losses import DiceLoss
from torchlab.optimizers import Lion

x = torch.randn(8, 32)
y = GELU()(x)
z = Swish()(x)

print(y.shape, z.shape)

Optimizer example:

import torch
from torchlab.optimizers import Lion

model = torch.nn.Linear(10, 1)
optimizer = Lion(model.parameters(), lr=1e-4)

x = torch.randn(32, 10)
target = torch.randn(32, 1)

prediction = model(x)
loss = torch.nn.functional.mse_loss(prediction, target)

optimizer.zero_grad()
loss.backward()
optimizer.step()

Testing a source checkout

From the repository root:

python -m pip install -e ".[dev]"
pytest -q

For a clean wheel test:

python -m build
python -m twine check --strict dist/*
python -m pip install --force-reinstall dist/torchlab-*.whl

Documentation

Project documentation can be hosted with GitHub Pages from the docs/ directory.

Research-code note

TorchLab contains implementations of methods described in research literature. Some algorithms require special training-loop behavior, parameter constraints, or approximations. Consult the project documentation and mathematical audit before using unfamiliar methods in production.

License

TorchLab is released under the MIT License. See LICENSE.

Release files for torchlab-pytorch 0.1.1

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

Source distribution (sdist)

Source distribution for torchlab-pytorch 0.1.1
File Size Uploaded
torchlab_pytorch-0.1.1.tar.gz 59.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for torchlab-pytorch 0.1.1
File Interpreter ABI Platform
torchlab_pytorch-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 115.7 kB

Release files / torchlab_pytorch-0.1.1.tar.gz

Download URL torchlab_pytorch-0.1.1.tar.gz
Size 59.0 kB
Tags Source
SHA-256 checksum
How to use checksums
401ce218747fe4d465c70b4da9b3566ee73e522685c5993cc73b5821b88da9f2
BLAKE2b-256 checksum
How to use checksums
b570dc559b862a83bd4e048267629fb0aa848a773388e7f10168a45a716e0ec4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release files / torchlab_pytorch-0.1.1-py3-none-any.whl

Download URL torchlab_pytorch-0.1.1-py3-none-any.whl
Size 56.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7af68dc8092114d547fe1a6c45939c91dab4e580ba1cec7bbad5021b3f82230a
BLAKE2b-256 checksum
How to use checksums
0edc6d9697b272c3e84929aad1d740eed9ad03a932453224be61488af4abf04a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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