Created
June 17, 2022 14:24
-
-
Save SmiffyKMc/a5be5e8057e02f9014f683d116d77445 to your computer and use it in GitHub Desktop.
V2 of the CNN
This file contains hidden or 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
inputs = keras.Input(shape=(256, 256, 3)) | |
x = data_augmentation(inputs) | |
x = layers.Rescaling(1./255)(x) | |
x = layers.Conv2D(filters=32, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=64, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=128, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=256, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.MaxPooling2D(pool_size=2)(x) | |
x = layers.Conv2D(filters=256, kernel_size=3, activation=keras.activations.relu)(x) | |
x = layers.Flatten()(x) | |
x = layers.Dense(512, activation=keras.activations.relu)(x) | |
x = layers.Dropout(0.5)(x) | |
outputs = layers.Dense(1, activation=keras.activations.sigmoid)(x) | |
model = keras.Model(inputs, outputs) | |
model.compile(optimizer=keras.optimizers.RMSprop(), | |
loss=keras.losses.BinaryCrossentropy(), | |
metrics=["accuracy"]) | |
callbacks = [ | |
keras.callbacks.ModelCheckpoint( | |
filepath=f"{hotDogDir}hotdog_classifier_v2.keras", | |
save_best_only=True, | |
monitor="val_loss" | |
) | |
] | |
history = model.fit( | |
train_dataset, | |
epochs=50, | |
validation_data=validation_dataset, | |
callbacks=callbacks | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment