Answer the question
In order to leave comments, you need to log in
How to get and freeze a pre-trained convolutional warp?
There is a trained network:
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation="relu", input_shape=(150, 150, 3)))
model.add(layers.MaxPooling2D(2, 2))
model.add(layers.Conv2D(64, (3, 3), activation="relu"))
# model.add(layers.MaxPooling2D(2, 2))
# model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D(2, 2))
model.add(layers.Conv2D(128, (3, 3), activation="relu"))
model.add(layers.MaxPooling2D(2, 2))
model.add(layers.Flatten())
model.add(layers.Dropout(0.5))
model.add(layers.Dense(512, activation="relu"))
model.add(layers.Dense(1, activation="sigmoid"))
conv_base = VGG16(weights="imagenet",
include_top=False,
input_shape=(150, 150, 3))
model = models.Sequential()
model.add(conv_base)
model.add(layers.Flatten())
model.add(layers.Dense(256, activation="relu"))
model.add(layers.Dropout(0.5))
model.add(layers.Dense(1, activation="sigmoid"))
conv_base.trainable = False
for layer in model.layers:
if layer.name == "flatten_1" or layer.name == "dense_1" or layer.name == "dropout_1" or layer.name == "dense_2":
set_trainable = True
else:
layer.trainable = False
Answer the question
In order to leave comments, you need to log in
Freezing via layer.trainable is correct. What does it mean to "get" the convolutional base?
Here are the layer weights:
layer.weights
layer.get_weights()
for layer in model.layers[:4]:
layer.trainable = False
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question