Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from keras.layers import Conv2D, Activation, MaxPooling2D, Flatten, Dense
- from keras.layers import Input, ZeroPadding2D
- from keras.layers import Dropout, BatchNormalization
- from keras.models import Model
- from keras.utils import plot_model
- input_shape=(64, 64, 3)
- # Define the input placeholder as a tensor with shape input_shape.
- X_input = Input(input_shape)
- # Zero-Padding: pads the border of X_input with zeroes
- X = ZeroPadding2D((3, 3))(X_input)
- # CONV -> BN -> RELU
- X = Conv2D(filters=32, kernel_size=(7, 7), strides=(1, 1), padding='same', name='conv0')(X)
- X = BatchNormalization(axis=3, name='bn0')(X)
- X = Activation('relu')(X)
- # MAXPOOL
- # padding: valid (default) or same
- X = MaxPooling2D(pool_size=(2, 2), strides=(2,2), padding='valid', name='max_pool1')(X)
- # CONV -> RELU
- X = Conv2D(filters=64, kernel_size=(3, 3), strides=(1, 1), padding='same', activation='relu', name='conv1')(X)
- # MAXPOOL
- # strides default to pool_size
- X = MaxPooling2D(pool_size=(2, 2), name='max_pool2')(X)
- # Flatten X: convert X to a vector with shape (batch_size, h * w * c)
- X = Flatten()(X)
- # Fully connected layer
- X = Dense(units=512, activation='relu', name='fc0')(X)
- X = Dropout(0.25)(X)
- # softmax -> multi-class classification, units = num_classes
- # sigmoid -> binary classification, units = 1
- X = Dense(units=1, activation='sigmoid', name='fc1')(X)
- # Create model
- model = Model(inputs=X_input, outputs=X, name='Model')
- model.summary()
- plot_model(model, show_shapes=True, show_layer_names=True, to_file='model.png')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement