Last active
June 24, 2022 16:46
-
-
Save SmiffyKMc/779c3d7112d3abcedcdf8988b00233f7 to your computer and use it in GitHub Desktop.
Multiclassifier
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
conv_base = keras.applications.vgg16.VGG16( | |
weights="imagenet", | |
include_top=False | |
) | |
conv_base.trainable = False | |
inputs = keras.Input(shape=(256, 256, 3)) | |
x = data_augmentation(inputs) | |
x = keras.applications.vgg16.preprocess_input(x) | |
x = conv_base(x) | |
x = layers.Flatten()(x) | |
x = layers.Dense(512)(x) | |
x = layers.Dropout(0.5)(x) | |
outputs = layers.Dense(2, activation=keras.activations.softmax)(x) | |
model = keras.Model(inputs, outputs) | |
model.compile(loss=keras.losses.SparseCategoricalCrossentropy(), | |
optimizer=keras.optimizers.RMSprop(), | |
metrics=["accuracy"]) | |
callbacks = [ | |
keras.callbacks.ModelCheckpoint( | |
filepath=f"{hotDogDir}hotdog_multiclassifier_v1.keras", | |
save_best_only=True, | |
monitor="val_loss" | |
) | |
] | |
history = model.fit( | |
train_dataset, | |
epochs=20, | |
validation_data=validation_dataset, | |
callbacks=callbacks | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment