Skip to main content

The unofficial implementation of MLP Mixer by Tolstikhin, Houlsby, Kolesnikov, Beyer et all based on the official JAX implementation.

Project description

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

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

mixers-0.0.13.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

mixers-0.0.13-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

Details for the file mixers-0.0.13.tar.gz.

File metadata

  • Download URL: mixers-0.0.13.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mixers-0.0.13.tar.gz
Algorithm Hash digest
SHA256 6ce53c1246c7a83cb1147a7e70d5b17f374dbaeb85715658fa1d1c115c37bc48
MD5 084342630d83689d0218c54f0e30d9ab
BLAKE2b-256 384b501482cf5b500e1ee16d0eb362fce848f66f819489768449667705f74244

See more details on using hashes here.

File details

Details for the file mixers-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: mixers-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mixers-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 f78f4718765dc3d421e12d11d825b98a47c38112a48fea57715440635415b7ed
MD5 7e0101653e0a8a2cd4e3b2f58305dba5
BLAKE2b-256 59ae898b663ee99c5bd2d0e601e1eebc004009f2325820baef1fef9d4138649f

See more details on using hashes here.

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