-
Notifications
You must be signed in to change notification settings - Fork 4
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 Hard Negative Mining Layer. #24
Conversation
d7d1c06
to
0c9771a
Compare
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 for the PR! Left some minor comments
from keras_rs.src.layers.loss import hard_negative_mining | ||
|
||
|
||
class HardNegativeMiningTest(testing.TestCase, parameterized.TestCase): |
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.
Let's add a test_predict
test to check whether it works when compiled?
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.
Also added to FeatureCross
match. | ||
""" | ||
num_row = ops.shape(data)[0] | ||
num_column = ops.shape(data)[1] |
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.
Since we know it'll be a 2D tensor, we can rewrite these two lines to:
num_row, num_column = ops.shape(data)
num_hard_negatives: How many hard negatives to return. | ||
""" | ||
|
||
def __init__(self, num_hard_negatives: int) -> None: |
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.
**kwargs
, and then passed to super().__init__(**kwargs)
I'll be moving this layer to the |
This layer extract negative logits and labels. Also made layer test more similar.
0c9771a
to
54d34c6
Compare
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.
LGTM, thanks!
This layer extract negative logits and labels.