How to modify freezed layers in training using Tensorflow's Object Detection API?

痴心易碎 提交于 2019-12-14 03:09:59

问题


I am using Tensorflow's Object Detection API in training.

In which file, the freezed layers are defined to fine-tune the model in training. I need to experiment changing freezed layers in fine-tuning.

For example, if I use Resnet50 configuration, where I can change the freezed layers?


回答1:


That certainly you can do.

By reading the proto file for training, there is a field called freeze_variables, this is supposed to be a list containing all variables that you want to freeze, e.g. excluding them during the training.

Supposed you want to freeze the weights from the first bottleneck in the first unit of the first block, you can do it by adding

freeze_variables: ["resnet_v1_50/block1/unit_1/bottleneck_v1/conv1/weights"]

so your config flie looks like this:

train_config: {
  batch_size: 1
  freeze_variables: ["resnet_v1_50/block1/unit_1/bottleneck_v1/conv1/weights"]
  ...

You can verify that the weights are in fact freezed by checking the tensorflow graph.

As shown, the weights do not have train operation anymore.

By choosing specific patterns for freeze_variables, you can freeze variables very flexibly (you can get layer names from the tensorflow graph).

Btw, here is the actual filtering operation.



来源:https://stackoverflow.com/questions/55962158/how-to-modify-freezed-layers-in-training-using-tensorflows-object-detection-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!