Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to unfreeze encoder layers when training a computer vision model #3733

Open
saad-palapa opened this issue Oct 16, 2023 · 0 comments · May be fixed by #3981
Open

Option to unfreeze encoder layers when training a computer vision model #3733

saad-palapa opened this issue Oct 16, 2023 · 0 comments · May be fixed by #3981

Comments

@saad-palapa
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Our computer vision solution is missing an important feature to improve accuracy.

Describe the use case
In the past, I've followed this Tensorflow tutorial to train an image classifier. This is a transfer learning technique that has two training rounds:

  1. Training: add a classification head to a pretrained base model. The base model is frozen and the classification layers are trainable. This is currently what we have right now.
  2. Fine-tuning: unfreezing layers from the base model and doing 10 epochs of low learning rate training.

Describe the solution you'd like
There are two ways to implement this:

  1. Update the configuration to let users choose to automatically run the 2nd fine-tuning round. Maybe this can be the default.
  2. Rely on users to code their own fine-tuning round.

Both require a way to choose how to freeze layers. There are two approaches to freezing layers:

  1. By percentage or layer count of the base model starting from the first hidden layer
  2. Using a regex to choose which layers to freeze. From example:
var_freeze_expr: '(efficientnet|fpn_cells|resample_p6)'

The later layers encode high level features of the image while the early ones encode low level features (corners, edges, colors, gradients, etc). It's not good to fine-tune the lower levels because the model will overfit those features.

When fine-tuning, we unfreeze the later layers of the pretrained base model. The number of layers to unfreeze depends on the task similarity and dataset size relative to the pretrained encoder.

image

Describe alternatives you've considered
The alternative is to keep things as they are and rely on users to implement their own 2-round transfer-learning job.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant