Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch Normalization - Vgg fine tune model - very low accuracy #225

Open
HRKpython opened this issue Nov 16, 2018 · 1 comment
Open

Batch Normalization - Vgg fine tune model - very low accuracy #225

HRKpython opened this issue Nov 16, 2018 · 1 comment

Comments

@HRKpython
Copy link

HRKpython commented Nov 16, 2018

I created the Vgg model using keras with tensorflow backend and theano image ordering. For fully connected layers, I added the batch normalization after the relu activation layers. I loaded the vgg16_bn.h5 weights of the model. Then I pop the last 8 layers up to the maxpooling laye in conv5 block "model.add(MaxPooling2D((2,2), strides=(2,2)))".

model.add(Flatten())
model.add(Dense(4096, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(4096, activation='relu'))
model.add(BatchNormalization())
model.add(Dropout(0.5))
model.add(Dense(1000, activation='softmax'))

I pre-compute the features up to there and save them. Then I created a top_model based on my problem and load the precompute features to the top_model and trained the model. I got 88% accuracy after 20 epochs on validation set and 99% accuracy on the training set. Then I saved the weights for the top model to a file.

Now, I want to fine tune the model (train the last conv block as well). So I have the vgg model with batch normalization only on fully connected layers, I loadded the vgg_bn weights and poped the last 8 layers. Then created my top_model and load the weights based on the previous study and add my model to the vgg_bn model without last 8 layers. Then for the first 25 layers, I setup the trainable to be False.

for layer in model.layers[:25]:
layer.trainable = False

Without doing any training, If I evaluate my validation_generator, I get 88% accuracy. Now I let the model to be trained for 1 epoch and my accuracy is 20% on training and 36% on validation. Even if I train for 40 epochs it does not help. I appreciate any help.

@Evan05543071
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants