Giter VIP home page Giter VIP logo

convmixer's Introduction

convmixer

Conv-Mixer custom layer implementation in Tensorflow/Keras. ConvMixer is introduced in ICLR 2022 submission "Patches Are All You Need?" by Asher Trockman and Zico Kolter.

Feel free to make pull requests & suggestions. 😀

How to Use

Example code is provided in example.py file.

First layer should be patcher, so patches can be extracted

inputs = tf.keras.layers.Input((w, h, c))
patches = Patcher(filters = 128, patch_size = (4, 4))(inputs)

Conv mixer layers are added sequentially with a certain "depth"

t = patches
for i in range(depth):
    t = ConvMixer(256, (3, 3), (1, 1), "gelu")(t)

Then the features are ready to feed other layers. In this example i used Global Average Pooling and FC to perform classsification.

final_conv = tf.keras.layers.Conv2D(n_classes, 
                                    kernel_size=1, 
                                    strides=1, 
                                    padding="same",
                                    activation="relu")(t)
outputs = tf.keras.layers.GlobalAveragePooling2D()(final_conv)
outputs = tf.keras.layers.Dense(n_classes, "softmax")(outputs)
model = tf.keras.Model(inputs, outputs)

convmixer's People

Contributors

arthurgsf avatar

Stargazers

Lucas Araújo avatar  avatar  avatar Weverton Trindade avatar

Watchers

 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.