-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Conversation
Just sent a PR to web-data for the image (dmlc/web-data#40). |
@@ -0,0 +1,72 @@ | |||
# Image Embedding Learning | |||
|
|||
This example implements embedding learning based on a Margin-based Loss with distance weighted sampling [(Wu et al, 2017)](http://www.philkr.net/papers/2017-10-01-iccv/2017-10-01-iccv.pdf). The model obtains a validation Recall@1 of ~64% on the [Caltech-UCSD Birds-200-2011](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html) dataset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does performance match the original paper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, approximately (slightly higher recall@1 and slightly lower recall@16 than what's reported in the paper). The difference is < 1%.
The difference between this implementation and the original implementation is that here we perform sampling within each GPU while the original paper implements cross-gpu sampling. Since the performance is almost identical (at least on this dataset), I use per-gpu sampling here for simplicity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaoyuaw Thanks for the contribution! Do you mind noting the difference with the original paper (per-gpu sampling) explicitly in readme? That will be good information to know when others reuse the example.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for the good suggestion! Yes, I will update this soon.
LGTM |
try: | ||
n_indices += np.random.choice(n, k-1, p=np_weights[i]).tolist() | ||
except: | ||
n_indices += np.random.choice(n, k-1).tolist() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaoyuaw It seems that you also sample positive elements into the n_indices here. If I understand correctly the exception can occur if all negative partners induce non-zero loss, meaning that there are none left to sample from due to the (distance < self.nonzero_loss_cutoff)
mask. So shouldn't you sample some of the negative elements that induce zero loss instead of possibly positive elements here? Please correct me if I misunderstood something. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for pointing this out! Yes, you're absolutely right. I'll fix this soon.
Outputs: | ||
- Loss. | ||
""" | ||
def __init__(self, margin=0.2, nu=0.0, weight=None, batch_axis=0, **kwargs): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chaoyuaw Is ν=0 the same as what you use for the results with learned β^class in Table 3? Thanks for clarifying!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @leezu, thanks for your question! A \nu == 0 doesn't disable learning of \beta^{class}. \nu is the regularization hyperparameter, or you can think of it as setting a prior for beta. In experiments, I found \nu==0 usually works well. Setting --lr-beta=0 will however disable learning of \beta^{class}. I hope that clarifies!
* add embedding learning example * image from web-data * fix typos
* add embedding learning example * image from web-data * fix typos
Description
Add gluon example for embedding learning.
Checklist
Essentials
make lint
)Changes
Comments