Reputation: 19
vgg16_model = tf.keras.applications.vgg16.VGG16()
model= Sequential()
for layer in vgg16_model.layers[:-1]:
model.add(layer)
model.summary() #The last dense layer is removed till now
for layer in model.layers:
layer.trainable=False #for transfer learning i have freeze the layers
model.add(Dense(2, activation='softmax'))
model.summary() #now when i add dense layers trainable parameters of model get changed
Upvotes: -1
Views: 1478
Reputation: 112
In the first step you generate a network with 134,260,554 parameters.
Those parameter are all set to be non trainable. Then you add a layer with two neurons to the model. This adds 2*4096 + 2 = 8194 (weights + bias) parameters to the model. Those parameters are trainable. This is what the summary shows.
Upvotes: 0