Skip to content

Adding Hinge embedding loss function#2229

Merged
birm merged 7 commits intomlpack:masterfrom
ojhalakshya:Hinge-Embedding-Loss-Function
Mar 18, 2020
Merged

Adding Hinge embedding loss function#2229
birm merged 7 commits intomlpack:masterfrom
ojhalakshya:Hinge-Embedding-Loss-Function

Conversation

@ojhalakshya
Copy link
Copy Markdown
Contributor

Hello,
This loss function in regarding to my previous issue #2200 in which I opened up for help from all guys working hard to contribute. There I mentioned many loss functions which are now being implemented.
I also am trying to implement the Hinge Embedding Loss Function now.
It can be referred from both pytorch and tensorflow.
Hope to contribute more.
Thanks.

@ojhalakshya ojhalakshya changed the title Hinge embedding loss function Adding Hinge embedding loss function Feb 22, 2020
Copy link
Copy Markdown
Member

@kartikdutt18 kartikdutt18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some small changes, other than that it looks fine.

Copy link
Copy Markdown
Member

@birm birm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I've added suggestions based upon @zoq 's comments, just to make that a bit easier. I think with that, the addition to HISTORY.md, and the merge conflict fix in the testing file, you should be good!

Copy link
Copy Markdown
Member

@kartikdutt18 kartikdutt18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One really minor style issue.

@ojhalakshya ojhalakshya requested a review from zoq February 24, 2020 18:54
const TargetType&& target,
OutputType&& output)
{
for (size_t i = 0; i < input.n_elem; i++)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we can avoid the for loop here too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be done ((1 - target(i) * input(i)) >= 0) % -target .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have implemented the changes, kindly have a look when you get time.
Thanks.

@ojhalakshya ojhalakshya closed this Mar 8, 2020
@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from 2b9bf44 to 0d8c3a0 Compare March 8, 2020 04:09
@ojhalakshya ojhalakshya reopened this Mar 10, 2020
@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch 4 times, most recently from 0b6af9b to 08a7099 Compare March 11, 2020 10:41
@rcurtin
Copy link
Copy Markdown
Member

rcurtin commented Mar 12, 2020

This code touches the ANN code, and there was recently a big refactoring of the ANN code in #2259, so be sure to merge the master branch into your branch here to make sure that nothing will fail if this PR is merged. 👍 (I'm pasting this message into all possibly relevant PRs.)

@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from ff2a9fc to 6f1971a Compare March 13, 2020 04:38
@ojhalakshya
Copy link
Copy Markdown
Contributor Author

Hey @zoq @rcurtin
I am not able to get a hold of this fail, been working to fix this from like 5 days but still no clue.
Apart from this error I have pretty much everything covered up.
Can you help me a bit in this?
The error occurs in the loss_function_test.cpp line no 522 and it generates this error when I use

HingeEmbeddingLoss<> module;

and when I just remove the <>

HingeEmbeddingLoss module;

then the template error doesn't show and only the last 4 errors show up.

I am not sure with the last 4 errors in both the cases as Forward and Backward function are defined correctly and when I build without the loss_function_test.cpp file the build works 100%.

Screenshot from 2020-03-13 10-21-18

Thanks.

@rcurtin
Copy link
Copy Markdown
Member

rcurtin commented Mar 13, 2020

You can see in the error message that it is referencing struct LossFunctionsTest::HingeEmbeddingLoss. Do you have a class or struct called HingeEmbeddingLoss defined locally in the loss_functions_test.cpp file? (This might happen if, for instance, you've named one of the tests HingeEmbeddingLoss.)

@ojhalakshya
Copy link
Copy Markdown
Contributor Author

Hi @rcurtin
Thanks for the reply and the solution also, I was able to fix the same because of it.
Can you please also have a look at the whole pr so if it is fine.
Thanks.

@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch 2 times, most recently from f9ddb47 to a0dd14e Compare March 13, 2020 21:11
@ojhalakshya ojhalakshya requested review from birm and favre49 March 13, 2020 21:12
@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch 2 times, most recently from f600880 to ad3f83d Compare March 14, 2020 04:43
Copy link
Copy Markdown
Member

@favre49 favre49 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything seems good to me :) Good work!

@kartikdutt18
Copy link
Copy Markdown
Member

Yes I am, You will also need to do the same for this layer / function as well. Thanks for all the work though 👍 .

@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from ad3f83d to fdcd685 Compare March 16, 2020 07:02
@ojhalakshya
Copy link
Copy Markdown
Contributor Author

ojhalakshya commented Mar 16, 2020

Hey @birm
I have made some changes, I think now everything is fine. I have attached the build and test results.
Can you see into this when you get time.
Thanks.
Screenshot from 2020-03-16 13-16-24

@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from fdcd685 to 5cc4d0f Compare March 16, 2020 08:26
@ojhalakshya ojhalakshya requested a review from birm March 16, 2020 08:27
@ojhalakshya
Copy link
Copy Markdown
Contributor Author

@rcurtin
Can you kindly have a look when you get time. Although azure pipelines are not working, I did build this atleast 4 times with the tests also and I think it works fine now.
I wanted to know if it works fine in other systems also.
@kartikdutt18 can you also try this one if comfortable.
Thanks.

@birm
Copy link
Copy Markdown
Member

birm commented Mar 17, 2020

I think that azure is working again; can you trick github into running those tests?

ojhalakshya and others added 3 commits March 17, 2020 08:45
* completed hardshrink_function.hpp

* resetting master

* complete hardsrhink_function.hpp

* activation_functions_test.cpp

* cmake changes

* base layer changes

* style correction

* starting implementing hard shrink as layer

* new changes

* changes in tests

* inv changes

* test changes

* test changes

* deleting prev function

* test style changes

* more style changes

* comment changes

* minor changes

* comment corrections hard shrink

* minor changes

* dummy commit

* Style fix for parameter lambda

* hardshrink.hpp to hardshrink_impl.hpp fn function shift

* style fix

Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>

* completed hardshrink_function.hpp

* resetting master

* complete hardsrhink_function.hpp

* activation_functions_test.cpp

* cmake changes

* base layer changes

* style correction

* starting implementing hard shrink as layer

* new changes

* changes in tests

* inv changes

* test changes

* test changes

* deleting prev function

* test style changes

* more style changes

* comment changes

* minor changes

* comment corrections hard shrink

* minor changes

* dummy commit

* Style fix for parameter lambda

* hardshrink.hpp to hardshrink_impl.hpp fn function shift

* style fix

Co-authored-by: Marcus Edel <marcus.edel@fu-berlin.de>

dummy commit

Redirected link on NUMfocus logo

test bugs fixing

rebasing branch
edited copyright.txt

changes in History.md

bug fix
minor change
@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from 5cc4d0f to b37f3c7 Compare March 17, 2020 03:16
@ojhalakshya
Copy link
Copy Markdown
Contributor Author

I am not sure about the LoadSaveTest in ctest in which the macOS Plain failed, as I can see all builds and all the corresponding tests had passed successfully see here.
@kartikdutt18 can you verify if this is good to go?
Also lets see if other tests are working good, lately there have been problems with azure.
Thanks.

Copy link
Copy Markdown
Member

@birm birm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks and great addition!
I don't think there's any relevance in the loadsave test. I'll add an issue for that.

@kartikdutt18
Copy link
Copy Markdown
Member

Yes it is good to go, The load save test fails because of an armadillo dependency issue and so it's not relevant to your PR. Thanks for all the work 👍.

@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from af8d812 to 854adf2 Compare March 17, 2020 07:01
@ojhalakshya ojhalakshya force-pushed the Hinge-Embedding-Loss-Function branch from 854adf2 to 778f4d2 Compare March 17, 2020 07:17
@kartikdutt18
Copy link
Copy Markdown
Member

Hey @ojhalakshya, Could you resolve the merge conflicts. Thanks a lot 👍

@kartikdutt18
Copy link
Copy Markdown
Member

kartikdutt18 commented Mar 18, 2020

Or if you could do a rebase before we merge this, that would be really great. I think we have fixed every possible build so all tests should pass. Thanks again 👍.

@ojhalakshya
Copy link
Copy Markdown
Contributor Author

Also if you could do a rebase before we merge this, that would be really great. I think we have fixed every possible build so all tests should pass. Thanks again .

I think its up to date now after resolving the conflict.

@kartikdutt18
Copy link
Copy Markdown
Member

Agreed, Thanks again. :)

@birm
Copy link
Copy Markdown
Member

birm commented Mar 18, 2020

@kartikdutt18 do you have any other review additions or conditions other than the tests passing?

@kartikdutt18
Copy link
Copy Markdown
Member

No, it's good to go for me 👍. Once the tests pass I think we can merge this, I think will since they did yesterday but might be better to wait for them anyway.

@ojhalakshya
Copy link
Copy Markdown
Contributor Author

@kartikdutt18 @birm
Thanks for the review. :)

@kartikdutt18
Copy link
Copy Markdown
Member

Really nice to see green builds. Thanks a lot @ojhalakshya for the great work.

@birm birm merged commit a967547 into mlpack:master Mar 18, 2020
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.

6 participants