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

Model overfitting, smooth triplet margin loss #690

Open
taaresh7 opened this issue Mar 23, 2024 · 2 comments
Open

Model overfitting, smooth triplet margin loss #690

taaresh7 opened this issue Mar 23, 2024 · 2 comments

Comments

@taaresh7
Copy link

taaresh7 commented Mar 23, 2024

Hi there!

Thank you for the awesome library!

I'm currently working on training a model using the CARS196 dataset with the following parameters:

distance = distances.CosineSimilarity()
reducer = reducers.ThresholdReducer(low=0)
loss_func = losses.TripletMarginLoss(margin=0.2, distance=distance, reducer=reducer, smooth_loss=True)
mining_func = miners.TripletMarginMiner(margin=0.2, distance=distance, type_of_triplets="all")

Initially, I didn't include the smooth_loss parameter, which caused the loss to get stuck at the margin of 0.2. However, after setting smooth_loss=True, I encountered an overfitting issue. Do you think the margin and type of triplets I've used are appropriate to begin with? Should I consider adjusting them?

Additionally, I'm using the VIT base 16 224 model and freezing the early layers to reduce parameters. Do you see any mistakes in my approach, or do you have any suggestions on what I should try next? I think It is possible to achieve at least Precision@1 of 0.8. Currently, I'm at 0.6 with some overfitting.

@taaresh7 taaresh7 changed the title Model overfitting, soft triplet margin loss Model overfitting, smooth triplet margin loss Mar 23, 2024
@KevinMusgrave
Copy link
Owner

Do you know what settings were used to get 0.8 accuracy?

@taaresh7
Copy link
Author

taaresh7 commented Apr 1, 2024

Not exactly, but I checked the open-metric-learning library

train-car196-oml

They achieved 0.9 P@1 (max 1000 epochs )with the above parameters and using oml I was able to achieve 0.8 P@1 on validation (220 epochs), while on train it was 0.9. Training for more epochs it can probably reach the benchmark of 0.9.

The main thing I was forgetting was augmentation, I could try again with pytorch-metric-learning this week.

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