Suppose I download a resnet model from and use it with tensorflow. Now I can exclude the top (output) layer and add my own output layer with 100 units that is related my business (lets call it some image classification app). and train it on that. What are the chances it will work on that?
Yes, this will work. you can reference the resnet model available in the tensorflow hub in your tensorflow model, re-train the output layer and keep the remaining layers fixed. You can also open up a few more layers below the output layer, keep the rest of the layers fixed, and re-train it allowing the new model a little more flexibility to adjust its parameters and get better tuned to your set of images.
Hello @tbhaxor, Just to add a little on what @shanup has said. The process is called Transfer Learning, You freeze the features of the pre-trained model and now you just train the classifiers of the model
You have a pretrained model that was trained on animal images…dog, cat, lion, tiger etc. If you take this model and use it to classify different breed of cats, then the pretrained model can be fine-tuned by keeping all the layers fixed and training the output layer. In some cases, we could think of opening up one or two of the fully connected layers preceding the output layer and training them as well (if required) - This will not be an expensive or heavy time consuming activity.
On the other hand, if you are going to use this pretrained model to classify buildings which the model was never trained on, then you would have to unfreeze a lot more layers and retrain it. How many layers back you would need to open up is something that will need to be experimented. However, the more layers you start opening up, the training will take more time and incur more cost, and you might need to provide more training data.
if you have (implicit) representative features learned in the pre-trained model which help in the fine-tuning, see also @shanup’s excellent example above!
In the end a deep learning model can learn what is contained in the data. If the data is sufficiently representative, compared to the new specialised tasks, transfer learning should be worth a look! Then you can leverage the pre-trained model (which is usually also super expensive and difficult to create in the first place).
Fine tuning is when to take a pre-trained model from remote repository like tfhub, remove output layer, freeze the parameters, attach the output layer based on the project configuration along with 2 3 dense layer if required. Now after training it will work similar kind of data only.
Transfer learning is simply when you download and plug model, fine tuning is special case of transfer learning where the output layers is trained on some similar kind of dataset, not entirely new set of data.