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

Add WARPLossLayer and gradient check test cases #126

Closed
wants to merge 1 commit into from
Closed

Add WARPLossLayer and gradient check test cases #126

wants to merge 1 commit into from

Conversation

kloudkl
Copy link
Contributor

@kloudkl kloudkl commented Feb 18, 2014

This pull request chose to implement the Weighted Approximate Rank Pairwise (WARP) loss layer in response to issue #88 "Implement ranking loss layer". WARP[1] was applied in a similar manner for image annotation[2] and is also useful in image retrieval using text queries.

The only open source implementation of WARP loss that I found is in the mrec recommender systems Python library from Mendeley. WARP was used there to optimize a matrix factorization model and a hybrid ranking model.

Obeying the contributing protocol designed by @shelhamer in #101, I opened this work in progress PR to welcome comments to correct defects as early as possible and to guide my further development.

References:
[1] Jason Weston, Samy Bengio, and Nicolas Usunier. Wsabie: Scaling up to large vocabulary image annotation. In IJCAI, 2011.
[2] Yunchao Gong, Yangqing Jia, Sergey Ioffe, Alexander Toshev, Thomas Leung. Deep Convolutional Ranking for Multilabel Image Annotation. arXiv:1312.4894 [cs.CV]

@kloudkl
Copy link
Contributor Author

kloudkl commented Feb 18, 2014

The base branch was not set to the newly created dev branch. The project maintainer can change it with the Pull Request API. Thanks!

curl --user ":owner" \
       --request POST \
       --data '{"issue": "126", "head": "kloudkl:warp_loss_layer", "base": "dev"}' \
       https://api.github.com/repos/BVLC/caffe/pulls/

@shelhamer
Copy link
Member

As far as I know the API actually creates a new PR rather than updating the existing request. Since dev is a recent invention for Caffe this PR and other open PRs have amnesty, and we'll merge them to dev behind-the-scenes.

@shelhamer
Copy link
Member

As to the actual content of this PR: ranking loss has been on my todo list as well, and WARP is a welcome choice of loss.

@sergeyk
Copy link
Contributor

sergeyk commented Feb 24, 2014

Thanks @kloudkl!
@shelhamer will review this after March 7.

@kloudkl
Copy link
Contributor Author

kloudkl commented Feb 25, 2014

I did not make progress since the opening of this PR because there is an assumption that was not satisfied, i.e. computing the loss relied on how multiple labels of a data point is store in the bottom label blob. Currently the DataLayer only supports single label input data. So the loss layer is blocked by the data layer. That's why I opened #144 asking for an external potential solution.

Now, the related works are concentrated in #149 thanks to @sergeyk. I will have discussions there to have the data layer implemented first and refine the WARP loss layer at the same time. Making changes to be coordinated with #149 is expected.

@sergeyk
Copy link
Contributor

sergeyk commented Mar 13, 2014

@kloudkl, if you need a multi-label input to make progress on this, the HDF5DataLayer provides both data and label as vectors. See test example.

@kloudkl
Copy link
Contributor Author

kloudkl commented Mar 15, 2014

@sergeyk, thanks for the HDF5DataLayer! I will give it a try. We also need tools to convert existing datasets into the HDF5 format.

@jay2002
Copy link

jay2002 commented Mar 23, 2014

@kloudkl have you tried to convert your dataset into HDF5 format?
If my dataset have 4 (0, 1, 2, 3) labels and one sample has 3 labels (0, 1, 2)
should the label vetcor be [1 1 1 0]? or [0 1 2]?

@kloudkl
Copy link
Contributor Author

kloudkl commented Mar 23, 2014

@jay2002, I am too busy at some other related issues #244, #250 and #251 at the moment. So I haven't converted a dataset yet.

#220 used the C++ interface of HDF5 which must be manually compiled on Ubuntu 12.04. Have a look at it to see it helps. I will implement #213 using the C interface very soon.

@sergeyk, as the creator of HDF5DataLayer, you must have a lot of first hand experiences in doing so. How did you handle such situations?

@sergeyk
Copy link
Contributor

sergeyk commented Mar 23, 2014

ALthough HDF5DataLayer can load matrices for label data, I haven't ever
used that functionality. The answer to @jay2002's question depends entirely
on the loss layer. -- and I'm not up to date on our multi-label loss
options, sorry.

One thing I can say is that each row of the label matrix must be the same
size, so your option 2 doesn't make sense.

On Sun, Mar 23, 2014 at 12:35 AM, kloudkl notifications@github.com wrote:

@jay2002 https://github.com/jay2002, I am too busy at some other
related issues #244 #244, #250https://github.com/BVLC/caffe/pull/250and
#251 #251 at the moment. #213https://github.com/BVLC/caffe/issues/213will be the next target. So I havn't got the time to do the conversion.

@sergeyk https://github.com/sergeyk, as the creator of HDF5DataLayer,
you must have a lot of first hand experiences in doing so. How did you
handle such situations?


Reply to this email directly or view it on GitHubhttps://github.com//pull/126#issuecomment-38376170
.

@kloudkl
Copy link
Contributor Author

kloudkl commented Mar 23, 2014

HDF5OutputLayer has been implemented in #252. You can convert a dataset using a network with only a DataLayer and an HDF5OutputLayer.

@jay2002
Copy link

jay2002 commented Mar 24, 2014

I got it. Thx @kloudkl @sergeyk

@kloudkl kloudkl closed this Mar 25, 2014
@kloudkl kloudkl mentioned this pull request Mar 25, 2014
@kloudkl
Copy link
Contributor Author

kloudkl commented Mar 25, 2014

Continued in #257.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants