Skip to content

Instantly share code, notes, and snippets.

@Rodio346
Created August 12, 2021 17:04
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 Rodio346/405411270252f2505292164ec2540e24 to your computer and use it in GitHub Desktop.
Save Rodio346/405411270252f2505292164ec2540e24 to your computer and use it in GitHub Desktop.
def CNNbuild(height, width, classes, channels):
model = Sequential()
inputShape = (height, width, channels)
chanDim = -1
if K.image_data_format() == 'channels_first':
inputShape = (channels, height, width)
model.add(Conv2D(32, (3,3), activation = 'relu', input_shape = inputShape))
model.add(MaxPooling2D(2,2))
model.add(BatchNormalization(axis = chanDim))
model.add(Conv2D(32, (3,3), activation = 'relu'))
model.add(MaxPooling2D(2,2))
model.add(BatchNormalization(axis = chanDim))
model.add(Conv2D(32, (3,3), activation = 'relu'))
model.add(MaxPooling2D(2,2))
model.add(BatchNormalization(axis = chanDim))
model.add(Flatten())
model.add(Dense(8, activation = 'relu'))
model.add(Dense(8, activation = 'relu'))
model.add(Dense(8, activation = 'relu'))
model.add(BatchNormalization(axis = chanDim))
model.add(Dropout(0.5))
model.add(Dense(classes, activation = 'softmax'))
return model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment