models
models copied to clipboard
Fine-tuning in model_main_tf2.py
Prerequisites
Please answer the following question for yourself before submitting an issue.
- [x] I checked to make sure that this issue has not been filed already.
1. The entire URL of the documentation with the issue
https://github.com/tensorflow/models/tree/master/research/object_detection
2. Describe the issue
I have been looking around the source code, but I can't find how the actual fine-tuning is done. I know there is an option to train from a "detection" and from a "classification" checkpoint and I understand that this involves loading the weights from a previous checkpoint. But when it comes to training what layers are actually trained? Do you do transfer learning or do pertaining on the entire architecture?
I looked at the tutorials: https://github.com/tensorflow/models/blob/master/research/object_detection/colab_tutorials/inference_from_saved_model_tf2_colab.ipynb and I understand that here you are fine-tuning only the final 6 layers from the classification and regression heads and that makes sense, but when you train using the model_main_tf2.py file I can't find how the trainable_variables are selected.
There doesn't seem to be a selection class or function in the project. Can you customize in the model_main_tf2.py the layers that you want to fine-tune?
Hi @StoyanBoyukliyski ,
In the new tensor-flow model garden, official models repository has new experiment configuration where you can train layers using task.build_model() to select the trainable variables.
The Task object has all the methods necessary for building the dataset, building the model, and running training & evaluation. These methods are driven by tfm.core.train_lib.run_experiment
Please refer new tensor-flow model garden example and the new official repository for your reference.
I have attached gist file for your reference. Please let us know if this can help you to solve your problem.
Hi,
Thank you for that. I will have a look at it.
However, my current project is using model/research/object_detection and I will need to understand how the fine-tuning works there: namely if the fine-tuning done in model_main_tf2.py is on the whole network or on the final layers and where this is configured.
Hi,
Thank you for that. I will have a look at it.
However, my current project is using model/research/object_detection and I will need to understand how the fine-tuning works there: namely if the fine-tuning done in model_main_tf2.py is on the whole network or on the final layers and where this is configured.
Just from thinking about I guess the training process adjusts all the weights in the architecture for transfer learning. You always do transfer learning with the OD API.