2

I am experimenting with different pre-trained TensorFlow models from "Tensorflow detection model zoo" on my data - I want to retrain (fine-tune) only the deepest N layers in each model to find the optimal configuration for my data. Is there a way to do this in a generic form that will work for any architecture, and will not depend on layer names (that change between models)? Alternatively, is there an easy way to query the graph for the names of the last N layers (and I mean layers - and not ops)?

Jenny
  • 333
  • 2
  • 11

1 Answers1

0

You could use the freeze_variables option in the training config to prevent the lower layers from being optimized.

Which model are you looking to finetune? In my experience, freezing lower layers doesn't translate to faster training or better results (letting the lower layers float seemed best). YMMV though.

Derek Chow
  • 722
  • 3
  • 6
  • I wanted to try several models from the zoo - currently it looks like the `ssd_mobilenet_v2_coco_2018_03_29` model works best for my data. Can you please guide me **how** to use the `freeze_variables` option? – Jenny Apr 17 '18 at 12:38
  • 2
    Add the following line to the `train_config` section: `freeze_variables: "FeatureExtractor/MobilenetV2/(Conv|expanded_conv(_([1-9]|1[0-4]))*)/.*"` In general, if you specify a regex as a `freeze_variables` argument, the trainer will no train variables with names that match the specified regex. Note you can specify multiple `freeze_variables` arguments. – Derek Chow Apr 18 '18 at 06:28