Mustafain Rehmani
Mustafain Rehmani

Reputation: 19

trainable parameters of vgg16 model get changed after adding my own dense layer

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 

enter image description here

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 

enter image description here

Upvotes: -1

Views: 1478

Answers (1)

Daniel Lang
Daniel Lang

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

Related Questions