Created
June 12, 2021 06:45
-
-
Save shubham0204/eade500d54be843b17c42d35c9740ea5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Token Mixing MLPs : Allow communication within patches. | |
def token_mixing( x , token_mixing_mlp_dims ): | |
# x is a tensor of shape ( batch_size , num_patches , channels ) | |
x = tf.keras.layers.LayerNormalization( epsilon=1e-6 )( x ) | |
x = tf.keras.layers.Permute( dims=[ 2 , 1 ] )( x ) | |
# After transposition, shape of x -> ( batch_size , channels , num_patches ) | |
x = mlp( x , token_mixing_mlp_dims ) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment