Advertisement
Guest User

Custom CNN

a guest
Mar 19th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. def HappyModel(input_shape):
  2.   # Define the input placeholder as a tensor with shape input_shape.
  3.   X_input = Input(input_shape, name='input')
  4.  
  5.   # Zero-Padding: pads the border of X_input with zeroes
  6.   X = ZeroPadding2D((3, 3), name='padding')(X_input)
  7.  
  8.   # CONV -> BN -> RELU Block applied to X
  9.   X = Conv2D(32, (7, 7), strides=(1, 1), name='conv1')(X)
  10.   X = BatchNormalization(axis=3, name='bn1')(X)
  11.   X = Activation('relu', name='relu1')(X)
  12.  
  13.   # MAXPOOL
  14.   X = MaxPooling2D((2, 2), name='max_pool1')(X)
  15.  
  16.   # FLATTEN X (means convert it to a vector) + FULLYCONNECTED
  17.   X = Flatten(name='flatten1')(X)
  18.   X = Dense(1, activation='sigmoid', name='fc1-output')(X)
  19.  
  20.   # Create model. This creates our Keras model instance, you’ll use this instance
  21.   # to train/test the model.
  22.   model = Model(inputs=X_input, outputs=X, name='HappyModel')
  23.   return model
  24.  
  25. happyModel = HappyModel(X_train.shape[1:])
  26. happyModel.summary()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement