Last active
May 28, 2019 13:22
-
-
Save alonlavian/cf4c6e85aa7f042f15f09da65fc14182 to your computer and use it in GitHub Desktop.
Revisions
-
alonlavian revised this gist
May 28, 2019 . 1 changed file with 5 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,17 @@ from tensorflow.keras import layers from tensorflow.keras.models import Model base_model = VGG16(weights='imagenet', #pre-trained weights include_top=False, #remove original classifier input_shape=(HEIGHT, WIDTH, 3)) #Freeze all layers for layer in base_model.layers: layer.trainable = False #Add binary classifier x = base_model.output x = layers.Flatten()(base_model.output) x = layers.Dense(1024, activation='relu')(x) x = layers.Dropout(0.2)(x) x = layers.Dense (1, activation='sigmoid')(x) -
alonlavian created this gist
May 23, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ from tensorflow.keras.applications.vgg16 import VGG16 from tensorflow.keras import layers from tensorflow.keras.models import Model #VGG16 pre-trained and no top base_model = VGG16(weights='imagenet', include_top=False, input_shape=(HEIGHT, WIDTH, 3)) #Freeze all for layer in base_model.layers: layer.trainable = False #Add top x = base_model.output x = layers.Flatten()(base_model.output) #last_output x = layers.Dense(1024, activation='relu')(x) x = layers.Dropout(0.2)(x) x = layers.Dense (1, activation='sigmoid')(x) model = Model(inputs=base_model.input, outputs=x)