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 check for 0 to 1 inclusive for elements of target tensor in BCE loss #97814

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions aten/src/ATen/native/Loss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ Tensor& binary_cross_entropy_out_cpu(const Tensor& input, const Tensor& target,
(input_val >= 0) && (input_val <= 1),
"all elements of input should be between 0 and 1"
);
TORCH_CHECK(
(target_val >= 0) && (target_val <= 1),
"all elements of target should be between 0 and 1"
);

// Binary cross entropy tensor is defined by the equation:
// L = -w (y ln(x) + (1-y) ln(1-x))
Expand Down