Skip to main content

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:

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:

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

@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

Metadata

Release files for mixers 0.0.13

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

Source distribution (sdist)

Source distribution for mixers 0.0.13
File Size Uploaded Provenance Actions
mixers-0.0.13.tar.gz 8.8 kB Without provenance Details for mixers-0.0.13.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mixers 0.0.13
File Interpreter ABI Platform Actions
mixers-0.0.13-py3-none-any.whl Python 3 none any Details for mixers-0.0.13-py3-none-any.whl

Total release size: 17.5 kB

Release files / mixers-0.0.13.tar.gz

Download URL mixers-0.0.13.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6ce53c1246c7a83cb1147a7e70d5b17f374dbaeb85715658fa1d1c115c37bc48
BLAKE2b-256 checksum
How to use checksums
384b501482cf5b500e1ee16d0eb362fce848f66f819489768449667705f74244
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / mixers-0.0.13-py3-none-any.whl

Download URL mixers-0.0.13-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f78f4718765dc3d421e12d11d825b98a47c38112a48fea57715440635415b7ed
BLAKE2b-256 checksum
How to use checksums
59ae898b663ee99c5bd2d0e601e1eebc004009f2325820baef1fef9d4138649f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Security for mixers 0.0.13

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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