To solve the problem that the loss of verification set of resnet50 pre-training model remains unchanged

# Available whenever available in the library Use pre-trained ResNet50 models
covn_base = tf.keras.applications.ResNet50(weights='imagenet', include_top = False,
                                           input_shape=(im_height,im_width,3), layers=tf.keras.layers)

K.set_learning_phase(1)
"""
freeze the weights for the first 174-33=141
frezee the level 141 before
"""
for layer in covn_base.layers[0:141]:
    layer.trainable = False

for layer in covn_base.layers[141:]:
    layer.trainable = True

model.add(covn_base)
model.add(tf.keras.layers.GlobalAveragePooling2D())
model.add(tf.keras.layers.Dense(512,activation="relu"))
model.add(tf.keras.layers.Dropout(rate=0.2))
model.add(tf.keras.layers.Dense(CLASS,activation="softmax"))

Load pre training model with your own classification model!!!


Read More: