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

Invalid gradient when finetuning and learning rate with gradient clip setting #65

Open
skill-diver opened this issue Jul 25, 2024 · 2 comments

Comments

@skill-diver
Copy link

skill-diver commented Jul 25, 2024

Hi Author,

Thank you for sharing this project and for your kindness for answering my previous questions. I have some of questions want to ask about training:

  1. What is your default learning rate and gradient clip setting when training from scratch?
  2. I tried to replace the dino part in the encoder with another VIT and the performance got bad. So, I decide to finetune your weights. But I will get an invalid gradient if I use the code's learning rate and gradient clip now. So I choose unfreeze layer training during epochs to solve this problem (But the performance increase is really slow).
  3. Would you happen to have some better suggestions to avoid the invalid gradient when finetuning your model with new VIT? My current idea is train from scratch but does that need to spend too much time?

Thank you so much.

@Parskatt
Copy link
Owner

Parskatt commented Jul 25, 2024

  1. Its different depending on the encoder and decoder, the settings should be in the train experiment. Grad clip is 0.01 I think. Basically you can set grad clip thr super low so all gradients are clipped. This helped a bit with stability.

  2. The model is trained with a step lr, so that at the end the lr is /10 the original onr. If you want to finetune, I suggest that lr.

  3. It's probably difficult to replace the vit without scratch since the features will be different.

Sorry for lack of detail, on my phone and cant check stuff right now.

If you have issues with stability, you could check which params give nans and manually use fp32 there.

You might also want to freeze the batchnorm of the network, ive found the batchnorm can cause a lot of issues.

@skill-diver
Copy link
Author

skill-diver commented Jul 27, 2024

How many days you spend to train the roma model? I also find if I replace the dino with other vit the training result is bad

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

No branches or pull requests

2 participants