Fine-tuning Deep Learning Models in Keras
I followed the tutorial in the link provided below
I have to fine tune a model which is already trained with the dataset .I have to fine tune this model with new set of data which are representing the same classes as in my training but having some difference in its view.The procedure used by me is given below
finemodel=baseline_model()
finemodel.load_weights(‘mysavedmodel.h5’)
for layer in finemodel.layers[:5]:
…….layer.trainable = False
I want to freeze the weight for the first 5 layers so that they remain intact throughout the fine-tuning process.
finemodel.fit(X_train_ft,y_train_ft,validation_data=(X_test_ft,y_test_ft),nb_epoch=10,batch_size=10)
It is actually a common practice to freeze the weights of the first few layers of the pre-trained network. This is because the first few layers capture universal features like curves and edges that are also relevant to our new problem. We want to keep those weights intact. Instead, we will get the network to focus on learning dataset-specific features in the subsequent layers.
https://medium.com/@14prakash/transfer-learning-using-keras-d804b2e04ef8