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.12.tar.gz (8.9 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.12-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mixers-0.0.12.tar.gz
  • Upload date:
  • Size: 8.9 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.12.tar.gz
Algorithm Hash digest
SHA256 290160ffe67a6211bfbc4787df2c2118a141624c8acdeec4e1b1ef104707b7d1
MD5 83f865a6ee26c76e1e28ac6b350bb0c3
BLAKE2b-256 8c93f1889b2194433929fddc0ef45ec616640f7e8f67d6f0de7e4782701e71a6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mixers-0.0.12-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.12-py3-none-any.whl
Algorithm Hash digest
SHA256 2d32d140d90d746cfb62b5fe573c6d373956bb7c28f7114a3f589703aa0176e9
MD5 f57cbc056215b89ae30d5954c1972def
BLAKE2b-256 d2f946d4b49f14783b6529bbef15d3a9461dc64624dec568771713ca795b075c

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