Skip to content

Instantly share code, notes, and snippets.

@JituShinde77
Created February 29, 2020 16:00
Show Gist options
  • Save JituShinde77/59f757d8df101a8445aa8f45b09e51b8 to your computer and use it in GitHub Desktop.
Save JituShinde77/59f757d8df101a8445aa8f45b09e51b8 to your computer and use it in GitHub Desktop.
# Swish Layer
def SwishMod(inp, filter_size = 3, stride = 2, padding ='same', batchNormalize = True, alpha = 0.2):
"""
This Function perform swish layer operation
Take input image perform conv operatin perform dot on input and conv output(multiply operation on both) return result element wise multimplication
Filter are the channels in input images
Here input and output are the same shape if input (64, 64, 3) output also (64, 64,3)
"""
filters = list(inp.get_shape())[-1]
conv = Conv2D(filters, filter_size, padding = 'same', kernel_initializer=tf.keras.initializers.truncated_normal(stddev=.02))(inp)
conv = sigmoid(conv)
swished = tf.keras.layers.multiply([inp, conv])
#print (swished.shape)
return swished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment