[OpenVINO] Fix for SparseCategoricalCrossentropy: cast target to int before one_hot#22607
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22607 +/- ##
=======================================
Coverage 83.28% 83.28%
=======================================
Files 596 596
Lines 68102 68103 +1
Branches 10610 10610
=======================================
+ Hits 56720 56721 +1
Misses 8636 8636
Partials 2746 2746
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request enables several SparseCategoricalCrossentropy tests for the OpenVINO backend by introducing an unconditional cast of the target tensor to i64 within the sparse_categorical_crossentropy implementation. While this change allows the tests to pass, the feedback indicates that hardcoding this cast within the loss function is an internal implementation detail that violates Keras API design guidelines. It is recommended to handle such type conversions through the backend's type promotion logic instead of within the specific function implementation.
OpenVINO's
one_hotop requires integer indices, but target insparse_categorical_crossentropywas passed without casting, causing failures when float labels were provided.This PR adds casting target to int64 unconditionally at the top of
sparse_categorical_crossentropy, similar to how other backends do it.