tensorflow / tensorflow/models
Freezing specific layers when using Tensorflow Object Detection API
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.7k
- Forks
- 44.8k
- PR merge metrics
- No merged PRs in 30d
Description
Greetings,
- I am using the latest Tensorflow Object Detection API release and TensorFlow 2.
- I am reporting the issue to the research directory
- I checked to make sure that this issue was not completely resolved, #10167
1. The entire URL of the file you are using
https://github.com/tensorflow/models/blob/master/research/object_detection/model_main_tf2.py
https://github.com/tensorflow/models/blob/master/research/object_detection/model_lib_v2.py
2. Describe the bug
When I provide something in the freeze_variables config, e.g. freeze_variables: ['.*conv.'], and then run training with model_main_tf2.py as in the tutorial, no variables are frozen, and all layers are trained. I went through the model and training protocol configuration steps in model_lib_v2.py, in the train_loop method which is called in model_main_tf2.py, and it never seems to touch the freeze_variables option.
3. Steps to reproduce
Follow the steps of the tutorial to set up a training run for the CenterNet MobileNetV2 FPN 512x512 model, and use the config file included with the model. Add freeze_variables: ['.*conv.'] to train_config. If you add print(detection_model.trainable_variables) to line 673 of model_lib_v2.py (right before the training begins), it outputs all variables, i.e. all variables are still trainable.
4. Expected behavior
Variables matching the provided freeze_variable regex should no longer be trainable.
6. System information
== python version ==============================================
(major, minor, micro, releaselevel, serial)
(3, 7, 10, 'final', 0)
== bazel version ===============================================
Build label: 5.3.1
== check os platform ===============================================
os: Linux
machine: x86_64
== check pips ===================================================
numpy 1.21.6
proto-plus 1.20.3
protobuf 3.19.4
tensorflow 2.8.0
tensorflow-addons 0.14.0
tensorflow-datasets 4.5.2
tensorflow-estimator 2.3.0
tensorflow-hub 0.12.0
tensorflow-io 0.25.0
tensorflow-io-gcs-filesystem 0.25.0
tensorflow-metadata 1.8.0
tensorflow-model-optimization 0.7.2
tensorflow-probability 0.15.0
tensorflow-text 2.8.2
tensorflowjs 3.20.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.