Skip to content

Instantly share code, notes, and snippets.

@thuwarakeshm
Last active October 26, 2021 10:42
Show Gist options
  • Select an option

  • Save thuwarakeshm/e2c91dabebcbb9a1447a2bf7a19e2e4c to your computer and use it in GitHub Desktop.

Select an option

Save thuwarakeshm/e2c91dabebcbb9a1447a2bf7a19e2e4c to your computer and use it in GitHub Desktop.
# trainable property is available on model instances
model.trainable = False
# Also on individual layers
layer.trainable = False
tf.keras.layers.Dense(8, activation='relu')(input1)
model = VGG16(
include_top=False,
# Other model parameters
)
# Specify a small value for learning rate.
# This ensures the model doesn't drastically deviate from the original one.
base_learning_rate = 0.0001
model.compile(
optimizer=tf.keras.optimizers.Adam(learning_rate=base_learning_rate),
loss=tf.keras.losses.BinaryCrossentropy(from_logits=True),
metrics=['accuracy']
)
training_history = model.fit(
train_dataset,
epochs=initial_epochs,
validation_data=validation_dataset
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment