Last active
December 15, 2023 03:36
-
-
Save mohdsanadzakirizvi/63b8ab2e0b3310f6d16cfb6f43548ff6 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
from keras.models import Sequential | |
from keras.layers import Conv2D, MaxPool2D, Flatten, Dense, InputLayer, BatchNormalization, Dropout | |
# build a sequential model | |
model = Sequential() | |
model.add(InputLayer(input_shape=(224, 224, 3))) | |
# 1st conv block | |
model.add(Conv2D(25, (5, 5), activation='relu', strides=(1, 1), padding='same')) | |
model.add(MaxPool2D(pool_size=(2, 2), padding='same')) | |
# 2nd conv block | |
model.add(Conv2D(50, (5, 5), activation='relu', strides=(2, 2), padding='same')) | |
model.add(MaxPool2D(pool_size=(2, 2), padding='same')) | |
model.add(BatchNormalization()) | |
# 3rd conv block | |
model.add(Conv2D(70, (3, 3), activation='relu', strides=(2, 2), padding='same')) | |
model.add(MaxPool2D(pool_size=(2, 2), padding='valid')) | |
model.add(BatchNormalization()) | |
# ANN block | |
model.add(Flatten()) | |
model.add(Dense(units=100, activation='relu')) | |
model.add(Dense(units=100, activation='relu')) | |
model.add(Dropout(0.25)) | |
# output layer | |
model.add(Dense(units=10, activation='softmax')) | |
# compile model | |
model.compile(loss='categorical_crossentropy', optimizer="adam", metrics=['accuracy']) | |
# fit on data for 30 epochs | |
model.fit_generator(train, epochs=30, validation_data=val) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment