bnu-wangxun / deep_metric Goto Github PK
View Code? Open in Web Editor NEWDeep Metric Learning
License: Apache License 2.0
Deep Metric Learning
License: Apache License 2.0
I have been trying Resnet 50 as the training network, however, it ends up errors saying there is no embed parameters, I am wondering what are changes needed to make in order to use it in your framework?
Hello, thanks for your good jobs!
When I use your codes, i find almost all types of loss can reach the result that rank1 is over 0.60. But when i read the paper, if the method is over 0.60(rank1), it can be seen as a good method. Even the contrastive loss can achieve rank1 over 0.60. Why? Thanks
Thank you for sharing your code. Nice work! I have a question about the Binomial Deviance Loss. In your previous paper, Binomial without mining achieves recall-top1 of 64% on CUB200, but I can not reproduce the result with your code. Could you provide more detail about your implementation? For example, the alpha and beta.
Hey, thank you for uploading your code and sharing your work.I tried running your code, but the result is not good as that given in your paper.At first,I thought it was a hyper parameter(alphabet and base) problem as the parameters set in the code were inconsistent with those in the paper.I tried to run the code according to the parameters in the paper, and found that the result were worse.Could mind sharing the best hyper parameters of the weight loss(alpha=?,beta=?,base=?),thank u very much!
Does MarginDevianceLoss.py and MarginPositiveLoss.py belong to lifted structure loss? I only want to use lifted loss.
Hello :D Thanks for your sharing!
I actually just started this metric learning few weeks ago, so I couldn't recognize the reference of those losses. Could you let me know the reference of the 'Weighted' Loss, and Margin loss?
Thanks
I start studying for the first time. Please analyze the results.
And why is the accuracy zero?
train===
Epoch: [001][1/1] Time 2.391 Loss 5.4381 Accuracy 0.0000 Pos 0.6235 Neg 0.6207
Hi, i have a question about the alpha which is a Hyperparameter
base = torch.mean(dist_mat[i]).data[0]
pos_logit = torch.sum(torch.exp(self.alpha*(base - pos_neig)))
neg_logit = torch.sum(torch.exp(self.alpha*(base - neg_neig)))
loss_ = -torch.log(pos_logit/(pos_logit + neg_logit))
In your implementation, I found that you first used K-nearest neighbors to select negative samples and then calculated the mean of the distances.
Maybe because the result is too small, so multiply by a parameter alpha?
Traceback (most recent call last):
File "train.py", line 207, in
main(parser.parse_args())
File "train.py", line 121, in main
optimizer=optimizer, train_loader=train_loader, args=args)
File "/home/user/2T-G/zyy/Deep_metric-master/trainer.py", line 62, in train
loss=losses, accuracy=accuracy, pos=pos_sims, neg=neg_sims))
TypeError: unsupported format string passed to Variable.format
I have encountered the above problem, can you help me solve it? Thanks
Thank you for sharing your code.It help me a lot to know DML.I've been looking at SemiHard for the last two days, but the papers that the project cites don't seem to go into it in detail.
Could you please tell me some specific information about SemiHard or the corresponding articles?Thx a lot.
Hey, thank u very much for uploading your great work!
I got a small problem about reading your train.txt and test.txt files in Dataset folder. Firstly, it seems like u haven't uploaded any test.txt file. Secondly, for different dataset, the train and test txt files should be different, right?
Did u forget to upload it or am I miss understanding ur work?
thank u very much again!
cheers
Hi, Thank you for your job. Can you tell me which paper has come up with weight loss ? Thank you a lot.
Hey I saw you updated your work recently, that is so nice of you.
I got a question about trainloader here. As I posted before, when I ran your code on my own computer, the loss function is increasing. The problem may be the trainloader. I found that in each epoch, the train loader only load about 480 images which is strange. The number of iterations in each epoch is only 6. I was trying to fix it by myself but it looks a little bit difficult to fully understand your code. Do you have any suggestions for me to fix this problem?
Cheers
Candice
Hi,
Thanks for your great work! But it seems that the pre-trained models were removed from the cloud drive. Could you please kindly upload them again ?
Hi, I wonder if you also tried the distance weighted margin loss specified in Sampling Matters in Deep Embedding Learning.
I see you have the sampling scheme applied to deviance loss. I wonder why?
i'm confused where is the Multi-Similarity Loss?
Where can i get the train.txt and test.txt in Product and In-shop Clothes Retrieval Benchmark dataset?Thanks
which paper are these algorithm abbreviation reference,very thanks
HDC
Clustering
ProxyNCA
Smart Mining
Margin [5]
HTL
ABIER
Weight
Hi, @bnu-wangxun
Thanks for your great work.
Could you kindly provide the processed SOP and In-Shop, or the pre-processing codes?
Thanks for sharing your great work!
I read some questions and your answers about the losses, but I ask again to make it sure.
For the losses in your code, I see a similar type of losses such as
neg_loss = 2.0/self.alpha * torch.log(1 + torch.sum(torch.exp(self.alpha * (neg_pair - base))))
from the SemiHard loss, DistWeighted loss. As far as I know, those losses were a linear loss of the distance(in your code, similarity) according to the original papers. (If those losses are from the FaceNet and Sampling matteres...)
Are these losses your own 'Weight' loss which has an assumption that the data follows the distribution of the mixture of Gaussian?
Thanks :D
Does your code reproduce the R@1 on cars-196 using npair (71.1) and proxy-nca (73)? If yes could you please share the hyperparams please?
I use the super parameters given in the run script to reproduce the work of WeightLoss, but I can not get the same result as reported. My best result as follow:
Epoch-130 0.6411 0.7437 0.8301 0.8981 0.9458 0.9731
Would you please give me some help?
Hello! I meet a problem when i am reading your code; Specifically, that is the implementation of 'lr_mul' trick.
your implementation of it is as follows:
param_groups = [ {'params': base_params, 'lr_mult': 0.0}, {'params': new_params, 'lr_mult': 1.0}]
And in the open-source code of your MS loss :
the implementation of it is as follows:
def build_optimizer(cfg, model): params = [] for key, value in model.named_parameters(): if not value.requires_grad: continue lr_mul = 1.0 if "backbone" in key: lr_mul = 0.1 params += [{"params": [value], "lr_mul": lr_mul}] optimizer = getattr(torch.optim, cfg.SOLVER.OPTIMIZER_NAME)(params, lr=cfg.SOLVER.BASE_LR, weight_decay=cfg.SOLVER.WEIGHT_DECAY) return optimizer
but in https://pytorch.org/docs/master/optim.html, the implementation of 'lr_mul' is as follows
optim.SGD([ {'params': model.base.parameters()}, {'params': model.classifier.parameters(), 'lr': 1e-3} ], lr=1e-2, momentum=0.9)
I want to know is there any difference between 'lr_mul' and 'lr_mult'? I can find any information of that. And in the document of pytorch framework, I cannot find any explain of 'lr_mul' and 'lr_mult'. (I find that the 'lr_mult' is used in caffe framework.) I'm confused of this problem and I need your help.
Thank you!
I can't understand the code
https://github.com/bnulihaixia/Deep_metric/blob/master/losses/Weight.py#L45
why using resize here?
The accuracy is always zero, any idea of what might went wrong?
It is very good to keep such a repo to summarize all the metric learning related loss functions' implementation. I am wondering whether it is convenient for you to share us the evaluation results to get more insights about whether your implementation is comparable with their orignal implementations.
Besides, you mentioned that your method named below has achieved state-of-the-art performance.
New Positive Mining Loss based on Fuzzy Clustering
Have you compared your method with some recent work like HDC[1], BIER[2] and so on.
[1] : Yuan Y, Yang K, Zhang C. Hard-Aware Deeply Cascaded Embedding[J]. arXiv preprint arXiv:1611.05720, 2016.
[2]: Opitz, Michael, et al. "BIER-Boosting Independent Embeddings Robustly." Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition. 2017.
I tried to use the code to reproduce some paper on DML, but it has too many configs need to verify.
Could you please provide more details?
Hey, thank you very much for your code. I know that this work has been accepted by CVPR2019, and have you release the work on arxiv? Where can I download your work. Thanks.
Have you cropped the images in the cub-200 dataset?
Hey when would the XBM code be released ? Is it possible to get it before you post it here (If it takes time) ? Thanks !
I have scanned the code of evalutions and now am confused of the metric 'rank@k'.
Is it the same with metric 'top@k'?
I revised the script 'test.py' and add additional functions to get the metric 'top@k'.
As you know, the two metrics are obtained from the matrix 'sim_mat' which is provided by you.
But the results of them are not equal sometimes.
So, could you explain the concept of 'recall@k' in the view of your code?
Thank you very much.
AttributeError: 'float' object has no attribute 'backward'
Cannot run loss.backward()
Can you please help me fix this?
Config: python - 3.6.7; pytorch - 0.4.1
In "CUB200.py" file, function "Generate_transform_Dict", It seems that the mean and std should be set to mean = [0.485, 0.456, 0.406] and std = [0.229, 0.224, 0.225] in RGB setting. And I have a question about your convertBGR, it seems that you don not use OpenCV. What is this operation mean?
Hi, I want to cite Weight Loss in my paper. Could you please provide its citation?
By running the code, first training and then test, without changing anything. I got the results below, which are far from being comparable with what you have reported. I use pytorch 0.2.0.4. Any idea on how this happens. Thanks.
test cub***knnsoftmax-model.pkl
[0.48176907 0.61428089 0.74257259 0.84689399]
test cub***knnsoftmax-50_model.pkl
[0.48041864 0.62187711 0.74206617 0.84351789]
test cub***knnsoftmax-100_model.pkl
[0.5035449 0.63740716 0.763842 0.85651587]
test cub***knnsoftmax-200_model.pkl
[0.50303849 0.63723835 0.76164754 0.86090479]
test cub***knnsoftmax-300_model.pkl
[0.50607698 0.6424713 0.76991897 0.86326806]
test cub***knnsoftmax-350_model.pkl
[0.51147873 0.65124916 0.76890614 0.86613774]
train cub***knnsoftmax-350_model.pkl
[0.58202592 0.696794 0.7941678 0.86834925]
test cub***knnsoftmax-400_model.pkl
[0.5140108 0.64804186 0.77211344 0.86664416]
test cub***knnsoftmax-450_model.pkl
[0.51367319 0.65563808 0.77211344 0.86647535]
test cub***knnsoftmax-500_model.pkl
[0.51536124 0.6492235 0.77599595 0.86866982]
test cub***knnsoftmax-550_model.pkl
[0.51958136 0.65563808 0.7744767 0.86293045]
test cub***knnsoftmax-600_model.pkl
[0.52160702 0.65698852 0.77970966 0.87002026]
train cub***knnsoftmax-600_model.pkl
[0.62772851 0.73328786 0.82213506 0.88847203]
I have a question about the algorithm01 in your paper.
You mentioned that the embeddings (called anchors) are detached from the graphe before being put into the queue.
You know that detached nodes from the graph don't retain the gradient history, hence, the embeddings will be considered constants in the next iteration, making them irrelevant to the loss function.
I don't undestand how the gradient can still be calculated on old batches without retaining the gradient history in different stages of the forward pass ?
Thank you.
How to select appropriate Alpha and Beta in Binomialloss for different dataset.Thx lot!
Hi, awesome work!
Have you ever had a chance to reproduce results for Proxy-NCA loss?
Thx
I appreciate your work very much. When I read your source code, I found that the code for weight loss was not released. May I ask when will it be released
Hi, @bnu-wangxun
I want to reproduce the result of Binomial Loss, so I modified the run_train_00.sh slightly:
DATA=car
...
LOSS=Binomial
...
DIM=64
And I downloaded the bninception from here.
But I get a performance Epoch-600 0.7719 0.8504 0.9052 0.9451 0.9701 0.9847, which is similar to MS Loss. Any idea about this? Thanks!
hello, thanks for you work, I'm curious that why you use similarity mat rather than euclidean metirc in contrastive loss and triplet loss.
Hi,
many losses here, Can you provide the reference paper about RAW+VTHM
?
Thanks for the comprehensive implementation. Really helpful for understanding the various metric learning loss.
I'm wondering if you can shed some insights on the modified loss function, which takes a different formation as the original one.
Compared to the original loss, the modified version use a different pos loss, and introduce a new parameter beta.
Traceback (most recent call last):
File "train.py", line 184, in
main(parser.parse_args())
File "train.py", line 41, in main
model = models.create(args.net, pretrained=True, dim=args.dim)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models_init_.py", line 22, in create
return __factory[name](*args, **kwargs)
File "D:\ProgramData\pyProjects\Pytorch-Deep-metric\models\BN_Inception.py", line 521, in BN_Inception
model.load_state_dict(model_dict)
File "D:\Program Files\Anaconda3\envs\pytorch1\lib\site-packages\torch\nn\modules\module.py", line 769, in load_state_dict
self.class.name, "\n\t".join(error_msgs)))
RuntimeError: Error(s) in loading state_dict for BNInception:
size mismatch for conv1_7x7_s2_bn.weight: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.bias: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
size mismatch for conv1_7x7_s2_bn.running_mean: copying a param with shape torch.Size([1, 64]) from checkpoint, the shape in current model is torch.Size([64]).
How to solve this problem?
Hello! Have you ever reproduced the results for triplet loss or N-pair loss? I found that the performace of ImageNet pretrained model is even better than the model further trained with triplet loss on CUB or CAR.
i'm confused where is the Multi-Similarity Loss?
I tried to replace the BN-inception with resnet50 pretrained on imagenet.
it seems that the performence droped a lot.
With your code, I can reproduce the result on cub-200, about 0.65.
And I inplemented a gluon(mxnet) version of the binomial loss.
But i can't find the pretrained model on mxnet.
Therefor, I tried different pretrained models. And the performences varies from 0.50 - 0.60 on cub-200.
Thus, I wonder know if different models have a big impact on the permformece?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.