Metadata-Version: 2.4
Name: mixers
Version: 0.0.13
Summary: The unofficial implementation of MLP Mixer by Tolstikhin, Houlsby, Kolesnikov, Beyer et all based on the official JAX implementation.
Author-email: Taha Shieenavaz <tahashieenavaz@gmail.com>
License: MIT License
        
        Copyright (c) 2026 Taha Shieenavaz
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/tahashieenavaz/mixers
Project-URL: Repository, https://github.com/tahashieenavaz/mixers
Project-URL: Documentation, https://github.com/tahashieenavaz/mixers#readme
Keywords: mlp,mixer,image classification
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: torch
Requires-Dist: einops
Dynamic: license-file

# MLP Mixer

An unofficial PyTorch implementation of the MLP-Mixer architecture proposed by *Tolstikhin et al.*, based on the official JAX implementation.

This package provides a simple and flexible interface for experimenting with all-MLP vision models.

## Features

* PyTorch implementation of MLP-Mixer
* Simple and customizable architecture
* Lightweight and easy to integrate

## Installation

You can install this package using pip by running the following command:

```
pip install mixers
```

## Usage

Build your own mixer:

```py
import torch
from mixers.modules import MLPMixer

images = torch.randn(1, 3, 224, 224)

classifier = MLPMixer(
        num_classes = 10,
        num_blocks = 5,
        hidden_dimension = 512,
        tokens_mlp_dimension = 128,
        channels_mlp_dimension = 128,
        patch_size = 16,
        image_size = 224
)

print(classifier(images))  # torch.Size([1, 10])
```

Use predefined, paper mentioned, mixers: 

```py
from mixers import BaseMixer16, BaseMixer32
from mixers import SmallMixer16, SmallMixer32
from mixers import LargeMixer16, LargeMixer32
from mixers import HugeMixer14

model = HugeMixer14(image_size=224, num_classes=10)

train_model(model)
```

## Parameters

* `num_classes`: Number of output classes
* `num_blocks`: Number of mixer layers
* `hidden_dimension`: Embedding dimension
* `tokens_mlp_dimension`: Token-mixing MLP size
* `channels_mlp_dimension`: Channel-mixing MLP size
* `patch_size`: Size of image patches
* `image_size`: Input image resolution

## Reference

Paper: http://arxiv.org/abs/2105.01601

## Citation

```bibtex
@misc{2105.01601,
	Title = {MLP-Mixer: An all-MLP Architecture for Vision},
	Author = {Ilya Tolstikhin and Neil Houlsby and Alexander Kolesnikov and Lucas Beyer and Xiaohua Zhai and Thomas Unterthiner and Jessica Yung and Andreas Steiner and Daniel Keysers and Jakob Uszkoreit and Mario Lucic and Alexey Dosovitskiy},
	Year = {2021},
	Eprint = {arXiv:2105.01601},
}
```

## License

MIT License
