Code Monkey home page Code Monkey logo

mlpmixer-jax2tf's Introduction

MLPMixer-jax2tf


Example usage.

This repository hosts code for converting the original MLP-Mixer models [1] (JAX) to TensorFlow. The converted models are hosted on TensorFlow Hub and can be found here: https://tfhub.dev/sayakpaul/collections/mlp-mixer/1.

Note that it's a requirement to use TensorFlow 2.6 or greater to use the converted models.

Several model variants are available:

SAM [2] pre-trained (these models were pre-trained on ImageNet-1k):

ImageNet-1k fine-tuned:

ImageNet-21k pre-trained:

For more details on the training protocols, please follow [1, 3].

The original model classes and weights [4] were converted using the jax2tf tool [5]. For details on the conversion process, please refer to the conversion.ipynb notebook.

I independently validated two models on the ImageNet-1k validation set. The table below reports the top-1 accuracies along with their respective logs from tensorboard.dev.

Model Top-1 Accuracy tb.dev link
B-16 fine-tuned on
ImageNet-1k
75.31% Link
B-16 pre-trained on
ImageNet-1k using SAM
75.58% Link

Here is a tensorboard.dev run that logs fine-tuning results (using this model) for the Flowers dataset.

Other notebooks

  • classification.ipynb: Shows how to load a Vision Transformer model from TensorFlow Hub and run image classification.
  • fine-tune.ipynb: Shows how to fine-tune a Vision Transformer model from TensorFlow Hub on the tf_flowers dataset.

References

[1] MLP-Mixer: An all-MLP Architecture for Vision by Tolstikhin et al.

[2] Sharpness-Aware Minimization for Efficiently Improving Generalization by Foret et al.

[3] When Vision Transformers Outperform ResNets without Pretraining or Strong Data Augmentations by Chen et al.

[4] Vision Transformer GitHub

[5] jax2tf tool

Acknowledgements

Thanks to the ML-GDE program for providing GCP Credit support that helped me execute the experiments for this project.

mlpmixer-jax2tf's People

Contributors

sayakpaul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.