Repository navigation
Additoinal losses - #336
Conversation
awni
left a comment
There was a problem hiding this comment.
Thanks for the contribution!!
We already have a hinge and huber loss already. The focal, dice, and contrastive are in #324. Please remove all of them and rebase to resolve conflicts.
If you want to add the cosine loss in this PR that would be great.
add cos sim
cos sim test
awni
left a comment
There was a problem hiding this comment.
Thanks! I left a couple comments, please address then let me know when ready for re-review.
|
|
||
| if __name__ == "__main__": | ||
| unittest.main() | ||
|
|
There was a problem hiding this comment.
Nit: can you remove that extra line
|
Hey @Jyun1998 sorry but somehow my main comment did not get included. I must have not pushed the save button by accident. Basically I'm wondering what reference you use for this loss as it looks quite different than the similarly named cosine similarity loss in PyTorch ? For example there is a |
|
@Jyun1998 are you still planning to follow up on this? |
Hi awni, according to common tensorflow and pytorch implementaiton, the functions are composed of doing l2 norm to each embedding and returns the negative of dot product of both embedding. My codes also do so, and margin-based loss is applying if it's necessary :) |
|
@Jyun1998 got it. We should keep it simple until we see that we need more features. Could you follow the PyTorch cosine similarity loss? I think that one covers the most common case (margin / targets are are niche and possibly never needed so we don't want to add them to the API until we are sure they are necessary) |
I also agree. Even though there's also margin for pytorch F.cosine_similarity, it defaultly do not use it. There's only slight change needed for changes and I will test the function and commit asap. Thanks for the review |
|
I see, thanks. Yes let's go with the plain cosine similarity for now. Thank you! |
|
Also could you rebase and resolve conflicts? |
Am I correct that losses test codes are gone? nvm found new losses test file |
* fix: tidy pull request template * fix: feedback from awni
* Added scale for RoPE * Ran pre-commit * Added RoPE scaling test * Added docstring for scale parameter * Modified docstrings
* feat: Add Dropout3d layer to nn.layers * acknowledgement * Add dropout tests to test_nn.py * run pre-commit * Add activation functions and dropout3d ops * Add dropout tests for bfloat16 and float16
Co-authored-by: xuan <[email protected]>
Co-authored-by: Chunyang Wen <[email protected]>
* spelling: accumulates Signed-off-by: Josh Soref <[email protected]> * spelling: across Signed-off-by: Josh Soref <[email protected]> * spelling: additional Signed-off-by: Josh Soref <[email protected]> * spelling: against Signed-off-by: Josh Soref <[email protected]> * spelling: among Signed-off-by: Josh Soref <[email protected]> * spelling: array Signed-off-by: Josh Soref <[email protected]> * spelling: at least Signed-off-by: Josh Soref <[email protected]> * spelling: available Signed-off-by: Josh Soref <[email protected]> * spelling: axes Signed-off-by: Josh Soref <[email protected]> * spelling: basically Signed-off-by: Josh Soref <[email protected]> * spelling: bfloat Signed-off-by: Josh Soref <[email protected]> * spelling: bounds Signed-off-by: Josh Soref <[email protected]> * spelling: broadcast Signed-off-by: Josh Soref <[email protected]> * spelling: buffer Signed-off-by: Josh Soref <[email protected]> * spelling: class Signed-off-by: Josh Soref <[email protected]> * spelling: coefficients Signed-off-by: Josh Soref <[email protected]> * spelling: collision Signed-off-by: Josh Soref <[email protected]> * spelling: combinations Signed-off-by: Josh Soref <[email protected]> * spelling: committing Signed-off-by: Josh Soref <[email protected]> * spelling: computation Signed-off-by: Josh Soref <[email protected]> * spelling: consider Signed-off-by: Josh Soref <[email protected]> * spelling: constructing Signed-off-by: Josh Soref <[email protected]> * spelling: conversions Signed-off-by: Josh Soref <[email protected]> * spelling: correctly Signed-off-by: Josh Soref <[email protected]> * spelling: corresponding Signed-off-by: Josh Soref <[email protected]> * spelling: declaration Signed-off-by: Josh Soref <[email protected]> * spelling: default Signed-off-by: Josh Soref <[email protected]> * spelling: dependency Signed-off-by: Josh Soref <[email protected]> * spelling: destination Signed-off-by: Josh Soref <[email protected]> * spelling: destructor Signed-off-by: Josh Soref <[email protected]> * spelling: dimensions Signed-off-by: Josh Soref <[email protected]> * spelling: divided Signed-off-by: Josh Soref <[email protected]> * spelling: element-wise Signed-off-by: Josh Soref <[email protected]> * spelling: elements Signed-off-by: Josh Soref <[email protected]> * spelling: endianness Signed-off-by: Josh Soref <[email protected]> * spelling: equivalent Signed-off-by: Josh Soref <[email protected]> * spelling: explicitly Signed-off-by: Josh Soref <[email protected]> * spelling: github Signed-off-by: Josh Soref <[email protected]> * spelling: indices Signed-off-by: Josh Soref <[email protected]> * spelling: irregularly Signed-off-by: Josh Soref <[email protected]> * spelling: memory Signed-off-by: Josh Soref <[email protected]> * spelling: metallib Signed-off-by: Josh Soref <[email protected]> * spelling: negative Signed-off-by: Josh Soref <[email protected]> * spelling: notable Signed-off-by: Josh Soref <[email protected]> * spelling: optional Signed-off-by: Josh Soref <[email protected]> * spelling: otherwise Signed-off-by: Josh Soref <[email protected]> * spelling: overridden Signed-off-by: Josh Soref <[email protected]> * spelling: partially Signed-off-by: Josh Soref <[email protected]> * spelling: partition Signed-off-by: Josh Soref <[email protected]> * spelling: perform Signed-off-by: Josh Soref <[email protected]> * spelling: perturbations Signed-off-by: Josh Soref <[email protected]> * spelling: positively Signed-off-by: Josh Soref <[email protected]> * spelling: primitive Signed-off-by: Josh Soref <[email protected]> * spelling: repeat Signed-off-by: Josh Soref <[email protected]> * spelling: repeats Signed-off-by: Josh Soref <[email protected]> * spelling: respect Signed-off-by: Josh Soref <[email protected]> * spelling: respectively Signed-off-by: Josh Soref <[email protected]> * spelling: result Signed-off-by: Josh Soref <[email protected]> * spelling: rounding Signed-off-by: Josh Soref <[email protected]> * spelling: separate Signed-off-by: Josh Soref <[email protected]> * spelling: skipping Signed-off-by: Josh Soref <[email protected]> * spelling: structure Signed-off-by: Josh Soref <[email protected]> * spelling: the Signed-off-by: Josh Soref <[email protected]> * spelling: transpose Signed-off-by: Josh Soref <[email protected]> * spelling: unnecessary Signed-off-by: Josh Soref <[email protected]> * spelling: unneeded Signed-off-by: Josh Soref <[email protected]> * spelling: unsupported Signed-off-by: Josh Soref <[email protected]> --------- Signed-off-by: Josh Soref <[email protected]>
add cos sim
cos sim test
Could you check? Thanks :) |
awni
left a comment
There was a problem hiding this comment.
Looks great, thanks for the contribution @Jyun1998 !
feat: `ARRAY_API_TESTS_MODULE` for runtime-defined xp


Proposed changes
Added commonly used losses with tests
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes