Last active
April 25, 2018 09:10
-
-
Save johnolafenwa/4d99b03ef26a47a052e26c6551e04399 to your computer and use it in GitHub Desktop.
This file contains 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
# A single resnet module consisting of 1 x 1 conv - 3 x 3 conv and 1 x 1 conv | |
def resnet_module(x, filters, pool=False): | |
res = x | |
stride = 1 | |
if pool: | |
stride = 2 | |
res = Conv2D(filters, kernel_size=1, strides=2, padding="same")(res) | |
res = BatchNormalization()(res) | |
x = Conv2D(int(filters / 4), kernel_size=1, strides=stride, padding="same")(x) | |
x = BatchNormalization()(x) | |
x = Activation("relu")(x) | |
x = Conv2D(int(filters / 4), kernel_size=3, strides=1, padding="same")(x) | |
x = BatchNormalization()(x) | |
x = Activation("relu")(x) | |
x = Conv2D(filters, kernel_size=1, strides=1, padding="same")(x) | |
x = BatchNormalization()(x) | |
x = add([x, res]) | |
x = Activation("relu")(x) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment