mirror of
https://github.com/openai/CLIP.git
synced 2026-11-05 01:37:26 +00:00
[GH-ISSUE #39] Hyperparameter sweep in Evaluation (linear probe) #37
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
openai/CLIP#37
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @meigaoms on GitHub (Feb 10, 2021).
Original GitHub issue: https://github.com/openai/CLIP/issues/39
Hi there,
I'm trying to reproduce evaluation scores in this paper, particularly table 10. A.3. Evaluation in Page 38 mentioned L2 regularization strength lambda is determined with a hyperparameter sweep.
(1) Only maximum 1,000 iterations is mentioned in L-BFGS. Do other parameters matter, like the learning rate?
(2) For parametric binary search, is the cost function monotonic to lambda?
Thank you!
@jongwook commented on GitHub (Feb 12, 2021):
Hi! Thanks for your interest in CLIP!
(1) We used scikit-learn's LogisticRegression implementation for linear probes, and we used the default arguments for anything not mentioned. Under the hood, it calls
scipy.minimizeand in turnscipy.optimize.fmin_l_bfgs_b, which performs line search along the quasi-Newton direction to find the minimum in the convex objective. So a learning rate / step length is not required.(2) The cost function is convex in weights and linear in lambda (or C), so if you take min_w over it, the function is still convex in lambda. But cost functions using different lambda values are not comparable anyway. Also, this does not always guarantee that there will be a single peak accuracy/ROCAUC/etc. with respect to C.
However, we empirically found that the validation curves almost always have a single peak w.r.t. C, barring some noise, so we went ahead with parametric binary search to save time.
@meigaoms commented on GitHub (Feb 16, 2021):
With Tensorflow flower 102 dataset and Pytorch ResNet 50 pre-trained model model, transforms of ImageNet normalization and Resize(224,interpolation=PIL.Image.BICUBIC) + CenterCrop, fixed rand_state=0 in LogisticRegression, I expected to reproduce the number 90.8 in Table 10 exactly. However, I got 91.0. Did I miss some details? or Is this difference explainable in some way?
Thank you!
@jongwook commented on GitHub (Feb 16, 2021):
We experienced that linear probe accuracy can vary ±0.5% depending on various factors that we can't perfectly control, such as the exact versions of CUDA, cudnn, etc. Considering that, I'd say the 0.2%P difference is quite normal.
@nikky4D commented on GitHub (Feb 16, 2021):
Would you have code for this? I am working on recreating the same thing but stuck at hyperparameter sweep
@meigaoms commented on GitHub (Feb 17, 2021):
Thanks for the explanation.
I ran the linear probe with ResNet50 and multiple datasets, accuracy/mean-per-class score from some datasets are the same as what shown in Table 10, such as Food-101, CIFAR10, CIFAR100, and MNIST. Some are not: FGVC Aircraft has the largest difference (CLIP paper reported 48.5, while I got 56.4). CLIP paper mentioned that "For the datasets that contains a validation split in addition to from the test split, we use the provided validation set to perform the hyperparameter search".
(1) After hyper parameter search, do you combine the validation set with training set together to train the final LinearRegression? Or use the training set only?
(2) I currently use transforms of ImageNet normalization and Resize(224,interpolation=PIL.Image.BICUBIC) + CenterCrop for train, test, and val (if any) datasets. (Thanks of answering my question about normalization in another thread) Since there are couple of different strategies, like moco, bit. Could you share details about data augmentation in linear probe?
@meigaoms commented on GitHub (Feb 17, 2021):
Here is a sketch of my implementation:
@jongwook commented on GitHub (Feb 18, 2021):
(1) Yes. For the final test scores reported, we combined the validation split back to the training split, after the hyperparameter sweep.
(2) We didn't use any data augmentation, other than center-cropping and resizing the images as in the code. (During pre-training, we used random square crops) One exception is the KITTI dataset which contains very wide images and we stretch-resized the images into squares.
@meigaoms commented on GitHub (Feb 19, 2021):
Thank you very much!