Metadata-Version: 2.4
Name: torchlab-pytorch
Version: 0.1.1
Summary: A research-oriented collection of PyTorch activation functions, loss functions, and optimizers.
Author: Dilyan Grigorov
License-Expression: MIT
Project-URL: Homepage, https://github.com/didogrigorov/torchlab
Project-URL: Repository, https://github.com/didogrigorov/torchlab
Project-URL: Issues, https://github.com/didogrigorov/torchlab/issues
Keywords: pytorch,deep-learning,machine-learning,activation-functions,loss-functions,optimizers
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch>=2.0
Provides-Extra: dev
Requires-Dist: pytest>=8; extra == "dev"
Requires-Dist: build>=1.2; extra == "dev"
Requires-Dist: twine>=5; extra == "dev"
Requires-Dist: numpy>=1.26; extra == "dev"
Dynamic: license-file

# 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

```text
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:

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

Run the test suite:

```bash
pytest -q
```

## Basic usage

```python
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:

```python
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:

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

For a clean wheel test:

```bash
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`.
