Created
June 25, 2019 22:37
-
-
Save obeshor/6f3edb98e90508a2b4470eae2ce94b82 to your computer and use it in GitHub Desktop.
Building model
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
feature_extractor = hub.KerasLayer(MODULE_HANDLE, | |
input_shape=IMAGE_SIZE+(3,), | |
output_shape=[FV_SIZE]) | |
do_fine_tuning = False #@param {type:"boolean"} | |
if do_fine_tuning: | |
feature_extractor.trainable = True | |
# unfreeze some layers of base network for fine-tuning | |
for layer in feature_extractor.layers[-30:]: | |
layer.trainable =True | |
else: | |
feature_extractor.trainable = False | |
model = tf.keras.Sequential([ | |
feature_extractor, | |
tf.keras.layers.Flatten(), | |
tf.keras.layers.Dense(512, activation='relu'), | |
tf.keras.layers.Dropout(rate=0.2), | |
tf.keras.layers.Dense(train_generator.num_classes, activation='softmax', | |
kernel_regularizer=tf.keras.regularizers.l2(0.0001)) | |
]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment