Closed lxtGH closed 7 years ago
Yes, you are in the right direction. If you look into the detail in the get_var
function, you will notice that it will use the pre-trained data only if the name
and the index
exist. And it will use the initial_value
otherwise. That is why I like to save the network as npy file to get more flexibility.
So basically what you need to do is to replace the fc
layers with new names. You can see the previous discussion for more detail.
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py This example shows how to take a Inception v3 architecture model trained on ImageNet images, and train a new top layer that can recognize other classes of images. I have the same problem as lxtGH. If you have time,can you help me write a re-train demo like that. Hope for help!!!
@machrisaa Thank u! (I did not see the vgg_trainable.py file ) You mean that if I only change the name of fc8 in vgg_trainable.py file,
self.fc8 = self.fc_layer(self.relu7, 4096, 1000, "fc8")
Then I can make my any output size that I want like this self.fc8 = self.fc_layer(self.relu7, 4096, 25, "my_fc8")
and retrain the model ?
did the above change worked or need to do something else to fine tune the model on your daatset @machrisaa
For example, I want to classify 25 labels of my image data, which means there are 25 outputs. I don't know how to ignore the last FC-layer parameters. My idea is first to load all pre-trained parameters and then change the network in memory(change the last fully connected layer, randomly initialize it), then feed my data in and add the optimizer, re-train the network? I don't if it is sensible. Hope for help!!!