Skip to content

Instantly share code, notes, and snippets.

@siddharthganjoo
Created September 4, 2021 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siddharthganjoo/3922c2a13852c3f1c638649dcf099a3b to your computer and use it in GitHub Desktop.
Save siddharthganjoo/3922c2a13852c3f1c638649dcf099a3b to your computer and use it in GitHub Desktop.
from tensorflow.keras.layers import Conv2D, MaxPooling2D, Input, Dense, Activation, ReLU, Flatten, Dropout, BatchNormalization
from tensorflow.keras.models import Model
X=Input(shape=[28,28,1])
x=Conv2D(16, (3,3), strides=1, padding="same", name="conv1")(X)
x=BatchNormalization(momentum=0.1, epsilon=1e-5, gamma_initializer="uniform", name="batch1")(x)
x=Activation('relu',name='relu1')(x)
x=Dropout(0.1)(x)
x=Conv2D(32, (3,3), strides=1, padding="same", name="conv2")(x)
x=BatchNormalization(momentum=0.15, epsilon=1e-5, gamma_initializer="uniform", name="batch2")(x)
x=Activation('relu',name='relu2')(x)
x=Dropout(0.15)(x)
x=MaxPooling2D(pool_size=2, strides=2, padding="same", name="max2")(x)
x=Conv2D(64, (5,5), strides=1, padding ="same", name="conv3")(x)
x=BatchNormalization(momentum=0.17, epsilon=1e-5, gamma_initializer="uniform", name="batch3")(x)
x=Activation('relu', name="relu3")(x)
x=MaxPooling2D(pool_size=2, strides=2, padding="same", name="max3")(x)
x=Conv2D(64, (5,5), strides=1, padding="same", name="conv4")(x)
x=BatchNormalization(momentum=0.15, epsilon=1e-5, gamma_initializer="uniform", name="batch4")(x)
x=Activation('relu', name="relu4")(x)
x=Dropout(0.17)(x)
x=Conv2D(32, (3,3), strides=1, padding="same", name="conv5")(x)
x=BatchNormalization(momentum=0.15, epsilon=1e-5, gamma_initializer="uniform", name="batch5")(x)
x=Activation('relu', name='relu5')(x)
#x=MaxPooling2D(pool_size=2, strides=2, padding="same", name="max5")(x)
x=Dropout(0.2)(x)
x=Conv2D(16, (3,3), strides=1, padding="same", name="conv6")(x)
x=BatchNormalization(momentum=0.15, epsilon=1e-5, gamma_initializer="uniform", name="batch6" )(x)
x=Activation('relu', name="relu6")(x)
x=Dropout(0.05)(x)
#x=MaxPooling2D(pool_size=2, strides=2, padding="same", name="max6")(x)
x=Flatten()(x)
x=Dense(50, name="Dense1")(x)
x=Activation('relu', name='relu7')(x)
x=Dropout(0.05)(x)
x=Dense(25, name="Dense2")(x)
x=Activation('relu', name='relu8')(x)
x=Dropout(0.03)(x)
x=Dense(10, name="Dense3")(x)
x=Activation('softmax')(x)
model=Model(inputs=X, outputs=x)
print(model.summary())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment